BMP.GetPixel is incorrect
Hi all
I have given up on printing a PCX image, instead I need to convert a BMP
into an ASCII HEX string. So I signed my name, saves as a monochrome BMP
and dropped it onto my PPC. I know this image is valid because I can drop a
picturebox onto my form and then
do this
Bitmap bmp = new Bitmap("/SDMMC Disk/MySignature.bmp");
pictureBox1.Image = bmp;
and the image appears. However, when I execute the following code the pixel
always comes out as
A=255
B=248
G=252
R=248
this is the value returned for every pixel, which is obviously wrong because
I can clearly see my signature in the PictureBox. Can anyone tell me what I
am doing wrong?
Thanks
Pete
StringBuilder result = new StringBuilder();
Bitmap bmp = new Bitmap("/SDMMC Disk/MySignature.bmp");
using (bmp)
{
result.Append(string.Format("EG {0} {1} {2} {3} ", bmp.Width,
bmp.Height, xPosition, yPosition));
for (int y = 0; y < bmp.Height; y++)
for (int x = 0; x < bmp.Width; x++)
{
Color color = bmp.GetPixel(x, y);
int intensity = (color.R + color.G + color.B) / 3;
result.Append(intensity.ToString("X2"));
}
}
result.Append("\r\n");
return result.ToString();
Date:Thu, 16 Aug 2007 16:36:25 +0100
Author:
|