Ossobuko

Newbies
  • Content Count

    3
  • Joined

  • Last visited

Community Reputation

0
  1. Thanks for the help and ideas. Thank you very much for your quick response. This is really a great community. Yes, I know the code is horrible. It is meant to be used personally and on very small areas, so it actually works well enough (and not too bad). I solved the problem by removing random and using: RandomNumber.Next(256) Thanks BoltBait.
  2. Hello, I am a complete newbie. Sorry in advance. I am trying to develop a plugin for my personal use. But it seems there is a problem and I cannot understand why that happens. You can find the source code and example of the problem in the attached files. Here is steps to reproduce the problem: 1. open a transparent, empty image. 2. draw a shape to it. make sure it doesn't cover everything. 3. Effects>Object>Pixel Gradient Outline 4. Play with the dials until it stops working. At first everything works fine (like in the first picture), until the point of no return and it just starts to outline the object (look at the second picture). I am attaching dll file with source code and example pictures. // Name: Pixel Gradient Outline // Submenu: Object // Author: Ossobuko // Title: Pixel Gradient Outline // Version: 1 // Desc: // Keywords: // URL: // Help: #region UICode IntSliderControl Amount1 = 10; //[1,200]Radius #endregion static Random rnd = new Random(); void Render(Surface dst, Surface src, Rectangle rect) { // Delete any of these lines you don't need ColorBgra PrimaryColor = (ColorBgra)EnvironmentParameters.PrimaryColor; Surface output = blur(src, rect, Amount1); ColorBgra inputPixel, outputPixel; for (int y = rect.Top; y < rect.Bottom; y++) { if (IsCancelRequested) return; for (int x = rect.Left; x < rect.Right; x++) { // original image inputPixel = src[x,y]; // blurred original image outputPixel = output[x,y]; if ((inputPixel.A == 0) && (outputPixel.A != 0) && (rnd.Next(0,256) < outputPixel.A)) { dst[x,y] = PrimaryColor; } else dst[x,y] = inputPixel; } } } Surface blur(Surface src, Rectangle rect, float radius) { Surface dst = src.Clone(); for(float a=radius; a>0; a--) { Surface current = dst.Clone(); outline(current, src, rect, (int)a,ColorBgra.Black); for (int y = rect.Top; y < rect.Bottom; y++) { for (int x = rect.Left; x < rect.Right; x++) { if ((src[x,y].A == 0) && (current[x,y].A != 0)) { ColorBgra color = new ColorBgra(); color.R = color.G = color.B = 0; color.A = (byte) (int)(255*((radius-a)/radius)); dst[x,y] = color; } } } } return dst; } void outline(Surface dst, Surface src, Rectangle rect, int radius, ColorBgra color) { // Setup for calling Gaussian Blur GaussianBlurEffect blurEffect = new GaussianBlurEffect(); PropertyCollection bProps = blurEffect.CreatePropertyCollection(); PropertyBasedEffectConfigToken bParameters = new PropertyBasedEffectConfigToken(bProps); bParameters.SetPropertyValue(GaussianBlurEffect.PropertyNames.Radius, radius); // fix blurEffect.SetRenderInfo(bParameters, new RenderArgs(dst), new RenderArgs(src)); // Call Gaussian Blur blurEffect.Render(new Rectangle[1] {rect},0,1); ColorBgra inputPixel, outputPixel; for (int y = rect.Top; y < rect.Bottom; y++) { for (int x = rect.Left; x < rect.Right; x++) { // original image inputPixel = src[x,y]; // blurred original image outputPixel = dst[x,y]; if ((inputPixel.A == 0) && (outputPixel.A != 0)) { dst[x,y] = color; } else dst[x,y] = inputPixel; } } } MyScript.cs Pixel Gradient Outline - Pain.net.dll
  3. Layers > flip vertical Anything else?