last day (15 days later) » 

14:53
0
Q: Destructure a solid color into overlayed colors with transparency

EnchewI am working on an application, in which I export an image with different shapes (rectangles, circles, polygons and etc). Each shape has its own unique color. Currently, the colors are solid and have no transparency and this gives me a strong limitation: If a shape is placed over another shape, t...

TaW
TaW
While color/alpha blending can be quite complex (to wit: look at the photoshop modes!) your case will be solvable for some cases : picking n pixels with different colors results in n equations and these can be solved if only n shapes are used and all combinations/overlapping are present. If two shapes are identical their colors cannnot be reconstructed.
I think I understand, but now I have another question. Is it then possible to check if the result color could be achieved by another given. For example I have a final color RGB(100,100,100), can I iterate over all color combinations (rgba(0,0,1,0.3), rgba(0,0,2,0.3), etc.) and check if it is possible to be part of the final solid color?
TaW
TaW
Lets simplify the issue by looking athe channels separately. If we assume a simplistic blending mode that simply adds all channels Even the 1st color can be anything as the two others will be able to get to 100. If the target values 255 otoh only one solution is possible. ((Aside: Do note that the GDI color blending is quite crappy and doesn't work that way and all those ideas will not be be possible to achieve with simple gdi drawing code!)
I see. So probably this approach would not be possible as I thought. Do you have then any other idea, on how can I then identify multiple shapes overlayed over each other? (this must happen when a user clicks anywhere in the image and I have to ask him which of all overlayed shapes he wants to select)
TaW
TaW
Where do the shapes come from? Do you draw themß Then you can easily remeber them and test which were hit..
14:53
Well, I generate them, and I also know every unique color that has been used. But when a bigger object is placed over a smaller one, I lose the smaller one and I only have the metadata for it in the database, but the user is not able access it.
TaW
TaW
Well, keep the coodinates/graphicspaths and test which contain the mouse point..
The problem is that the shape could have "holes" inside it and also could be large and complex shapes and saving such information would bring me performance/memory issues.
TaW
TaW
How exactly do you then draw them? - What are you targetting: Winforms, WPF, ASP..? YOU should always TAG your questions correctly so one can see it on the questions page!
Would you like to move the discussion in a chat, so I can give you a wider perspective of my problem?
TaW
TaW
Sure, go ahead..
14:59
Is this a private chat or can we make it private somehow, because I don't want to share the information with the whole world
That's the first chat I create in stackoverflow
15:19
Actually, I overthought my question and even if I found a fix to it, I would get a couple other problems. I think I will have to think of a completely new solution to code the shapes, without using colors overlay.
Thank you very much for the time you spent on my question, I really appreciate it!
 
1 hour later…
TaW
TaW
16:24
Dinner is over. don't know if we could open a private chat. In Winforms a GraphicsPath can be complex and include holes but I really can't advise without knowing a lot more.. Good luck!

last day (15 days later) »