Re: STGAPIBuffer rotated to landscape? Possible? How?
- From: TJ <someone@xxxxxxxxxxxxx>
- Date: Thu, 29 Sep 2005 23:12:37 -0500
AFAIK there is no built in method to automatically rotate a bitmap for you built into GAPI. I don't use MFC but I'll tell you the approach I would take in pure code. Take the bitmap that needs to be rotated and copy it to a DIBSection then use the pointer to the raw bytes create a WORD array (76,800 items) and store all pixels as 16bit-565, rotating the picture -90 degrees as you go. Since bitmaps read from the bottom up the formula to get the pixels in the right spot would be (320-x)*240+(240-y). Then just copy the pixels to the screen buffer from the array.
MCM wrote:
I'm using STGapiBuffer on a PocketPC app. I've built things such that I can use MFC drawing functions to a memory DC (CBitmap-based) then use STGapiBuffer to throw it at the screen.
What I'm trying to do is tweak STGapiBuffer to rotate the bitmap for me as STGAPI is converting it to "native" format. I see that STGapiBuffer is getting at the bits, but it looks like the destination will need to be resized and the pixels need to be re-mapped to new locations.
Has anybody done this?
Currently, my display is 240x320 (as GAPI dictates). I'd like to make a 320x240 CBitmap and draw to it (which I can currently do) via a CDC. With that I need a modification to the "CreateNativeBitmap" and "CreateNativeBitmapFromBGRBits" functions that will rotate the bitmap from the standard orientation to the landscape orientation:
Transform the source bitmap (320x240) of:
-------------------------> (+x) | | (X0Y0) X1 X2 .... (Xn-1=319) | Y0 | Y1 | ... | (Yn-1=239) v (+y)
to the desired orientation (90 CCW) of (240x320):
(+x) ^ | (xn-1 = 319) | ... | x2 | x1 | (x0y0) y1 y2 ... (yn-1 = 239) | ------------------------> (+y)
In other words what needs to be changed in CreateNativeBitmap and CreateNativeBitmapFromBGRBits in order to rotate my HBITMAP 90deg counterclockwise?
Thanks!
.
- References:
- Prev by Date: Re: Newbie - how to remove forms from a project (Visual Studio 2003)
- Next by Date: problem on 'fread'
- Previous by thread: STGAPIBuffer rotated to landscape? Possible? How?
- Next by thread: Newbie - how to remove forms from a project (Visual Studio 2003)
- Index(es):
Relevant Pages
|
Loading