B
bern11
I have a linked-list of bitmaps drawn on a window - no problem. I want
to convert one of them to Black & White - problem! It just doesn't do
it. I dumbed the routine down to implementing the 'Lockbit' example
code, and no effect. Now, if I call bimap.FlipRotate() first, I can get
it to FlipRotate and go grayscale. the following is the lead-in code:
private void convertToGrayScaleToolStripMenuItem_Click(object
sender, EventArgs e)
{
//ActiveElement.bitmap.RotateFlip(RotateFlipType.Rotate90FlipXY);
// Lock the bitmap's bits.
Rectangle rect = new Rectangle(0, 0,
ActiveElement.bitmap.Width, ActiveElement.bitmap.Height);
BitmapData bmpData =
ActiveElement.bitmap.LockBits(rect,
ImageLockMode.ReadWrite,
PixelFormat.Format32bppArgb);
// Get the address of the first line.
IntPtr ptr = bmpData.Scan0;
int bytes = ActiveElement.bitmap.Width *
ActiveElement.bitmap.Height * 4;
byte[] rgbValues = new byte[bytes];
// Copy the RGB values into the array.
System.Runtime.InteropServices.Marshal.Copy(ptr, rgbValues,
0, bytes);
.... If I un-comment the FlipRotate statement, the function works and I
get a grayscale image (That has been flipped & rotated). If I don't
FlipRotate, no grayscale.
to convert one of them to Black & White - problem! It just doesn't do
it. I dumbed the routine down to implementing the 'Lockbit' example
code, and no effect. Now, if I call bimap.FlipRotate() first, I can get
it to FlipRotate and go grayscale. the following is the lead-in code:
private void convertToGrayScaleToolStripMenuItem_Click(object
sender, EventArgs e)
{
//ActiveElement.bitmap.RotateFlip(RotateFlipType.Rotate90FlipXY);
// Lock the bitmap's bits.
Rectangle rect = new Rectangle(0, 0,
ActiveElement.bitmap.Width, ActiveElement.bitmap.Height);
BitmapData bmpData =
ActiveElement.bitmap.LockBits(rect,
ImageLockMode.ReadWrite,
PixelFormat.Format32bppArgb);
// Get the address of the first line.
IntPtr ptr = bmpData.Scan0;
int bytes = ActiveElement.bitmap.Width *
ActiveElement.bitmap.Height * 4;
byte[] rgbValues = new byte[bytes];
// Copy the RGB values into the array.
System.Runtime.InteropServices.Marshal.Copy(ptr, rgbValues,
0, bytes);
.... If I un-comment the FlipRotate statement, the function works and I
get a grayscale image (That has been flipped & rotated). If I don't
FlipRotate, no grayscale.