|
-
June 10th, 2010, 02:30 PM
#6
Re: Reading image into char array
 Originally Posted by loolyn
Hi All.
I need to read an image to char array with C++. I have written the following code for it, but it seems that the code does not read the entire image, it just reads the part of it. Can someone hint why, or give some better solution for how to read an image into char array?
std::fstream image;
image.open("C:\\bbb.bmp");
image.seekg (0, ios::end);
int n = image.tellg();
image.seekg (0, ios::beg);
char* res = new char[n];
image.read(res, n);
Thanks behorehand.
Use unsigned char if you're reading in full bytes.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|