# rotation and flipping the bitmap - Programmer

This is a discussion on rotation and flipping the bitmap - Programmer ; Hi, Can any one tell me how to rotate the bitmap using C++(but not MFC). Regards, swetha....

# Thread: rotation and flipping the bitmap

1. ## rotation and flipping the bitmap

Hi,

Can any one tell me how to rotate the bitmap using C++(but not MFC).

Regards,
swetha.

2. ## Re: rotation and flipping the bitmap

In article <36c03bb7-d097-4875-9d05-31f7e9a61420
> Hi,
>
> Can any one tell me how to rotate the bitmap using C++(but not MFC).

Vertical flipping can be done by inverting the coordinates you feed to
BitBlt. Other flips and/or rotations can be done by setting a world
transform.

--
Later,
Jerry.

The universe is a figment of its own imagination.

3. ## Re: rotation and flipping the bitmap

On Jan 23, 6:54*pm, Jerry Coffin wrote:
> In article <36c03bb7-d097-4875-9d05-31f7e9a61420
>
> > Hi,

>
> > *Can any one tell me how torotatethebitmapusing C++(but not MFC).

>
> Vertical flipping can be done by inverting the coordinates you feed to
> BitBlt. Other flips and/or rotations can be done by setting a world
> transform.
>
> --
> * * Later,
> * * Jerry.
>
> The universe is a figment of its own imagination.

If you dont mind can you tell me how to do rotation with any angle.
Or if you have any sample code can you send that one.

swetha.

4. ## Re: rotation and flipping the bitmap

In article <54cb8288-6d4b-4f30-ac37-b0f6f2caed63

[ ... ]

> If you dont mind can you tell me how to do rotation with any angle.
> Or if you have any sample code can you send that one.

First the standard utility routine to convert from degrees to radians:

return angle * 3.1416f / 180.0f;
}

Then, this goes into your OnDraw routine, where you'd normally start out
with a comment saying something about inserting code to draw your native
data or something like that:

// there will be code something like:
// CWhateverDoc* pDoc = GetDocument();
// ASSERT_VALID(pDoc);

HDC dc = pDC->GetSafeHdc();

XFORM xform;

xform.eDx = 0.0f;
xform.eDy = 0.0f;
xform.eM11 = cos(angle);
xform.eM12 = sin(angle);
xform.eM21 = -sin(angle);
xform.eM22 = cos(angle);

SetWorldTransform(dc, &xform);

pDC->TextOut(100, 0, "This is a string");

Of course, if you only wanted to print out text, you could just create a
font with the lfEscapement set to the correct angle -- but this also
rotates other output as well, such as anything you do with BitBlt,
StretchBlt, Rectangle, etc.

--
Later,
Jerry.

The universe is a figment of its own imagination.