1

I'm using this code to save a texture to bmp file.
I ran this code on both windows and android platforms.
On windows it's work good as should be, but on android I get all the images black, which is weird bc in windows I got the real images (not black of course).
The saving action itself is using FreeImage library.
is there anything I'm missing?
I'm pretty lost here.
thanks for help.

     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);
arii
  • 143
  • 2
  • 12

0 Answers0