Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Trying to rotate a bitmap

671 views
Skip to first unread message

Andy Ellis

unread,
Aug 25, 2004, 11:04:05 AM8/25/04
to
Hi, folks. I'm a huge beginner with the WinAPI, but a bit more
experienced with VB.

I have a problem to solve for the app I'm working on right now. There
are a number of real-world objects which are created and manipulated
by the user, and each has an associated image (.bmp, .gif or .jpg),
which is uploaded by the user who creates the object. The different
objects each have a sub-object containing the image - I've called the
class Bitmap. (When the Bitmap object is first referenced, it loads
the image from file, using LoadPicture, into an IPictureDisp).

OK - I need to provide a way for the images to be rotated when
displayed (the app has to manipulate their orientation).

I found some code on the web, which I thought was going to show me how
to do it. The url is
http://www.ur.co.nz/static/default_typeid_3_dataid_372.htm

I downloaded the demo code, but found that it doesn't display the
image correctly. Once I get that sorted out, I may be able to
integrate it into my app.

If anyone has tried to use this code, what did you do to fix it? (I'm
using VB6+SP5 on Win2KPro.)

Andy Ellis


Mike D Sutton

unread,
Aug 25, 2004, 11:44:04 AM8/25/04
to

The code works fine here as-is however will only work with 8-bit images since it only writes one byte per pixel. You could modify
it to write the additional bytes per pixel to work with higher bit-depths if you don't mind getting your hands dirty playing
directly with the Bitmap data.
Your other options are to have a look at world transformation matrices or the PlgBlt() API call (the latter probably requiring the
least code), however both require NT-based OS' so Win9x/Me won't be supported if this is a problem.
If you need help on any of the above methods then post back here and we'll see if we can assist you further.
Hope this helps,

Mike


- Microsoft Visual Basic MVP -
E-Mail: ED...@mvps.org
WWW: Http://www.mvps.org/EDais/


alpine

unread,
Aug 25, 2004, 12:06:51 PM8/25/04
to


How is your image not being displayed correctly using the example
code? Are you sure you have implemented the code just as it is
implemented in the example?

HTH,
Bryan
____________________________________________________________
New Vision Software "When the going gets weird,"
Bryan Stafford "the weird turn pro."
alpine_don'tsen...@mvps.org Hunter S. Thompson -
Microsoft MVP-Visual Basic Fear and Loathing in LasVegas

Andy Ellis

unread,
Aug 25, 2004, 1:22:47 PM8/25/04
to
Brian,

"alpine" <alpine_don'tsen...@mvps.org> wrote in message
news:bidpi0pt35cc9kupu...@4ax.com...

> How is your image not being displayed correctly using the example
> code? Are you sure you have implemented the code just as it is
> implemented in the example?

I downloaded the project's ZIP file, extracted it to a new folder and
ran the .VBP from there. I haven't made any changes to it whatsoever.
The image shown in the demo is grossly distorted (but identical at
each degree of rotation), compared to the original, which of course I
can see directly by various means, including opening it (the sample
image provided is a .GIF file) in something like PaintShop Pro.

I could get a screen capture - but I don't think I can post it here,
can I? Alternatively I could send it to you directly - is the
underscore part of your address?

Regards
Andy Ellis

alpine

unread,
Aug 25, 2004, 2:11:18 PM8/25/04
to


Ahhh. Sounds like a buggy example. ;-)

Have you tried a google search for other examples of rotating a bitmap
in VB? I would be willing to bet there are examples out there that
work correctly. http://groups.google.com/advanced_group_search

If all else fails, you could get a copy of Rod Stephens' Visual Basic
Graphics Programming. When it comes to doing graphics in VB, it
contains pretty much everything you need to know.

Mike D Sutton

unread,
Aug 25, 2004, 2:47:53 PM8/25/04
to
Hi Bryan,

> Ahhh. Sounds like a buggy example. ;-)

The example worked fine here 'out of the box', however depending on your display settings it could be a DWord alignment issue in the
DIB data buffer if you're running at 24-bit. I've not looked at the code in detail but recall this happening on another of the
demo's from the site downloaded a while back.

> Have you tried a google search for other examples of rotating a bitmap
> in VB? I would be willing to bet there are examples out there that
> work correctly. http://groups.google.com/advanced_group_search
>
> If all else fails, you could get a copy of Rod Stephens' Visual Basic
> Graphics Programming. When it comes to doing graphics in VB, it
> contains pretty much everything you need to know.

