Jump to content

Felix The Ghost

Members
  • Posts

    20
  • Joined

  • Last visited

About Felix The Ghost

  • Birthday 03/09/1991

Profile Information

  • Gender
    Male
  • Location
    Oklahoma. USA
  • Interests
    Sex, drugs, and mild salsa

Felix The Ghost's Achievements

Apprentice

Apprentice (3/14)

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

Recent Badges

0

Reputation

  1. I'm looking to update a program I created a long time ago, found out today there are several new versions of CodeLab. I looked at the comments following the announcement of the version that supports single-threading. Is it true it will still split up the image into independent units?
  2. I stand by my original statement. Use your status to get me the source code or refrain from posting in threads you have no possible way of knowing how contribute to :-)
  3. I just downloaded and tried the Paint.net 4 Beta and though I like the improvements, I am surprised there still isn't an option (that I see) to toggle selection edges. I did a forum search and it seems some users don't see the use of it, but as a Photoshop user I can personally attest to the convenience of hiding them when you have already made your selection and are experimenting with adjustments within the selection (e.g. color adjustments) It gives you a more accurate visual of the render while you are in the effect window before it is finalized. Currently in Paint.net I can make a selection, copy its contents into a new layer, then open the desired adjustment/filter window(s) without a selection as it will affect the entire layer (which only contains what we pasted in) But that is a lot of work around for what could be as easy as a keyboard shortcut and/or a menu item in View->Selection Edges And in implementation, I cannot imagine it being hard to add logic to NOT render the edges. You can even unset the option when the selection is modified if we are afraid it will confuse some users. I would like to see this implemented in the next beta release (assuming it's not there and I missed it) Thanks.
  4. I'll have to see how others have posted plugins but I should have it out within a few days when I have more free time. I very much appreciate the help
  5. Very clever! I see you got it to respect selections too! I still don't know what you use object sync = new object(); for in the code though. I also like the reseed button but I can probably figure that out. I thought I posted this but I guess I closed the browser before posting.
  6. I don't mean to sound repetitive but there isn't enough information there to judge speed. I can create a 1024x768 blank image, draw a gradient and posterize it to reduce colors (reduced to 43 colors in my test) and the plugin renders in less than three seconds. Since each pixel loops through colors[] the amount of unique colors greatly affects speed I will have to see if there is some c# container that retains order but has quick-access (keyword or something) Rick, does ConcurrentSet preserve order? There needs to be a copy of the container with tweaked colors. Maybe it can be a concurrentSet with a custom struct of two colors so order is no longer important? You should test on those linked images if you haven't yet (you can drag and drop into Paint.net)
  7. Will check it out when I can! Thanks for the help so far. Append: I think it is important to note that it is intended to be used on images with few colors like these (not my work, just illustrates my point) Large image, but few colors, renders in less than two seconds for me. and Less than one second on this one Maybe it is possible to build in a safety when there are over say 512 unique colors (or maybe a slider) to not render if it will be slow and take a long time to cancel. And you are right the multithreaded one has a different effect than I am aiming for. I am basically mutating colors into other colors randomly with a randomly generated "palette swap" so every instance of a specific color is changed the same way. I do not understand this code: Random rndm = new Random((int)Guid.NewGuid().GetHashCode()); I thought RandomNumber was specifically created to be the best option for Code Lab? I also am not sure but wouldn't this Color[] colors = new Color[rect.Width * rect.Height]; Color[] off_colors = new Color[rect.Width * rect.Height]; negatively affect performance? It seems to assume each pixel of the image is a unique color rather than expanding in size as new unique colors are identified. I am not familiar with all the C# container classes but I do think the container should have a dynamic size (I do not know how that affects threading) Perhaps we can use ConcurrentSet as Rick recommends? This is what I am using to count unique colors in the image some images on google from older games that would be great examples have JPEG compression and you can see through the plugin it gives them many unique colors which slow down the effect. The posterize effect can help reduce color. Also, I noticed the effect ignores selections except in the preview and transparency is lost. I made a filter using CodeLab before and it respects selections, so I do not know what is wrong. I'll have to investigate further tomorrow but I wanted to give feedback immediately as I appreciate your help.
  8. This is really frustrating. I keep changing code with poor version control so I'm posting this to see if anyone sees something obviously wrong that I don't. #region UICode int Amount1=1; //[0,100]Hue Adjust int Amount2=1; //[0,100]Saturation Adjust int Amount3=1; //[0,100]Value Adjust byte Amount4 = 0; // [255] Reseed #endregion List<Color> colors = new List<Color>(); List<Color> off_colors = new List<Color>(); object sync = new object(); void Render(Surface dst, Surface src, Rectangle rect) { bool match = false; ColorBgra CurrentPixel; //populate colors for (int y = rect.Top; y < rect.Bottom; y++) { for (int x = rect.Left; x < rect.Right; x++) { CurrentPixel = src[x,y]; match = false; lock (sync) { for (int i = 0; i < colors.Count; i++) { if (CurrentPixel.ToColor().Equals(colors[i])) { match = true; break; } } if (!match) { colors.Add(CurrentPixel.ToColor()); } } } } //tweak colors HsvColor hsv; int H = 0, S = 0, V = 0; for (int i = 0; i < colors.Count; i++) { //hsv = HsvColor.FromColor(colors[i]); //H = hsv.Hue; //S = hsv.Saturation; //V = hsv.Value; //H -= (RandomNumber.Next(Amount1 * 180 / 100)); //H += (RandomNumber.Next(Amount1 * 180 / 100)); //S -= (RandomNumber.Next(Amount2) / 2); //S += (RandomNumber.Next(Amount2) / 2); //V -= RandomNumber.Next(Amount3) / 2; //V += RandomNumber.Next(Amount3) / 2; //if (H < 0) H = 360; //if (H > 360) H = 360; //if (S < 0) S = 0; //if (S > 100) S = 100; //if (V < 0) V = 100; //if (V > 100) V = 100; //hsv = new HsvColor(H,S,V); //off_colors.Add(hsv.ToColor()); off_colors.Add(colors[i]); } // Colorize for (int y = rect.Top; y < rect.Bottom; y++) { for (int x = rect.Left; x < rect.Right; x++) { CurrentPixel = src[x,y]; for (int i = 0; i < colors.Count; i++) { if (CurrentPixel.ToColor().Equals(colors[i])) { CurrentPixel = ColorBgra.FromColor(off_colors[i]); break; } } dst[x,y] = CurrentPixel; } } }
  9. Looked good at a glance, but Paint.net uses int and not double for hsv. So what is the functional range of H, S, V? Edit: Going to guess based on the color window in Paint.net: 0..360 0..100 0..100 Append: Seems to work well, but I have trouble accessing the user variables Amount1 etc within the lock() sections. It just returns the value they were initialized with
  10. Thanks, I'm aware of that tutorial, but I'm surprised there isn't something somewhere that's more in-depth (Even just the source code for the data types would help) I don't even know the functional ranges of H/S/B. (like R/G/B is 0-255) The tutorial does confirm my suspicions on the need to reassemble the structure each time a member is modified, though.
  11. This is what I have so far: #region UICode int Amount1=3; //[0,255]Hue Variation #endregion List<ColorBgra> colors = new List<ColorBgra>(); List<ColorBgra> off_colors = new List<ColorBgra>(); HsvColor hsv = new HsvColor(0,0,0); int hue_plus = 0; int hue_minus = 0; bool match = false; object sync = new object(); Random rnd = new Random(); void Render(Surface dst, Surface src, Rectangle rect) { ColorBgra CurrentPixel; for (int y = rect.Top; y < rect.Bottom; y++) { for (int x = rect.Left; x < rect.Right; x++) { lock (sync) { CurrentPixel = src[x,y]; for (int i = 0; i < colors.Count; i++) { if (CurrentPixel.Equals(colors[i])) { match = true; CurrentPixel = off_colors[i]; break; } } if (!match) { colors.Add(CurrentPixel); hsv = HsvColor.FromColor(CurrentPixel); hue_plus = rnd.Next((Amount1/2)); hue_minus = rnd.Next((Amount1/2)); hsv.Hue += hue_plus; hsv.Hue -= hue_minus; off_colors.Add(ColorBgra.FromColor(hsv.ToColor())); CurrentPixel = ColorBgra.FromColor(hsv.ToColor()); } dst[x,y] = CurrentPixel; match = false; } } } } Both Lists are increased in size at the same step so they should stay the same size. Lots of redundant code in the (!match) block because I guess I don't understand the ColorBgra/HsvColor data types; What was supposed to be a simple += turned into that experimental mess (still doesn't work -- guessing this kind of behavior is not allowed and the struct needs to be recreated each time instead of modifying its members directly?) Not sure where to read up on the datatypes Paint.net uses. I couldn't even tell you the data types of their members though I found out r,g,b,a are bytes. The goal is to be able to "tweak" colors in an image randomly to sort of mutate placeholder colors into something more desirable.
  12. I'm eventually going to have an identical size List to do a pseudo "palette swap" effect so I think I will have to preserve the order of the elements. I'll also not use it on images of many colors so speed shouldn't be an issue.
×
×
  • Create New...