DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
start date: Thu, 16 Aug 2007 16:36:25 +0100,    posted on: microsoft.public.dotnet.framework.compactframework        back       

Thread Index
  1    Peter Morris


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:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us