Convert floating point RGBA bitmap to standard Dotnet Bitmap

北慕城南 提交于 2019-12-11 10:33:21

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!