473,385 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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;
}

}
}
}
Jun 27 '08 #1
0 994

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: James Dean | last post by:
Could anybody tell me the most efficient way to set the bits in a 1Bpp class. I am reading in byte lines of an image. The byte array tells me what what bits are turned on or off.....i do bit...
0
by: Howie (remove _) | last post by:
Hi, i want to resize a image to create a texture to use with OpenGL. OpenGL needs a size of pover^2. This is my first try: CImage texture1; HRESULT hResult =...
0
by: prakash | last post by:
Dear Friends I am new guy to Visual C++.NET I've program to save website as a image vc++.net . It have a function "SaveSnapshot" to save the webpage as an image On that function ifor saving...
17
by: henrytcy | last post by:
Hi, How can I get a digit from integer for example, 12311, one by one for comparision? Thanks!
12
by: Frederick Gotham | last post by:
Over on comp.lang.c, Hallvard B Furuseth devised a compile-time constant representing the amount of value representation bits in an unsigned integer type. In true C fashion, here it is as a macro:...
0
by: lovecarole | last post by:
hi, i am the student who should write a program about reading wav file and do the DFT. actually i don't know how to read data of the wav song and save it into the array... if i want to read...
2
by: duylam76 | last post by:
I'm programming a server and corresponding client application that sends data to each other over a socket. I want to encode an integer to send over the socket. Right now everything is fine because...
9
by: Matrixinline | last post by:
Hi All, Here is the problem char* memblock; std::ifstream file(sFileName, ios::in|ios::binary); if (file.is_open()) { size = file.tellg();
1
by: tom thomas | last post by:
Dear sir, i am very new to c# and i request you to... please look into the problem The following is the code(please see the code below:) which i uses to open the binary file,currently it works...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.