I need to copy the snapshot to the clipboard. How can I do that in Ogre? Is there any direct Ogre tool for that?
I get the snapshot using the following code:
Code: Select all
HWND Handle = GetHwnd();
int Width = GetWindow()->getWidth();
int Height = GetWindow()->getHeight();
Ogre::PixelBox * mRenderPixelBox = new Ogre::PixelBox(Width,Height,1,Ogre::PF_A8R8G8B8);
mRenderPixelBox->data = new BYTE[mRenderPixelBox->getConsecutiveSize()];
GetWindow()->copyContentsToMemory(*mRenderPixelBox, Ogre::RenderTarget::FB_AUTO);Code: Select all
OpenClipboard(Handle);
EmptyClipboard();
SetClipboardData(CF_BITMAP, mRenderPixelBox->data);
CloseClipboard(); I also tried this way:
Code: Select all
BYTE * mTempBufferForSave;
mTempBufferForSave = new BYTE[mRenderPixelBox->getConsecutiveSize()];
size_t biBitCount = Ogre::PixelUtil::getNumElemBits(mRenderPixelBox->format);
size_t rowLengthInBytes = biBitCount * lWidth / 8;
BYTE * data = static_cast<BYTE *>(mRenderPixelBox->data);
for(int i = 0 ; i < height - 1 ; i++ )
{
memcpy(&mTempBufferForSave[rowLengthInBytes * (height - i - 1)], &data[rowLengthInBytes * i], rowLengthInBytes);
}
BITMAPFILEHEADER* bmfh;
bmfh = (BITMAPFILEHEADER*)mTempBufferForSave;
BITMAPINFOHEADER* bmih;
bmih = (BITMAPINFOHEADER*)(mTempBufferForSave+ sizeof(BITMAPFILEHEADER));
BITMAPINFO* bmi;
bmi = (BITMAPINFO*)bmih;
void* bits;
bits = (void*)(mTempBufferForSave+ bmfh->bfOffBits);
HDC hdc = ::GetDC(NULL);
HBITMAP hbmp = CreateDIBitmap(hdc, bmih, CBM_INIT, bits, bmi, DIB_RGB_COLORS) ;
if(!hbmp) return;
OpenClipboard(lHandle);
EmptyClipboard();
SetClipboardData(CF_BITMAP, hbmp);
CloseClipboard();