简体   繁体   English

使用FreeImage是否可以在ARGB32或RGBA32中而不是BGRA32中具有ConvertToRawBits输出?

[英]With FreeImage is it possible to have ConvertToRawBits output in ARGB32 or RGBA32 rather than BGRA32?

I'm loading in a PNG to use as a texture in Unity. 我正在加载一个PNG以用作Unity中的纹理。 When I use ConvertToRawBits() it outputs to BGRA32. 当我使用ConvertToRawBits()时,它输出到BGRA32。 Is it possible to output to ARGB32 or RGBA32 instead? 是否可以改为输出到ARGB32或RGBA32?

https://gist.github.com/ciwolsey/24635ea523b4a6b758783688be53bf86 https://gist.github.com/ciwolsey/24635ea523b4a6b758783688be53bf86

You have two options for this, you can: 为此,您有两种选择:

  1. Recompile Freeimage with FREEIMAGE_COLORORDER set to FREEIMAGE_COLORORDER_RGB value (1). FREEIMAGE_COLORORDER设置为FREEIMAGE_COLORORDER_RGB值(1) FREEIMAGE_COLORORDER_RGB编译Freeimage Then your loaded images will be always in RGBA32 format. 这样,您加载的图像将始终为RGBA32格式。 If this FREEIMAGE_COLORORDER is not specified at compile time, the actual color order setting is determined from the target system's endianess. 如果在编译时未指定此FREEIMAGE_COLORORDER ,则根据目标系统的字节序确定实际的颜色顺序设置。

  2. Use Freeimage SwapRedBlue32 function to convert loaded image from BGRA32 to RGBA32 format. 使用Freeimage SwapRedBlue32函数将加载的图像从BGRA32转换为RGBA32格式。

Here is a nice discussion on this subject. 是关于这个主题的精彩讨论。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM