Jump to content

MJW

Members
  • Posts

    2,848
  • Joined

  • Last visited

  • Days Won

    70

Everything posted by MJW

  1. I believe you can use my Split Color and Brightness plugin to do that. - Put the image whose V you wish to modify in the lower layer, and the image whose V you wish to replace it with in the upper layer. - Set the upper layer's Blend Mode to Multiply. - Run Split Color and Brightness on the lower layer, with the Display set to Color. - Run Split Color and Brightness on the upper layer, with Display set to Brightness. - Merge the layers or flatten the image.
  2. The Split Color and Brightness plugin will do that. Set Display to Brightness and Blending Mode to Multiply. I believe there are some other plugins that can do that, also. I don't think there's any way to do so without using a plugin. In particular (even though it seems like it should work), I don't think that's what you get if you set Saturation to zero in the built-in Hue/Saturation Adjustment, though I'm not sure. That might be the first thing to try. I'll try to test that out later today, since it would be useful to know. EDIT: No. Unfortunately, setting Saturation to zero in the built-in Hue/Saturation Adjustment would not give you what you want.
  3. Some other suggestions: Food: banana lollipop or sucker Musical instruments: violin recorder hand bell Tools and the like: C clamp hammer screwdriver straight razor scissors lawn faucet Plants: pinecone pineapple tulip Various household items: baseball cap billiard ball goblet tennis shoe (might be too complex) ring book (with leather binding?) wine glass wine bottle pistol bicycle spool of thread open lipstick tube toothpaste tube toothbrush (manual?) dart hand fan paint brush light bulb lamp and shade Various: skull sheriff or police badge fire hydrant icicle duck decoy
  4. Except for my number-conversion routine, I don't see your code being that much simpler than mine. I like the fact that mine doesn't require any fancy-shmancy external parcing routine like JSON, though I can't say exactly why. I explained why I chose to parse the numbers myself: I wanted to convert in place instead of first splitting the selection string into scads of substrings. You may consider that to be pointless (as it may well be), but I did mention my reason. In any event, foolish or not, it was a choice, not ignorance of the existence of the Parse methods, which I referred to. (I need to use foreach more often -- it does make things more compact and intuitive. Most of my former high-level programming was in C, and I tend to fall back on old ways.) Thanks to your posting the JSON version, users now have two choices. I'll continue to use mine, though I expect most everyone else will (no doubt wisely) choose yours. I agree it would be very good for PDN to have built-in routines for converting the clipboard selection data. The possibility of a future change in the format did concern me.
  5. I wrote routines to parse the clipboard selection data. Perhaps others will find them useful. ParseClipboardSelection takes a clipboard selection-data string and produces a jagged PointF array that represents the selection. ToClipboardSelectionString takes a jagged PointF array and produces a string that can be written to the clipboard. I'm sure it could be more compact if I'd used regular expressions or such. One might reasonably question my decision to write a number parsing routine (GetDouble) instead of just using the built-in Parse methods. My objective (reasonable or not) was to do the conversion in place without having to produce a bunch of substrings. I will say, it was a very simple routine until I realized I also had to handle number strings with the "E" exponent format. I've tested the routines a fair amount. So far, so good. Please let me know of any problems.
  6. I was asked in a private message about how to write to the clipboard with the new PDN methods. I thought I'd copy my reply here. --------------------------------------------- I haven't yet tried to write an image to the clipboard. However, I have successfully written text to the clipboard using the new PDN routines. Here is the code I wrote to call the PDN routines. public bool SetClipboardText(string s) { try { Services.GetService<IClipboardService>().SetText(s); return true; } catch { return false; } } I disassembled the PDN clipboard code with ILSpy, to find out how to write an image. I believe the following should work: public bool SetClipboardImage(Image i) { try { Services.GetService<IClipboardService>().SetImage(i); return true; } catch { return false; } } There are also overloads of SetImage() to handle Bitmaps and PDN Surfaces.
  7. I agree that would be a desirable feature. Having a program hang for a long time when trying to cancel an operation is very annoying. That was true seven years ago, and it's true today
  8. Though I could be wrong, I'm concerned that the subject of a chicken may be a too difficult to attract many entries. There are a lot of component parts and tricky textures involved, I would think. More specifically, I don't see how the usual methods of plugins, shapes, and such would help much. The only way I can think of to create a reasonable image of a chicken is to draw one.
  9. Okay, I finally get what you mean, and it does seem like it might be a good idea. You want the option of having a reset button on the List Box control. I suppose the reason List Boxes don't have reset buttons is because the choices are a fairly small range of distinct values, instead of a large more-or-less continuous range of values. I must admit, I never really thought about the fact that List Boxes don't have reset buttons like most of the other controls. EDIT: Probably not, but possibly List Boxes do have an optional reset button that's just normally disabled. For instance, Checkboxes can have a title above the checkbox just like other controls, but it's normally disabled. If someone else doesn't provide an answer to that, I'll try to look into it later today or tomorrow. If List Boxes can have a reset button, it would be up to BoltBait to provide access to it in CodeLab. (As you correctly surmised, the reset button is an integral part of a control, not a separate control connected to the main control.)
  10. I'm still not quite sure what you want to do, but if it's to have the plugin always start with the default control settings instead of the settings it was last executed with, there's not really a challenge, because I'm pretty sure it simply can't be done in CodeLab or in any other way that uses Indirect UI. Likewise, if it's to have a button that resets all four controls to their defaults. (I probably should qualify that with "it can't be done in an allowable way." I suppose it might be possible using reflection.)
  11. Well, the only way I can see to do that is to treat None as a special case. When a control in set to None, instead of getting the color to use from a table, as you do with the other entries, you need to get it from the pixel in the source image.
  12. After looking at the code, I'm not at all sure what you meant by "reset all the values of 4 ListBoxControls (None)," or how that relates to "I just added a new choice (None) that seems to do the trick." Perhaps if you explain in more detail, I'll have a theory about why it would crash. Did you add a "None" choice to each list box. And if so, what does it mean as far as the desired behavior of the plugin? What's supposed to happen if None is selected?
  13. If I understand your UI correctly, you might want to disable the ListBoxControls when None is selected. As I recall, unfortunately that can only be done in CodeLab if None is the first choice in the list, but it seems like it might be an appropriate first choice.
  14. Actually, my request is different. It's a request that the user (not the programmer) optionally be able to restore individual controls to the value that was set when the plugin was started, instead of the default value. In other words, the value to which the control would be set if the plugin were cancelled and rerun. I quite often adjust a control, then wish I could return the control to its original value when I started the plugin; sometimes because I adjust the wrong control; other times because I simply realize the adjustment wasn't what I wanted. As to your hope of resetting a number of controls with a button or some such, unfortunately I believe there's no way to do that in Indirect UI, either in CodeLab or Visual Studio. There's no external ability to change or reset a UI control.
  15. I'm surprised -- almost amazed. That does sound exactly like what you want. If the source code is available, I'd like to look at it to see what the algorithm is.
  16. Good luck, and I hope it works, but index suggests to me a feature that might find the nearest index in a linear array; but I'm doubtful about there being a built-in feature that finds the nearest point, using Euclidean distance, in a 3D array. Finding the nearest value in a sorted linear array, using e.g. a binary search, is comparatively easy. Colors can't be sorted into a linear array.
  17. Have you not paid attention to the long discussion about the difficulty of matching a huge palette in a reasonable amount of time?
  18. As I mentioned, there is an algorithm I describe in Fast algorithm for finding the minimum distances to a set that I believe could do the job in a reasonable time. The updated code for the "nearest pixel transform" algorithm (which would become the nearest color transform) is given in a later comment, since for some reason I couldn't update the lead comment. The "set pixels" mentioned in the algorithm correspond the the colors that are present in the palette image. The algorithm would need to be extended from two dimensions to three, to handle the three color components. I'm confident that would fairly straightforward -- it's just applying the second stage in the algorithm again in the other direction. Once the Nearest Color table is build, the colors in the second image could be replaced just by indexing into the table and fetching the color. Each entry in the 256x256x256 table is the nearest palette color. I'd be happy to help anyone who wants to try it, but I'm not inclined to do it myself. It seems like quite a lot of work for a very limited audience. I can't imagine why anyone would want to use a palette of 14 million color.
  19. I'm pretty sure the idea is that the new image contain only colors from the image used to build the palette.
  20. I kind of think the first part is pretty trivial compared to the second part.
  21. I thought the point was to find the nearest matching color. Finding the unique colors is pretty easy, I think. Just construct a linear bit-array of length 256x256x256. Then go through the image colors, setting the bit corresponding to (B << 16| G << 8 | R).
  22. Perhaps I'm dense, but that's not enough detail for me to understand the color-matching algorithm. If you're willing to construct a 256x256x256 three of four byte table, I believe the ideas described in Fast algorithm for finding the minimum distances to a set could be used to construct a nearest-color table in linear time. From then on, it's just a lookup per image color. Though the thread describes a two-dimensional version, the algorithm for finding the nearest set array element extends to any number of dimensions.
  23. To see that for 14 million distinct colors, I suggest a wide monitor. Perhaps the gmic colormap command does allow recoloring an image with a 14-16 million entry palette, but color me skeptical. Which is to say, while I believe there are algorithms that could efficiently do that, time-wise, as far as I know, they're quite non-obvious, and require lots of memory. If the colormap command can truly quickly recolor an image to such a large palette, I would be very interested to know the algorithm it uses. The selective palette plugin is slow, because for each color in the image it has to do 14-16 million color comparisons to find the best match. Obviously, that takes a bit of time.
  24. I am a programmer -- which is why I included the parenthetical "I believe." The one possible major complication I can see is that during the time the Line/Curve tool is active, the last end point would need to be part of state, and therefore part of the History state; so that Undoing a series of curves would work as expected when adding the next curve. That could be a minor matter, or it could be incompatible with the way the history data is recorded. If the latter, obviously it might require more effort than it's worth. Other than the History consideration, it's only a matter of slightly changing the manner of setting the initial point in the curve. I could be wrong about that, but don't think it's likely. Nevertheless, I do apologize to Rick Brewster if I seemed presumptuous. EDIT: I don't think the History angle is probably a significant problem. Undoing to the point before the last undeleted curve is finalized shows the nodes, so I think they must already be included in the History state.
×
×
  • Create New...