Saturday, August 15, 2009

Drawing an image with Alpha in .NET

This is how it is done: How to: Use a Color Matrix to Set Alpha Values in Images. There is an error on that post: it mentions DrawString in one place instead of DrawImage.

The key is to use one of the overloads of DrawImage which takes an ImageAttributes object as a parameter.

One thing I don't understand is that the following call fails if srcUnit is specified to be GraphicsUnit::Display.

g->DrawImage(image, imgDest, srcRect,
          GraphicsUnit::Pixel, imgAttr);

No comments:

About Me

My photo
C/C++ Programmer doing CAD on Windows. Some web development experience. Bangalorean.

Blog Archive