c++ - 从 unsigned char*(freeimage) 创建 fipImage*?

标签 c++ opengl freeimage

unsigned char * image_data;
int bytes; // size

format:
RGBA , UNSIGNED_BYTE.
(opengl-glGetTexImage()):

如何从该数据创建 fipImage*?

C++。


unsigned char * image_data;
int w = 1000;
int h = 1000;

该函数写入image_data

glGetTexImage(GL_TEXTURE_2D, 0 , GL_RGBA , GL_UNSIGNED_BYTE , image_data);

我想从 image_data 创建 fipImage

fipImage image;
something like this
image.load(image_data ,w , h);

最佳答案

您可以通过以下方式从原始像素创建 FreeImage 对象:

FIBITMAP* Bitmap = FreeImage_Allocate( Width, Height, BitsPP, 0, 0, 0 );

memcpy( FreeImage_GetBits( Bitmap ), image_data, Width * Height * ( BitsPP / 8 ) );

关于c++ - 从 unsigned char*(freeimage) 创建 fipImage*?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15289473/

相关文章:

c++ - 在 VC++ 中使用非英文字符作为函数/变量名称?

c++ - 未定义对 `__imp___glutInitWithExit' 等的引用,但库已链接

c++ - 避免等待 SwapBuffers

使用 FreeImage 时 Android NDK 链接器错误 'Undefined reference to std::ios_base'

c# - FreeImage.LoadFromStream 对 CR2 文件失败

c++ - 将派生类分配给基类

c++ - 无法从decltype中获取指向成员函数的指针

c++ - SetWindowsHookEx WH_MOUSE_LL Hook 只需要 1 次鼠标移动

c++ - gluUnProject 试图将鼠标坐标转换为 opengl 坐标的奇怪行为

c++ - 从位图加载纹理