POV-Ray : Newsgroups : povray.off-topic : Ooh. That's nice .. (GDI+ Feature) Server Time
6 Nov 2024 06:24:41 EST (-0500)
  Ooh. That's nice .. (GDI+ Feature) (Message 1 to 1 of 1)  
From: Mike Raiford
Subject: Ooh. That's nice .. (GDI+ Feature)
Date: 17 Jul 2008 10:27:13
Message: <487f56c1$1@news.povray.org>
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

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.