|
![](/i/fill.gif) |
So,
I'm working on a project that just got greenlighted - basically a means
of making a more intuitive interface to an existing piece of equipment.
Giving the main display more screen space and reducing the dizzying
array of toolbars and buttons are a must. I wanted to create a nice
overlay over the main display, drawing controls as partially transparent
(or in cases where the equipment will be in direct sunlight opaque)
That parenthesized statement above meant the images should already be
opaque. Which meant I needed a way to adjust the alpha value of the
image as a whole. I could go through each individual pixel and set an
alpha value, but that's slow. .NET does have some features to treat a
block of memory as a block of memory, but to get the buffer to draw, I
would have to lock and unlock the buffer, which also eats time. I could
dig through API's to see if there's a way to directly alter the screen
buffer. There is, but I don't want to mess with it.
So, I dig around the .NET framework a bit .. Ahh, when drawing an image
via .NET's GDI+ wrappers, I found the perfect thing, and ImageAttributes
class that has among other things a ColorMatrix. Simply apply the matrix
as I'm drawing, and BAM! I can scale any channel (including alpha) to my
liking.
I love it when things like that just come together!
FWIW, the color matrix is a 5x5 matrix. Rows and columns are in RGBAn
order. Where n is the usual extra factor used for nonlinear
transformations.
Post a reply to this message
|
![](/i/fill.gif) |