Hi all,

Is there a way to rotate a bitmap 180 degrees or do i need to load two resources? I have attached the picture of my bitmap. Thanks anyway
Posted on 2002-09-26 03:24:11 by roticv
rotating 180 degree seems to mean with this bitmap a vertical mirroring,
so you can use the BitBlt operation with a negative height. This will create the vertical mirror.
Posted on 2002-09-26 03:54:36 by beaster

copying your bitmap in a DIB makes it possible to rotate bitmaps in any angle.
DIB's give you the possibility to get the datas of your bitmap as byte-array.

Posted on 2002-09-26 07:19:48 by Sm?rebr?d

I just tried your method beaster, and it seem to unable to work. I would give a thought to Sm?rebr?d's idea. Thanks anyway.
Posted on 2002-09-26 07:37:02 by roticv
You can saqve some hassle if you have NT

The SetWorldTransform function sets a two-dimensional linear transformation between world space and page space for the specified device context. This transformation can be used to scale, rotate, shear, or translate graphics output.

BOOL SetWorldTransform(

HDC hdc, // handle of device context
CONST XFORM *lpXform // address of transformation data



Identifies the device context.


Points to an XFORM structure that contains the transformation data.

Must have windows NT. Don't know about newer systems. I'm on 98se which does not support this api call.
Posted on 2002-09-26 10:56:38 by IwasTitan

I found an api for it too bad it only works for Winnt. It is PlgBit. Bias microsoft ;)
Posted on 2002-09-27 06:55:40 by roticv
Hi roticv,

you could try the low level thing:

1) Set a buffer;

2) Copy your image there;

3) Now copy it back starting from the last address, that is, use something like:

mov edi,[Target_buffer]
mov esi,[Copy_buffer]
mov ecx,[count]
repe movsw

Or whatever optimization suit you best.

Hope it helps.
Posted on 2002-09-27 11:02:52 by slop
Afternoon, roticv.

Best way would be to chuck the bitmap into a DIB, then mirror it horizontally then vertically, to get a true 180 degree rotation.

Posted on 2002-09-27 17:13:00 by Scronty
Here is a code to rotate a DIB byte-array.
ebx = Pointer to array
edx = Pointer to last byte in byte-array - 2
edi = Lenght of array / 2


mov al,[ebx]
mov cl,[edx-2]
mov [ebx],cl
mov [edx-2],al

mov al,[ebx+1]
mov cl,[edx-1]
mov [ebx+1],cl
mov [edx-1],al

mov al,[ebx+2]
mov cl,[edx]
mov [ebx+2],cl
mov [edx],al

lea ebx,[ebx+3]
lea edx,[edx-3]
lea edi,[edi-3]
cmp edi,0
jg dumxixloop

Posted on 2002-09-28 06:09:43 by Sm?rebr?d

I fixed it

Just use StretchBlt, using negative height and you get a mirror image.
Thanks anyway,Sm?rebr?d
Posted on 2002-09-28 06:14:42 by roticv