PDA

View Full Version : rotating a bitmap



mphanke
06-14-2002, 01:52 AM
Hi,

I know it is little offtopic but not really. I have to implement a livepic in my OpenGL app. But the camera gives me a 320x240 bmp. I need to turn it 90 to get a 240x320 rect. What is the fastest way to do it to keep it in real time?

This is what I have:



tagBITMAPFILEHEADER *bfh = (tagBITMAPFILEHEADER*) pBuf;
tagBITMAPINFOHEADER *bih = (tagBITMAPINFOHEADER*)((LPBYTE)pBuf + sizeof(tagBITMAPFILEHEADER));
LPBYTE pPixels = (LPBYTE)pBuf + bfh->bfOffBits;

CanonClass *lthis = (CanonClass*)Context;

if( Format == 1 )
{
//Need to rotate somewhere in here! memcpy( (lthis->m_BMP.vpBits) , pPixels, bih->biSizeImage);

DCDst = GetDC(lthis->m_pViewFinder);
DCSrc = CreateCompatibleDC(DCDst);
SelectObject(DCSrc, (lthis->m_BMP.hBmp));
BitBlt(DCDst, 8, 8, 320, 240, DCSrc, 8, 8, SRCCOPY);
DeleteDC(DCSrc);
ReleaseDC( lthis->m_pViewFinder, DCDst );
}

Phobeus
06-14-2002, 03:14 AM
I am new also, but...

why not putting everything on a quad and simply change the uv coords of the texture, so that it is in the right position.

Robbo
06-14-2002, 04:12 AM
The above method is the fastest way of doing it (actually, you are not rotating it at all). The other way to do it would be to scan along the X of the source image, putting the pixels along the Y in the destination image.

Easy!