To be honest I found the book a little thin in areas and IIRC the rotation example in the book was pretty inefficient compared with
the UR version mentioned by the OP.. IMHO you're better off hunting around online for code unless performance really is of no
concern.

alpine

unread,
Aug 25, 2004, 6:15:00 PM8/25/04
to
On Wed, 25 Aug 2004 19:47:53 +0100, "Mike D Sutton" <ED...@mvps.org>
wrote:

>> If all else fails, you could get a copy of Rod Stephens' Visual Basic
>> Graphics Programming. When it comes to doing graphics in VB, it
>> contains pretty much everything you need to know.
>
>To be honest I found the book a little thin in areas

Well, of course, *you* would. ;-)

My first inclination was to send him to your site, but I don't see
where you have any bitmap rotation code posted at present.

Andy Ellis

unread,
Aug 25, 2004, 6:43:02 PM8/25/04
to
Bryan,

> My first inclination was to send him to your site, but I don't see
> where you have any bitmap rotation code posted at present.

As a matter of fact, I visited 'his' site earlier today, and in fact
downloaded the PDF file, 'Using Device Contexts in Visual Basic', for
bedtime reading. I think the transformations idea would be the way to
go, but I am somewhat constrained by non-NT users.

Mike D said...


> IMHO you're better off hunting around online for code unless
performance really is of no
> concern.

Well, performance IS an issue for me. The various objects' bitmaps
will be used in real time, rather like rotary knobs or dials. If the
mouse is moved around the centre of one of these bitmaps with the left
button down, the bitmap should rotate (in real time), and a control
variable's value will follow its position. That won't work well if
the algorithm used is a bit sluggish.

Regards
Andy Ellis


Mike D Sutton

unread,
Aug 25, 2004, 7:18:46 PM8/25/04
to
> Well, of course, *you* would. ;-)

*g* Just offering my opinion :)

> My first inclination was to send him to your site, but I don't see
> where you have any bitmap rotation code posted at present.

Here's a quick example of how to use PlgBlt() to draw a rotated Bitmap whilst retaining it's ratio, drop 2 picture boxes and a
horizontal scrollbar onto the form and put an image in Picture1 then drop in this code and run:

'***
Private Declare Function PlgBlt Lib "GDI32.dll" (ByVal hDCDest As Long, _
ByRef lpPoint As PointAPI, ByVal hdcSrc As Long, ByVal nXSrc As Long, _
ByVal nYSrc As Long, ByVal nWidth As Long, ByVal nHeight As Long, _
ByVal hbmMask As Long, ByVal xMask As Long, ByVal yMask As Long) As Long
Private Declare Function CreateCompatibleDC Lib "GDI32.dll" (ByVal hDC As Long) As Long
Private Declare Function SelectObject Lib "GDI32.dll" (ByVal hDC As Long, ByVal hObject As Long) As Long
Private Declare Function DeleteDC Lib "GDI32.dll" (ByVal hDC As Long) As Long

Private Type PointAPI
X As Long
Y As Long
End Type

Private Function DrawStdPictureRot(ByVal inDC As Long, ByVal inX As Long, _
ByVal inY As Long, ByVal inAngle As Single, ByRef inPicture As StdPicture) As Long
Dim hDC As Long
Dim hOldBMP As Long
Dim PlgPts(0 To 4) As PointAPI
Dim PicWidth As Long, PicHeight As Long
Dim HalfWidth As Single, HalfHeight As Single
Dim AngleRad As Single

Const Pi As Single = 3.14159
Const HalfPi As Single = Pi * 0.5

' Validate input picture
If (inPicture Is Nothing) Then Exit Function
If (inPicture.Type <> vbPicTypeBitmap) Then Exit Function

' Get picture size
PicWidth = ScaleX(inPicture.Width, vbHimetric, vbPixels)
PicHeight = ScaleY(inPicture.Height, vbHimetric, vbPixels)

' Get half picture size and angle in radians
HalfWidth = PicWidth / 2
HalfHeight = PicHeight / 2
AngleRad = (inAngle / 180) * Pi

' Create temporary DC and select input picture into it
hDC = CreateCompatibleDC(0&)
hOldBMP = SelectObject(hDC, inPicture.Handle)

If (hOldBMP) Then ' Get angle vectors for width and height
PlgPts(0).X = Cos(AngleRad) * HalfWidth
PlgPts(0).Y = Sin(AngleRad) * HalfWidth
PlgPts(1).X = Cos(AngleRad + HalfPi) * HalfHeight
PlgPts(1).Y = Sin(AngleRad + HalfPi) * HalfHeight

