BoltBait Posted February 11, 2013 Share Posted February 11, 2013 *idea!* *tinker* *tinker* *tinker* *give up* // Author: BoltBait // Submenu: Artistic // Name: Chalkboard // URL: http://www.BoltBait.com/pdn // Title: BoltBait's Chalkboard v1.0 #region UICode int Amount1 = 10; // [0,100] Radius int Amount2 = -10; // [-100,100] Brightness int Amount3 = 10; // [-100,100] Contrast double Amount4 = 0.9; // [0,1] Strength bool Amount5 = false; // [0,1] Invert Mask #endregion // Setup for using pixel op private UnaryPixelOps.Desaturate desaturateOp = new UnaryPixelOps.Desaturate(); private UnaryPixelOps.Invert invertOp = new UnaryPixelOps.Invert(); // Setup for using Darken blend op private UserBlendOps.MultiplyBlendOp multiplyOp = new UserBlendOps.MultiplyBlendOp(); // Here is the main render loop function unsafe void Render(Surface dst, Surface src, Rectangle rect) { // Setup for calling the Gaussian Blur effect GaussianBlurEffect blurEffect = new GaussianBlurEffect(); PropertyCollection blurProps = blurEffect.CreatePropertyCollection(); PropertyBasedEffectConfigToken BlurParameters = new PropertyBasedEffectConfigToken(blurProps); BlurParameters.SetPropertyValue(GaussianBlurEffect.PropertyNames.Radius, Amount1); blurEffect.SetRenderInfo(BlurParameters, new RenderArgs(dst), new RenderArgs(src)); // Call the Gaussian Blur function blurEffect.Render(new Rectangle[1] {rect},0,1); // Setup for calling the Brightness and Contrast function BrightnessAndContrastAdjustment bacAdjustment = new BrightnessAndContrastAdjustment(); PropertyCollection cProps = bacAdjustment.CreatePropertyCollection(); PropertyBasedEffectConfigToken cParameters = new PropertyBasedEffectConfigToken(cProps); cParameters.SetPropertyValue(BrightnessAndContrastAdjustment.PropertyNames.Brightness, Amount2); cParameters.SetPropertyValue(BrightnessAndContrastAdjustment.PropertyNames.Contrast, Amount3); bacAdjustment.SetRenderInfo(cParameters, new RenderArgs(dst), new RenderArgs(dst)); // Call the Brightness and Contrast function bacAdjustment.Render(new Rectangle[1] {rect},0,1); // Now in the main render loop, the dst canvas has a blurred version of the src canvas for (int y = rect.Top; y < rect.Bottom; y++) { ColorBgra* srcPtr = src.GetPointAddressUnchecked(rect.Left, y); ColorBgra* dstPtr = dst.GetPointAddressUnchecked(rect.Left, y); for (int x = rect.Left; x < rect.Right; x++) { ColorBgra CurrentPixel = *srcPtr; ColorBgra DestPixel = *dstPtr; // Desaturate pixels CurrentPixel = desaturateOp.Apply(CurrentPixel); DestPixel = desaturateOp.Apply(DestPixel); // Calculate difference in src and blurred dest pixel DestPixel.R = (byte)Math.Abs(CurrentPixel.R - DestPixel.R); DestPixel.G = (byte)Math.Abs(CurrentPixel.G - DestPixel.G); DestPixel.B = (byte)Math.Abs(CurrentPixel.B - DestPixel.; // Invert mask if (Amount5) DestPixel = invertOp.Apply(DestPixel); // Apply strength DestPixel.A = (byte)((double)DestPixel.A * Amount4); // Shade final pixel CurrentPixel = multiplyOp.Apply(*srcPtr, DestPixel); *dstPtr = CurrentPixel; srcPtr++; dstPtr++; } } } Quote Click to play: Download: BoltBait's Plugin Pack | CodeLab | and how about a Computer Dominos Game Link to comment Share on other sites More sharing options...
SAND33P Posted February 11, 2013 Share Posted February 11, 2013 I have only been learning basic Pascal programming in college but i kinda get how that works :O Probably not enough to help your problem though I might look into plugin programming one day Quote Link to comment Share on other sites More sharing options...
midora Posted February 11, 2013 Share Posted February 11, 2013 But now please tell us about the idea... Quote Link to comment Share on other sites More sharing options...
Ego Eram Reputo Posted February 11, 2013 Share Posted February 11, 2013 Trying to replicate an image drawn in chalk? Like these? Quote ebook: Mastering Paint.NET | resources: Plugin Index | Stereogram Tut | proud supporter of Codelab plugins: EER's Plugin Pack | Planetoid | StickMan | WhichSymbol+ | Dr Scott's Markup Renderer | CSV Filetype | dwarf horde plugins: Plugin Browser | ShapeMaker Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.