getting access to actual pixels in hbitmap object returned by GetHBitmap() using c#
Posted on 2004-11-12
I am programming in c#.
I need to change the alpha value of every pixel in a Bitmap.
I did this:
for(row = 1; row < myBitmap.Size.Height; row++)
for(col = 1; col < myBitmap.Size.Width; col++)
Color aColor = myBitmap.GetPixel(col, row);
aColor = Color.FromArgb(alpha, aColor);
myBitmap.SetPixel(col, row, aColor);
which works but it is too slow. i want to access the actual pixels via the bmBits pointer in the HBitmap returned from myBitmap.GetHbitmap() but I do not know how to do this. Can you show me how to at least get a bmBits pointer that I can increment over the range of the bitmap? I can figure out the rest.