' Project parallelogram points for rotated area
PlgPts(2).X = HalfWidth + inX - PlgPts(0).X - PlgPts(1).X
PlgPts(2).Y = HalfHeight + inY - PlgPts(0).Y - PlgPts(1).Y
PlgPts(3).X = HalfWidth + inX - PlgPts(1).X + PlgPts(0).X
PlgPts(3).Y = HalfHeight + inY - PlgPts(1).Y + PlgPts(0).Y
PlgPts(4).X = HalfWidth + inX - PlgPts(0).X + PlgPts(1).X
PlgPts(4).Y = HalfHeight + inY - PlgPts(0).Y + PlgPts(1).Y

' Draw rotated image
DrawStdPictureRot = PlgBlt(inDC, PlgPts(2), _
hDC, 0, 0, PicWidth, PicHeight, 0&, 0, 0)

' De-select Bitmap from DC
Call SelectObject(hDC, hOldBMP)
End If

' Destroy temporary DC
Call DeleteDC(hDC)
End Function

Private Sub HScroll1_Change()
Call ReDraw
End Sub

Private Sub HScroll1_Scroll()
Call ReDraw
End Sub

Private Sub ReDraw()
Picture2.AutoRedraw = True

Call Picture2.Cls
Call DrawStdPictureRot(Picture2.hDC, 0, 0, HScroll1.Value, Picture1.Picture)
Call Picture2.Refresh
End Sub
'***

Mike D Sutton

unread,
Aug 25, 2004, 7:32:39 PM8/25/04
to
> As a matter of fact, I visited 'his' site earlier today, and in fact
> downloaded the PDF file, 'Using Device Contexts in Visual Basic', for
> bedtime reading. I think the transformations idea would be the way to
> go, but I am somewhat constrained by non-NT users.

You're most likely better off sticking with the original piece of code you found, it's a nice solution to the problem but sounds
like it needs bullet proofing a little and extending to cope with more varied bit-depths. Could you send over a screenshot of the
visual anomaly you're seeing when running the code, it should be pretty obvious if it's a DWord alignment issue or not.
Also, are you working with a particular bit-depth of image or do you have to cope with any Bitmap? Are you using the Alpha channel
in 32-bit images? Palette images? 4/8-Bit RLE compressed images?

> Well, performance IS an issue for me. The various objects' bitmaps
> will be used in real time, rather like rotary knobs or dials. If the
> mouse is moved around the centre of one of these bitmaps with the left
> button down, the bitmap should rotate (in real time), and a control
> variable's value will follow its position. That won't work well if
> the algorithm used is a bit sluggish.

Can the images you're rotating be described by vector shapes by any chance? Rotating a bunch of vectors is a _lot_ faster and
easier than trying to implement Bitmap rotation, if these are specified by your users then you could use EMF or WMF files to store
the vector shapes which are easily enumerated via the API.

Schmidt

unread,
Aug 26, 2004, 4:54:15 AM8/26/04
to

"Andy Ellis" <andrewellisREM...@btconnect.com> schrieb im
Newsbeitrag news:%23itruSr...@TK2MSFTNGP11.phx.gbl...

You can achieve a fast rotate in VB, if you load your Images into
32bpp-Arrays (normal VB-Long-Arrays).
Here comes an example.

http://tinyurl.com/6lgzr

Olaf


Andy Ellis

unread,
Aug 27, 2004, 9:38:25 AM8/27/04
to
Mike,

"Mike D Sutton" <ED...@mvps.org> wrote in message
news:uDS8Pvvi...@TK2MSFTNGP11.phx.gbl...

> You're most likely better off sticking with the original piece of
code you found, it's a nice solution to the problem but sounds
> like it needs bullet proofing a little and extending to cope with
more varied bit-depths. Could you send over a screenshot of the
> visual anomaly you're seeing when running the code, it should be
pretty obvious if it's a DWord alignment issue or not.
> Also, are you working with a particular bit-depth of image or do you
have to cope with any Bitmap? Are you using the Alpha channel
> in 32-bit images? Palette images? 4/8-Bit RLE compressed images?

Did you get the screenshot I sent over (I had to send it directly to
your e-mail in order to include the attachment)?

