|
-
November 20th, 2019, 06:24 AM
#1
Convert custom bitmap to CBitmap/CImage bits format
I got an custom bitmap format, serialized (read) into file, just like that:
Code:
std::ifstream file(filename, std::ios::binary);
int Height, Width;
file >> Width >> Height;
float scale;
file >> scale;
scale = fabs(scale);
for (int h = 0; h < Height; ++h)
{
for (int w = 0; w < Width; ++w)
{
for (int c = 0; c < C; ++c)
{
float x;
file.read((char*)&x, sizeof(float));
image[((Height - 1 - h) * Width + w) * C + c] = x * scale;
}
}
}
where image is an object that has as constructor CImage(int width, int height, int channels).
Now, I should load this data into a CImage (or CBitmap) MFC object in order to display it. And I know that CImage has CImage::SetPixel method: https://docs.microsoft.com/en-us/cpp...-2019#setpixel, but I don't know how to use it in this case ...
Can you help me to setup CImage pixels to have that custom data valid into CImage object ? I had take a look over CImage::GetBits and CImage::GetPitch methods to see how to arrange data into CImage, but I didn't get it ... (just order way, and data range).
Tags for this Thread
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
|