问题
I'm trying to use the FreeImage.Net library to open the image and convert it to a standard bitmap, but either there must be a step I'm missing, or FreeImage simply can not convert floating point RGBA to 32BPP RGBA:
FreeImageBitmap fib = new FreeImageBitmap("C:\\test.exr");
Console.WriteLine(fib.ImageType); //FIT_RGBAF
fib.ConvertType(FREE_IMAGE_TYPE.FIT_BITMAP, true); //returns False
Conversion fails:
Can not convert from type 12 to type 1; No such conversion exists.
I need this as a 32BPP RGBA Bitmap solely for the purpose of being able to convert it into a System.Drawing.Bitmap
, so I may draw it using GDI+. I'm willing to use a different image library if necessary, or to consider WPF over Winforms if anyone thinks a solution will be found there.
I've uploaded an example floating point EXR for testing: http://dl.dropbox.com/u/2817180/test.exr
回答1:
AS Niko said, you should do it manually. Using unsafe code, and pointers that would PIN your memory buffers and make it unmovable, your routine will be both fast in execution and easy to write.
More so if you are having just one source and one target format.
来源:https://stackoverflow.com/questions/8694739/convert-floating-point-rgba-bitmap-to-standard-dotnet-bitmap