I've downloaded the demo again to a machine running XP, and also asked
a colleague to look at the demo on a 3rd machine, and it's clear that
my system is doing something strange with the bitmap. What is this
'DWord alignment issue' you spoke about? How will I correct it, and
furthermore, how will I ensure that the code will run successfully on
any (Windows variant) platform?

Regards
Andy Ellis


Andy Ellis

unread,
Aug 27, 2004, 1:18:18 PM8/27/04
to
Guys, particularly Mike D and Bryan,

Did you see my earlier posting? (Part reproduced below.)

> I've downloaded the demo again to a machine running XP, and also
asked
> a colleague to look at the demo on a 3rd machine, and it's clear
that
> my system is doing something strange with the bitmap. What is this
> 'DWord alignment issue' you spoke about? How will I correct it, and
> furthermore, how will I ensure that the code will run successfully
on
> any (Windows variant) platform?

Subsequently my colleague has tested the app again on another machine.
He doesn't have VB, so he's had to run the EXE (included in the
original downloaded ZIP). This time he's got the thing to fail in
exactly the same way that it failed for me. The common denominator
is, this time he's run it under Win2K Pro. The plot thickens! Does
this help either of you (or anyone else who's watching this thread) to
spot what's going on here? What's wrong with Win2K Pro?

Andy Ellis

Mike D Sutton

unread,
Aug 29, 2004, 4:39:58 PM8/29/04
to
> Did you get the screenshot I sent over (I had to send it directly to
> your e-mail in order to include the attachment)?

Yep, the 'shear' effect you see on the resulting image is very characteristic of DWord alignment problems.

> I've downloaded the demo again to a machine running XP, and also asked
> a colleague to look at the demo on a 3rd machine, and it's clear that
> my system is doing something strange with the bitmap. What is this
> 'DWord alignment issue' you spoke about? How will I correct it, and
> furthermore, how will I ensure that the code will run successfully on
> any (Windows variant) platform?

I would imagine that it's dependant on your display settings, changing your desktop resolution will likely change the resulting
image.
You may also want to have a look at this page on the original site which details a better method for performing the rotation
mapping:
http://www.ur.co.nz/static/default_typeid_3_dataid_363.htm
There's also a 24-bit version with demonstration application here:
http://www.ur.co.nz/static/default_typeid_3_dataid_362.htm
See if those versions work since they provide a more robust method than the original article, if so based on the changes to the
24-bit version you should be able to make one that works at 8, 16, 24 or 32-Bit with little difficulty. Lower bit-depths are a
little more complex since multiple pixels are contained with each byte, and both of these methods will only work with DIBSection's
but it will give you a good start at least.
Due to the way the routine maps the pixels back to the source rather than visa versa, it's also possible to add simple
multi-sampling to this method if you need higher quality rotation.

Andy Ellis

unread,
Aug 30, 2004, 2:23:59 PM8/30/04
to
Mike,

"Mike D Sutton" <ED...@mvps.org> wrote in message

news:uI7tahgj...@TK2MSFTNGP11.phx.gbl...


> You may also want to have a look at this page on the original site
which details a better method for performing the rotation
> mapping:
> http://www.ur.co.nz/static/default_typeid_3_dataid_363.htm
> There's also a 24-bit version with demonstration application here:
> http://www.ur.co.nz/static/default_typeid_3_dataid_362.htm

I'm not yet sure if I can get these samples will work - I'm trying to
shoe-horn them into a test project I have set up for this stuff, and
I'm running into problems in another aspect of it (caused by my lack
of understanding).

OK, I can see how to use GetObjectAPI and CopyMemory in order to have
a 2D array to work with - providing there exists a bitmap in a Picture
Box somewhere to use as a 'source'. What if I need to generate a
completely new bitmap to work with? My app (the subject of my
original enquiry) has a class module to encapsulate graphic objects,
each of which may include 2 bitmaps (which I am storing as
IPictureDisp objects, since they are loaded up from file with
LoadPicture). One bitmap is static, the other may rotate. So my test
project has a target picture box into which I need first to load the
static bitmap, then use the stuff from these demos to load the
rotating bitmap at whatever orientation is required. Well, if the
static bitmap has a height or width smaller than the diagonal across
the rotating bitmap, I need to make the target higher or wider in the
corresponding direction, and centre both bitmaps within it.
Otherwise, the rotating bitmap will lose its corners when the diagonal
is rotated to vertical or horizontal.

I think I have to tackle this by calculating the required width and
height for the target picture box, then creating a new bitmap of that
size (how???) as a starting point, having each pixel set to the
BackColor, then using BitBlt to copy in the static bitmap (centred),
and finally using the demo code to copy in the rotating bitmap (also
centred).

