Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > .NET General

Vista - hi, how to read bits from CImage class

Reply
 
Old 06-07-2008   #1 (permalink)
Baby Lion


 
 

hi, how to read bits from CImage class

I use the getbits like this ,but when I read half of the image ,the
error occur, could you tell me why this happen , and do I need to lock
the memory of CImage.GetBits() before I use it,

thanks


w = image.GetWidth();
h = image.GetHeight();
int nClrCount = image.GetBPP()/8;
BYTE * pImageData = (BYTE *)image.GetBits(); ///??? do I need to lock
it ? and how to lock it?
int Pitch = image.GetPitch();

if( nClrCount == 3)
{

for( int y = 0; y<h ; y++)
{
for( int x = 0 ;x<w; x++)
{
WORD hue,luminance,saturation;
BYTE bRed,bGreen,bBlue;
BYTE * p = pImageData + (y*w+x)*3; //////?????right?
/// the runtime error
happened here!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
bRed = *p;
bGreen = *(p+1);
bBlue = * (p+2);
COLORREF color = RGB(bRed, bGreen, bBlue);
ColorRGBToHLS(color,&hue,&luminance,&saturation);
if( luminance > 240)
{
cout<<"ERROR: luminance>240"<<endl;
throw exception();
}
if( Pitch < 0 )
{
PgmM[h-y-1][x] = luminance /240.0;
}else{
PgmM[y][x] = luminance / 240.0;
}

}
}


}

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
When a class is both an inherited class of another, and alsoimplements an interface method .NET General
Need help in 32 bits to 64 bits switching... General Discussion
Vista 32 bits to Vista 64 bits without loosing apps. Vista installation & setup
Internet Explorer 7 (32-bits) keeps on freezing wile the 64-bits works OK in Vista 64 Vista General
Why does x86 mean 64 bits while x32 means 32 bits? Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46