PDA

View Full Version : colors composition



elcuco
11th November 2007, 23:04
I am trying to find a way to composite colors off screen, using Qt4 API. My code just needs to paint a solid rectangle, with on 1 color. The problem is that the color will be computed according to different parameters, and I would prefer to computer the color off screen and then painting it once on screen. instead of using Qt4 API and painting the same place several times.

Besides computing the color "manually", what are my options?

wysota
12th November 2007, 00:58
What do you need to assemble the color from? Do you mean blending? Due to the use of a backing store by Qt, it might be quicker to use Qt API. Otherwise I'd suggest using OpenGL and/or shaders on the graphics card if you can support it.

elcuco
12th November 2007, 18:46
Hi wysota,

Basically, I have to draw a box using a simple QPainter. The color of the box will be determintaed by several factors.

What API does Qt4 supplied for color blending, *before* it reaches the QPainter (no need to paint 5 times a 500x10 rectangle if it can be painted once).

wysota
12th November 2007, 19:24
It will be painted only once. First four passes will go through the backing store where the final colour is computed and rendered to the framebuffer. So you might say that all compositions are performed offscreen (unless the paint engine doesn't use the backing store). At worst render to QImage (which uses BS) and then render the final image to the final destination.

elcuco
12th November 2007, 19:45
nah... that's lame. sorry, at worst case scenarion I will compute the colors once "manually", but this if really a "too lame way" to acomplish it.

What if I need to use that color for CSS styles on a button-box or something...?

wysota
12th November 2007, 21:51
Sorry, I don't understand your problem, so I can't help you... If you want to compute the colour manually, there are mathematical equasions for that - I think they are even present in composition modes docs in Qt reference, you can take a look at them.