Am I on the right track with this? How do I generate that first
bitmap?

Andy Ellis


Mike D Sutton

unread,
Aug 30, 2004, 5:18:32 PM8/30/04
to
> I'm not yet sure if I can get these samples will work - I'm trying to
> shoe-horn them into a test project I have set up for this stuff, and
> I'm running into problems in another aspect of it (caused by my lack
> of understanding).
>
> OK, I can see how to use GetObjectAPI and CopyMemory in order to have
> a 2D array to work with - providing there exists a bitmap in a Picture
> Box somewhere to use as a 'source'. What if I need to generate a
> completely new bitmap to work with?

To create a new Bitmap rather than working from an existing StdPicture you need to create a GDI Bitmap object using
CreateDIBSection() (Note; there are two kinds of GDI bitmaps, DDBs and DIBs. The UR method (all examples posted in this thread)
will only work with DIBs since DDBs do not give direct access to their image data, so don't try and create the bitmap using
CreateBitmap() or CreateCompatibleBitmap() etc.)
Once you have a DIBSection handle you can either use it as-is or if you prefer to work with the OLE StdPicture/IPictureDisp
interface then you can wrap this object using my OLEPicture library:
Http://www.mvps.org/EDais/Code/Libraries/Graphics/modOLEPicture.bas

> My app (the subject of my
> original enquiry) has a class module to encapsulate graphic objects,
> each of which may include 2 bitmaps (which I am storing as
> IPictureDisp objects, since they are loaded up from file with
> LoadPicture). One bitmap is static, the other may rotate. So my test
> project has a target picture box into which I need first to load the
> static bitmap, then use the stuff from these demos to load the
> rotating bitmap at whatever orientation is required. Well, if the
> static bitmap has a height or width smaller than the diagonal across
> the rotating bitmap, I need to make the target higher or wider in the
> corresponding direction, and centre both bitmaps within it.
> Otherwise, the rotating bitmap will lose its corners when the diagonal
> is rotated to vertical or horizontal.

I've actually been developing my own module based around this code and have come across some of the same problems you're facing.
Here's the method I'm using to calculate the size of the rotated Bitmap:

'***


Private Type PointAPI
X As Long
Y As Long
End Type

Private Const Pi As Single = 3.14159
Private Const HalfPi As Single = Pi * 0.5

...

Private Function GetRotationOffset(ByVal inAngleRad As Single, _
ByVal inHalfWidth As Long, ByVal inHalfHeight As Long) As PointAPI
Dim HorizVector As PointAPI, VertVector As PointAPI
Dim BoxPts(0 To 3) As PointAPI
Dim LoopPts As Long

' Calculate horizontal and vertical offset vectors
HorizVector.X = Cos(inAngleRad) * inHalfWidth
HorizVector.Y = Sin(inAngleRad) * inHalfWidth
VertVector.X = Cos(inAngleRad + HalfPi) * inHalfHeight
VertVector.Y = Sin(inAngleRad + HalfPi) * inHalfHeight

' Project corner points
BoxPts(0).X = inHalfWidth - HorizVector.X - VertVector.X
BoxPts(0).Y = inHalfHeight - HorizVector.Y - VertVector.Y
BoxPts(1).X = inHalfWidth + HorizVector.X - VertVector.X
BoxPts(1).Y = inHalfHeight + HorizVector.Y - VertVector.Y
BoxPts(2).X = inHalfWidth + HorizVector.X + VertVector.X
BoxPts(2).Y = inHalfHeight + HorizVector.Y + VertVector.Y
BoxPts(3).X = inHalfWidth - HorizVector.X + VertVector.X
BoxPts(3).Y = inHalfHeight - HorizVector.Y + VertVector.Y

' Get top left of bounding area
GetRotationOffset = BoxPts(0)

For LoopPts = 1 To 3 ' Find smallest size
If (BoxPts(LoopPts).X < GetRotationOffset.X) Then _
GetRotationOffset.X = BoxPts(LoopPts).X
If (BoxPts(LoopPts).Y < GetRotationOffset.Y) Then _
GetRotationOffset.Y = BoxPts(LoopPts).Y
Next LoopPts
End Function
'***

You pass it in the angle or rotation in radians and half the width and height and it returns you an X,Y coordinate for the extra
space it needs for each corner, so the resulting Bitmap size is:

