I am creating screenshots under Windows and using the LockBits
function from GDI+ to extract the pixel data, which will then be written to a file.
To maximise performance I am also:
- Using the same
PixelFormat
as the source bitmap, to avoid format conversion - Using the
ImageLockModeUserInputBuf
flag to extract the pixel data into a pre-allocated buffer - This pre-allocated buffer (pointed to by
BitmapData::Scan0
) is part of a memory-mapped file (to avoid copying the pixel data again.)
I will also be writing the code that reads the file, so I can use (or invent) any format I wish. However I would prefer to use a well-known format that existing programs (ideally web browsers) are able to read, because that means I can visually confirm that the images are correct before writing the code for the other program (that reads the image.)
I have implemented this successfully for the PixelFormat32bppRGB
format, which matches the format of a 32bpp BMP file, so if I extract the pixel data directly into the memory-mapped BMP file and prefix it with a BMP header I get a valid BMP image file that can be opened in Paint and most browsers.
Unfortunately one of the machines I am testing on returns pixels in PixelFormat64bppPARGB
format (presumably this is influenced by the video adapter driver) and there is no corresponding BMP pixel format for this.
Converting to a 16, 24 or 32bpp BMP format slows the program down considerably (as well as being lossy) so I am looking for a file format that can use this pixel format without conversion, so I can extract directly into the memory-mapped file as I have done with the 32bpp format.
What raster image file formats support 48bpp (BGR order, little-endian) and/or 64bpp (BGRA order, little-endian)?
Edit
I have ruled out these formats so far:
- BMP: Depth limited to <=32bpp (would be a perfect match otherwise.)
- PNG: Sample order can only be RGBA.
- TIFF: Sample order can only be RGBA.
Possible partial solutions:
- OpenEXR: 48bpp only. Sample order is alphabetical by channel name; BGR fits but BGRA does not.