Code: Select all
m_VideoTexture->m_PixelBuffer->lock(Ogre::HardwareBuffer::HBL_DISCARD);
memcpy(m_VideoTexture->m_PixelBuffer->getCurrentLock().data, lpbi + lpbi->biSize + 25, lpbi->biSizeImage);
m_VideoTexture->m_PixelBuffer->unlock();
Code: Select all
m_VideoTexture->m_PixelBuffer->lock(Ogre::HardwareBuffer::HBL_DISCARD);
memcpy(m_VideoTexture->m_PixelBuffer->getCurrentLock().data, lpbi + lpbi->biSize + 25, lpbi->biSizeImage);
m_VideoTexture->m_PixelBuffer->unlock();
I put the image data manually to the pixelbox, but the texture rendered is green, here is my code:paroj wrote:first describe your data with Ogre::PixelBox and then upload it using HardwarePixelBuffer::blitFromMemory
Code: Select all
System.Drawing.Bitmap bitmap = videotexMgr.Stream.GetBitmap(videotexMgr.FrameNum);
MemoryStream ms = new MemoryStream();
bitmap.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp);
byte[] bitmapBuffer = new byte[ms.Length];
ms.Seek(0, SeekOrigin.Begin);
ms.Read(bitmapBuffer, 0, bitmapBuffer.Length);
ms.Close();
videotexMgr.PixelBuffer.Lock(HardwareBuffer.LockOptions.HBL_DISCARD);
Marshal.Copy(bitmapBuffer, 0, videotexMgr.PixelBuffer.CurrentLock.data, bitmapBuffer.Length);
videotexMgr.PixelBuffer.Unlock();
Code: Select all
System.Drawing.Bitmap bitmap = videotex.Stream.GetBitmap(videotex.FrameNum);
bitmap.Save("./Media/materials/textures/xx.png");
Image image = new Image();
image.Load("xx.png", "General");
image.FlipAroundX();
videotexMgr.PixelBuffer.BlitFromMemory(image.GetPixelBox());
image.Dispose();
videotexMgr.FrameNum++;