'***
Dim Offset As PointAPI

...

Offset = GetRotationOffset(Angle, OldWidth / 2, OldHeight / 2)
NewWidth = OldWidth + (-Offset.X * 2)
NewHeight = OldHeight + (-Offset.Y * 2)
'***

> I think I have to tackle this by calculating the required width and
> height for the target picture box, then creating a new bitmap of that
> size (how???) as a starting point, having each pixel set to the
> BackColor, then using BitBlt to copy in the static bitmap (centred),
> and finally using the demo code to copy in the rotating bitmap (also
> centred).
>
> Am I on the right track with this? How do I generate that first
> bitmap?

Hopefully the above made sense for this. Hopefully sometime soon I'll have my DIB article finished which explains all of this in
detail, just got to find some time! If you want I can send you an early draft of the first few chapters which should give you a
better understanding of the subject area but it's quite heavy going if you're not really too into graphics development so be warned!

Andy Ellis

unread,
Aug 30, 2004, 6:19:19 PM8/30/04
to
Mike,

"Mike D Sutton" <ED...@mvps.org> wrote in message

news:OtGLobtj...@TK2MSFTNGP15.phx.gbl...

> Hopefully the above made sense for this. Hopefully sometime soon
I'll have my DIB article finished which explains all of this in
> detail, just got to find some time! If you want I can send you an
early draft of the first few chapters which should give you a
> better understanding of the subject area but it's quite heavy going
if you're not really too into graphics development so be warned!

These problems have shown up my need to get a better understanding of
the API, so in spite of the heavy going, I'd be grateful to see your
DIB article, thanks!

There's a bit of a time delay between our postings - it's my guess
you're on the West side of the Atlantic? Maybe even further West than
that?

Andy


Mike D Sutton

unread,
Aug 30, 2004, 7:28:40 PM8/30/04
to
> These problems have shown up my need to get a better understanding of
> the API, so in spite of the heavy going, I'd be grateful to see your
> DIB article, thanks!

Hokay, I'll hopefully get you something off tomorrow.

> There's a bit of a time delay between our postings - it's my guess
> you're on the West side of the Atlantic? Maybe even further West than
> that?

UK here, and I'm guessing from your e-mail address you are also?
Cheers,

Andy Ellis

unread,
Aug 30, 2004, 7:38:08 PM8/30/04
to
Mike

> UK here, and I'm guessing from your e-mail address you are also?

Well, kind of - Aberdeen.

Andy


Mike D Sutton

unread,
Aug 30, 2004, 7:44:09 PM8/30/04
to
> Well, kind of - Aberdeen.

Not still up at this time of night trying to get the Bitmap rotation to work I hope? ;)

Andy Ellis

unread,
Aug 30, 2004, 7:49:30 PM8/30/04
to
> Not still up at this time of night trying to get the Bitmap rotation
to work I hope? ;)

Sadly, yes - in between watching Frank Skinner on the TV.


Mike D Sutton

unread,
Aug 30, 2004, 7:54:15 PM8/30/04
to
> Sadly, yes - in between watching Frank Skinner on the TV.

Ok, give me a few and I'll send over a draft of this article - It'll likely put you right to sleep *g*

Schmidt

unread,
Aug 31, 2004, 4:24:59 AM8/31/04
to

"Andy Ellis" <andrewellisREM...@btconnect.com> schrieb im
Newsbeitrag news:eZwrz5rj...@TK2MSFTNGP11.phx.gbl...

> I think I have to tackle this by calculating the required width and
> height for the target picture box, then creating a new bitmap of that
> size (how???) as a starting point, having each pixel set to the
> BackColor, then using BitBlt to copy in the static bitmap (centred),
> and finally using the demo code to copy in the rotating bitmap (also
> centred).

The Rotate-Example I've posted (5 days ago) does just this.
(it get's the original-Bitmap as a 2Dim-Src-Array and returns the Dst-Arr
with the correct dimensions as the rotatet original Bitmap)

Olaf


Andy Ellis

unread,
Aug 31, 2004, 5:41:07 AM8/31/04
to
Olaf,

> The Rotate-Example I've posted (5 days ago) does just this.
> (it get's the original-Bitmap as a 2Dim-Src-Array and returns the
Dst-Arr
> with the correct dimensions as the rotatet original Bitmap)

I did take a look at your code, and in fact I experimented with using
sections of it in my test project for this. I'll have another look
now I've learnt a bit more about all this.

Thanks.

Andy


0 new messages