Hello Mark,
Thank you for your response. You were right about the reading upside down, but that was because I was studying a BMP example.. And since BMP's are stored upside down, I forgot to reverse it for the DC...
I know that GetPixel/SetPixel is a slow operation, but frankly I don't really know how I could convert it to 24 bit otherwise... Uptill now, I have only written console applications, so using the DC is kinda new to me...
I now tried to do it like this:
Code: Select all
int pixelPos = 0;
UINT8 rColor, gColor, bColor;
for (int y=0; y<height; y++)
for (int x=0; x<width; x++)
{
pixelColor = pView->m_MemoryDC.GetPixel(x,y);
rColor = GetRValue((UINT8) pixelColor);
pixelData[pixelPos++] = rColor;
gColor = GetGValue((UINT8) pixelColor);
pixelData[pixelPos++] = gColor;
bColor = GetBValue((UINT8) pixelColor);
pixelData[pixelPos++] = bColor;
}
....
dataset->putAndInsertUint8Array(DCM_PixelData, pixelData, pixelDataLength24bit);
but this doesn't seem to work. In my watches I can see that the gColor and bColor always return 0 (grayscale image), so that's not correct... Also the "image" that I get doesn't really look like the original one, but this could also has to do with an miscalculation of the rows and columns of the DC. I have to further look into it.
But I'm not really seeing what I'm doing wrong...: Get the individual colors of the color value, put those in an uint8 array, and pass that array to the method with the length of that array...
And if you can find the time, could you then please tell me what in your opinion would be the most performant way to convert it to 24 bit and store in the pixel data array?
Thanks