Jump to content

archip

Members
  • Posts

    18
  • Joined

  • Last visited

Recent Profile Visitors

796 profile views

archip's Achievements

Apprentice

Apprentice (3/14)

  • First Post
  • Collaborator
  • Conversation Starter
  • Week One Done
  • One Month Later

Recent Badges

4

Reputation

  1. Hello, When I work on my games, I often want to see how a picture render in game (which means save it as a PNG) but I want to keep the layered information because it makes future modifications easier. Currently, what I do is : What I want to do : My dream would be that there is a shortcut to save directly as a copy and that you can parameter it to apply some post-processing (like scaling because I prefer working with big images). link to an older topic with the same request : http://forums.getpaint.net/index.php?/topic/24725-request-and-recommended-approach-to-implement-a-save-as-copy-feature/ Thanks, archip
  2. Sorry to resurrect this but I also think it should be an option because it's very annoying to lose the selection when we clear it. Or maybe just have a filter that clear the selection.
  3. For now, the effect is applied to the entire image, I'll change this when I find how. I'll also change the menu placement. If you have suggestion post them and I'll see what I can do.
  4. Thanks, I've updated the first post
  5. This plugin deletes small islands of pixels. When I use the magic wand, some pixels aren't deleted. The plugin deletes them, if they are surrounded by transparent pixels. : It has two parameters : - radius threshold : Delete island up to this size. - alpha threshold : A pixel will be considered transparent up to this value. @toe_head2001 has recompiled this plugin to make it compatible with PDN 4.0+. StrayPixelRemover.zip
  6. Actually the program works well. The problem was that sometimes I launched the old version of the plugin... :S Thanks for your help, I'll make a release soon
  7. I've solved most of my problems and I've manage to do an UI but there is still a bug. The plugin works but when I launch it 3 or 4 times, it crashes. It looks like memory leak or something but I don't understand why since there is a garbage collector in C#. I've tried different thing but nothing work. Rectangle R; Surface SURF = null; List<Point> ToDelete = new List<Point>(); protected override void OnRender(Rectangle[] rois, int startIndex, int length) { Surface src = SrcArgs.Surface; R = SrcArgs.Surface.Bounds; SURF = new Surface(R.Size); SURF.CopySurface(SrcArgs.Surface); for (int y = R.Top; y < R.Bottom; y++) { for (int x = R.Left; x < R.Right; x++) { ToDelete.Clear(); if (testForDelete(x, y, 0, true, true, true, true)) { //If we need to delete the pixel SURF[x, y] = ColorBgra.Transparent; // we delete it foreach (Point p in ToDelete) //delete contiguous pixels { SURF[p.X, p.Y] = ColorBgra.Transparent; } } } } DstArgs.Surface.CopySurface(SURF); } //return true if the pixel has to be deleted bool testForDelete(int px, int py, int dist, bool h, bool b, bool g, bool d) { if (dist > propThresHoldSlider) return false; //too far from tested pixel if (px < R.Left || py < R.Top || px >= R.Right || py >= R.Bottom) return true; //out of screen if (SURF[px, py].A == 0) return true; // transparent bool ret = true; if (ret && h == true) ret = testForDelete(px, py - 1, dist + 1, true, false, g, d); if (ret && b == true) ret = testForDelete(px, py + 1, dist + 1, false, true, g, d); if (ret && g == true) ret = testForDelete(px - 1, py, dist + 1, h, b, true, false); if (ret && d == true) ret = testForDelete(px + 1, py, dist + 1, h, b, false, true); //if surrounded only by pixel that must be deleted and pixel that are transparent, return true. if (ret) ToDelete.Add(new Point(px, py)); return ret; } I've joined the full code. I hope you will help me solve my last problems straypixelremover.txt
  8. Yes, it's exactly the tools I want but it seems like avim hasn't developped the plugin. Also, I've found Ed Harvey's threshold effect but it isn't what I want.
  9. My new optimisation made multithreading impossible Where can I have a look at PropertyBased Effect plugins ? I can't find anything Also, I have different problems : - Even if I click cancel, the effect is applied - When effect is applied I can't cancel it even if I go back in the history. My code so far : using System; using System.Collections; using System.Drawing; using PaintDotNet; using PaintDotNet.Effects; using System.Collections.Generic; namespace StrayPixels { public class EffectPlugin : PaintDotNet.Effects.Effect { public static string StaticName { get { return "Stray deleter"; } } // public static Bitmap StaticIcon // { // get // { // return new Bitmap(typeof(EffectPlugin), "EffectPluginIcon.png"); // } // } // // Entire StaticIcon method (above) can be replaced by the line below referencing an icon (png) held in Resources // public static Bitmap StaticImage { get { return Properties.Resources.Icon; } } public static string StaticSubMenuName { get { return SubmenuNames.Render; // Use for existing submenu } } public EffectPlugin() : base(EffectPlugin.StaticName, EffectPlugin.StaticImage, EffectPlugin.StaticSubMenuName, EffectFlags.Configurable | EffectFlags.SingleThreaded) { } public override EffectConfigDialog CreateConfigDialog() { return new EffectPluginConfigDialog(); } Rectangle R; Surface SRC; List<Point> ToDelete = new List<Point>(); int DISTANCE = 3; public override void Render(EffectConfigToken parameters, RenderArgs dstArgs, RenderArgs srcArgs, Rectangle[] rois, int startIndex, int length) { Surface src = srcArgs.Surface; dstArgs.Surface.CopySurface(src, rois); Surface dst = dstArgs.Surface; SRC = src; R = SRC.Bounds; ColorBgra VoidPixel = new ColorBgra(); VoidPixel.A = 0; for (int y = R.Top; y < R.Bottom; y++) { for (int x = R.Left; x < R.Right; x++) { ToDelete.Clear(); if (testForDelete(x, y, 0, true, true, true, true)) { //If we need to delete the pixel dst[x, y] = VoidPixel; // we delete it foreach (Point p in ToDelete) //delete contiguous pixels { SRC[p.X, p.Y] = VoidPixel; } } } } for (int y = R.Top; y < R.Bottom; y++) { for (int x = R.Left; x < R.Right; x++) { dst[x, y] = SRC[x, y]; //copy new image } } } //return true if the pixel has to be deleted bool testForDelete(int px, int py, int dist, bool h, bool b, bool g, bool d) { if (dist > DISTANCE) return false; //too far from tested pixel if (px < R.Left || py < R.Top || px >= R.Right || py >= R.Bottom) return true; //out of screen if (SRC[px, py].A == 0) return true; // transparent bool ret = true; if (ret && h == true) ret = testForDelete(px, py - 1, dist + 1, true, false, g, d); if (ret && b == true) ret = testForDelete(px, py + 1, dist + 1, false, true, g, d); if (ret && g == true) ret = testForDelete(px - 1, py, dist + 1, h, b, true, false); if (ret && d == true) ret = testForDelete(px + 1, py, dist + 1, h, b, false, true); //if surrounded only by pixel that must be deleted and pixel that are transparent, return true. if (ret) ToDelete.Add(new Point(px, py)); return ret; } } }
  10. You were right on the spot, ROI were the cause of the problem so I tried VS2010 and I have no more problem with it ! using System; using System.Collections; using System.Drawing; using PaintDotNet; using PaintDotNet.Effects; namespace StrayPixels { public class EffectPlugin : PaintDotNet.Effects.Effect { public static string StaticName { get { return "Stray deleter"; } } // public static Bitmap StaticIcon // { // get // { // return new Bitmap(typeof(EffectPlugin), "EffectPluginIcon.png"); // } // } // // Entire StaticIcon method (above) can be replaced by the line below referencing an icon (png) held in Resources // public static Bitmap StaticImage { get { return Properties.Resources.Icon; } } public static string StaticSubMenuName { get { // return null; // Use for no submenu return SubmenuNames.Render; // Use for existing submenu // return "My SubMenu"; // Use for custom submenu } } public EffectPlugin() : base(EffectPlugin.StaticName, EffectPlugin.StaticImage, EffectPlugin.StaticSubMenuName, EffectFlags.Configurable | EffectFlags.SingleThreaded) { } public override EffectConfigDialog CreateConfigDialog() { return new EffectPluginConfigDialog(); } Rectangle R; Surface SRC; public override void Render(EffectConfigToken parameters, RenderArgs dstArgs, RenderArgs srcArgs, Rectangle[] rois, int startIndex, int length) { /*PdnRegion selectionRegion = EnvironmentParameters.GetSelection(srcArgs.Bounds); for (int i = startIndex; i < startIndex + length; ++i) { Rectangle rect = rois[i]; for (int y = rect.Top; y < rect.Bottom; ++y) { for (int x = rect.Left; x < rect.Right; ++x) { // Render Code Here } } }*/ Surface src = srcArgs.Surface; dstArgs.Surface.CopySurface(src, rois); Surface dst = dstArgs.Surface; SRC = src; R = SRC.Bounds; ColorBgra CurrentPixel; for (int ite = 0; ite < 5; ite++) { for (int y = R.Top; y < R.Bottom; y++) { for (int x = R.Left; x < R.Right; x++) { CurrentPixel = src[x, y]; if (testForDelete(x, y, 0, true, true, true, true)) //If we need to delete the pixel CurrentPixel.A = 0; // we delete it dst[x, y] = CurrentPixel; } } } } //return true if the pixel has to be deleted bool testForDelete(int px, int py, int dist, bool h, bool b, bool g, bool d) { if (dist > 2) return false; //too far from tested pixel if (px < R.Left || py < R.Top || px >= R.Right || py >= R.Bottom) return true; //out of screen if (SRC[px, py].A == 0) return true; // transparent bool ret = true; if (ret && h == true) ret = testForDelete(px, py - 1, dist + 1, true, false, g, d); if (ret && b == true) ret = testForDelete(px, py + 1, dist + 1, false, true, g, d); if (ret && g == true) ret = testForDelete(px - 1, py, dist + 1, h, b, true, false); if (ret && d == true) ret = testForDelete(px + 1, py, dist + 1, h, b, false, true); //if surrounded only by pixel that must be deleted and pixel that are transparent, return true. return ret; } } } I have looked the dust removal filter but it doesn't do what I want so I'll finish this plugin. I have to optimize it (I have some ideas) and make an option to choose the threehold. I'll try to do it this weekend or next week and then I'll publish the DLL.
×
×
  • Create New...