drakaan Posted September 21, 2007 Share Posted September 21, 2007 Hi Rick...which file(s) have the layer blending operations? Are they inside of a larger class or module? Quote Link to comment Share on other sites More sharing options...
Rick Brewster Posted September 21, 2007 Share Posted September 21, 2007 src/Data/UserBlendOps*.* It uses a code generator though, because of the "hole-in-the-middle" pattern (the three choices were to use a code generator, or have very high maintenance costs w/ error prone code, or have abysmal performance). http://enfranchisedmind.com/blog/archive/2007/07/10/279 Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html Link to comment Share on other sites More sharing options...
drakaan Posted September 21, 2007 Author Share Posted September 21, 2007 ahh...I see. ...and looking at UserBlendOps.Generated.H.cs I begin to see why there's currently nothing in the way of HSV-dependent blend modes. PaintDotNet.Data.dll is the assembly this ends up in, correct? Quote Link to comment Share on other sites More sharing options...
Rick Brewster Posted September 21, 2007 Share Posted September 21, 2007 Yes, this goes in to the Data dll. Why do you ask? Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html Link to comment Share on other sites More sharing options...
drakaan Posted September 22, 2007 Author Share Posted September 22, 2007 I'm thinking about hacking a patch for a "hue" blend mode, and I don't want to replace any more DLLs than I have to. I won't be able to start on it until Monday (my home machine's not an ideal development box), but I'm thinking it's definitely possible...I'll have to reference the colorHSV.cs code, or add a couple of conversion functions, and I'm not sure how fast it'll be, but I'm optimistic. At least it's math that's simple enough for me to actually grok. Quote Link to comment Share on other sites More sharing options...
pyrochild Posted September 22, 2007 Share Posted September 22, 2007 IIRC, you'll only need to replace the one DLL, but you'll also need to add entries in the resources file... Quote ambigram signature by Kemaru [i write plugins and stuff] If you like a post, upvote it! Link to comment Share on other sites More sharing options...
drakaan Posted September 22, 2007 Author Share Posted September 22, 2007 pyro, be prepared for some questions from me next week...I may need some advice from you... Quote Link to comment Share on other sites More sharing options...
drakaan Posted September 24, 2007 Author Share Posted September 24, 2007 Okay...two questions. One: if the functions for HSV blend ops take a different number of arguments (they appear to need 9...left and right hsv, and resultant hsv...I'm not making new classes, just 4-5 functions to support conversion to-from HSV), do I need to make a new "UserHSVBlendOps" file set that parallels the UserBlendOps files? I think the answer is yes..I don't see how I'd get around it, without seriously changing UserBlendOps.cs. It's dynamic for RGB-based operations, but since I can't operate on each color channel separately, it doesn't seem possible to add HSV-based functions without an additional blenderops framework. Two, where in the resources will I find blend-related stuff? Quote Link to comment Share on other sites More sharing options...
Rick Brewster Posted September 24, 2007 Share Posted September 24, 2007 Uhh ... you can't just define whatever parameters you want. The layer composition system will only use blend ops provided by the UserBlendOps class. Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html Link to comment Share on other sites More sharing options...
drakaan Posted September 24, 2007 Author Share Posted September 24, 2007 Uhh ... you can't just define whatever parameters you want. The layer composition system will only use blend ops provided by the UserBlendOps class. Understood (hence the question about this requiring a parallel class of UserHSVBlendOps). I know I wasn't very clear when I mentioned not creating new classes...I was typing faster than I was thinking. Rephrased, the question would be something like: In order to do HSV-based blender ops, would I need to create a UserHSVBlendOps class (using a similar "hole-in-the-middle" pattern) in order to circumvent the function parameter structure inherent in the existing UserBlendOps class? I think you just gave me the answer, though (yes, I'd have to make another class for HSV-based blender ops). Using the existing UserBlendOps.Generated.H.cs, I have an initial stab at UserHSVBlendOps.Generated.H.cs, so I need to get cracking on the supporting code. There's not a ton of code involved. A few subs (RGB_TO_HSV, HSV_TO_RGB, MOD_3D, ARG_RAD) and three trivial blend modes (HUE_ONLY, SAT_ONLY, VALUE_ONLY, and COLOR (hue + saturation)). ... Any pointers relating to question #2? Quote Link to comment Share on other sites More sharing options...
drakaan Posted September 25, 2007 Author Share Posted September 25, 2007 Okay...I finally scrolled down far enough to find the mappings for the blend mode names in the userblendops source. I ran into a big circle trying to figure out which file the layer properties window is in, though. The layer window code defines an event handler, which points to a sub, which does something that's not obvious to me (admittedly a n00b in programming windows forms applications). Is the layer properties window dynamically generated, or is there a source file that I missed somewhere? Quote Link to comment Share on other sites More sharing options...
Rick Brewster Posted September 25, 2007 Share Posted September 25, 2007 BitmapLayerPropertDialog.cs BitmapLayer derives from Layer, and even though there's no other type of layer other than a bitmap layer, at some level the rendering system still has no preference as to what type of layers it's working with. I wouldn't put too much investment in this hack/patch, as this stuff is very likely to change in a future version of Paint.NET (as in, it's guaranteed to). If you use these HSV blend ops of yours in a PDN, it will be completely unreadable by any official build of Paint.NET and will just say "unknown error opening ... you might have saved it in a newer version." Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html Link to comment Share on other sites More sharing options...
drakaan Posted September 25, 2007 Author Share Posted September 25, 2007 BitmapLayerPropertDialog.csBitmapLayer derives from Layer, and even though there's no other type of layer other than a bitmap layer, at some level the rendering system still has no preference as to what type of layers it's working with. I wouldn't put too much investment in this hack/patch, as this stuff is very likely to change in a future version of Paint.NET (as in, it's guaranteed to). If you use these HSV blend ops of yours in a PDN, it will be completely unreadable by any official build of Paint.NET and will just say "unknown error opening ... you might have saved it in a newer version." Mainly, this is a learning expedition for me. I've been wanting to get more familiar with the source for a while, and this is a good opportunity for me to see some real-world windows forms programming. I fully expect anything I change to be rendered obsolete (pun intended) buy future installments of Paint.Net, but I'm very interested in going back later and seeing how you've architected the changes you end up making vs. what's there now. I do a fair bit of .net development, but almost exclusively in the realm of web apps, so UI-related stuff (and things that can't work very well in a web page) are interesting but foreign to me. My only regret today is that I don't have as much time as I'd like to mess with this little project because of my normal work. When you say "likely [guaranteed] to change in a future version", are you talking 3.x or 4.x? Quote Link to comment Share on other sites More sharing options...
Rick Brewster Posted September 25, 2007 Share Posted September 25, 2007 Yeah, I'm thinking 4.x possibly. There has also been interest in allowing blending mode plugins, and once I have a generalized system for discovering them and doing error handling, then this should be a no brainer. Basically Paint.NET needs to be able to load a PDN and if it discovers an element (layer type, blend type, etc.) that it can't find code for it should revert it to a default type and tell the user "This requires a plugin that you don't have, so I used defaults instead" Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html Link to comment Share on other sites More sharing options...
drakaan Posted September 26, 2007 Author Share Posted September 26, 2007 If this was slashdot, that bit of info would've been modded +5 informative (or maybe interesting). ...at least to me. Then again, I think I've either started or commented on every blend-mode or blend plugin related thread for the past 3 months, so I'm unnaturally interested in this subject, anyway Actually, one of the things that didn't really occur to me when I first started thinking about blend modes was that they're not transient (like effects are). If you close the file, the blend modes have to be applied when you start up again. A default mode would be a handy way around that, for sure. I haven't said it recently, Rick, but thank you for Paint.NET, and I truly mean that. Quote Link to comment Share on other sites More sharing options...
barkbark00 Posted September 26, 2007 Share Posted September 26, 2007 ...I haven't said it recently, Rick, but thank you for Paint.NET, and I truly mean that. At this I lol'd... You kind of sound like a brain doctor who has come to God after studying his masterpiece... Ok, ok! I'll stop laughing at your sincerity... Quote Take responsibility for your own intelligence. 😉 -Rick Brewster 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.