views:

369

answers:

1

I'm writing an interpreter in managed C++ for, among other things, the PPM image format. The image spec allows for images with up to two bytes per pixel per channel, or 48 bit per pixel color images. I'm attempting to read this format and convert it to a .Net bitmap, but im having trouble getting it working. When I have 24 bit per pixel images, I initialize them like so:

bmp = gcnew Bitmap(width, height);
<for each pixel>
    bmp->SetPixel(x, y, Drawing::Color::FromArgb(Convert::ToInt32(fileData[offset]),
        Convert::ToInt32(fileData[offset + 1]), 
            Convert::ToInt32(fileData[offset + 2])));
    offset += 3;

For 48 bit per pixel images, I initialized the bmp as follows:

bmp = gcnew Bitmap(widht, height, Imaging::PixelFormat::Format48bppRgb);

However, when attempting to fill in the pixel data, I am unable to specify any color values using 'Color::FromArgb()' with values greater than 255 for R, G, and B. Is there any way to get around this limitation?

A: 

System.Drawing can handle 48 and 64bit image file formats, but it converts the pixel values to 24bit. I know of no way of preserving the full color fidelity.

See the Remarks section of: PixelFormat Enumeration

jlew