我正在使用此代码将texture
保存到bmp
文件
我在Windows和android
平台上运行此代码
在Windows上它应该是工作得很好,但在android上我得到的所有图像都是黑色的,这在Windows中很奇怪,我得到了真实的图像(当然不是黑色)。
保存操作本身使用FreeImage
库
有什么我想念的吗?
我在这里很丢失。
感谢帮助。
Ogre::HardwarePixelBufferSharedPtr pSrcBuffer = pTexture->GetBuffer();
Ogre::HardwarePixelBufferSharedPtr pDstBuffer = m_Texture->getBuffer(0, 0);
Ogre::PixelFormat ePixelFormat = m_Texture->getFormat();
size_t uPixelSizeInBytes = Ogre::PixelUtil::getNumElemBytes(ePixelFormat);
static int cnt = 0;
size_t uTextureWidthInPixels = pTexture->GetWidth();
size_t uTextureHeightInPixels = pTexture->GetHeight();
size_t uTextureSizeInBytes = uTextureWidthInPixels * uTextureHeightInPixels * uPixelSizeInBytes;
cnt++;
unsigned char* pTextureBuffer = static_cast<unsigned char*>((pTexture->GetBuffer())->lock(Ogre::HardwareBuffer::HBL_NORMAL));
Ogre::DataStreamPtr memStream(OGRE_NEW Ogre::MemoryDataStream(pTextureBuffer, uTextureSizeInBytes, false));
(pTexture->GetBuffer())->unlock();
Ogre::Image img;
img.loadRawData(memStream, uTextureWidthInPixels, uTextureHeightInPixels, ePixelFormat);
std::ostringstream filename;
#ifdef WIN32 || _WIN64
filename << "C:\\tex\\orgSrcTex_" << cnt << ".bmp";
#endif
#ifdef ANDROID
filename << "//sdcard//tex//orgSrcTex_" << cnt << ".bmp";
#endif
std::string var = filename.str();
img.save(var);