纹理图像保存为黑色 - Android

时间:2016-12-15 09:32:33

标签: android textures opengl-es-2.0 ogre freeimage

我正在使用此代码将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);

0 个答案:

没有答案