Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

rotate bitmap 5

Status
Not open for further replies.

ADoozer

Programmer
Dec 15, 2002
3,487
AU
ok, another simple one for someone,

im trying to rotate an image (selected with bitblt from a larger image) through 90° and 270° (and eventually 45°,135°,225°,315°)

can i do it with one of the raster ops (bitblt) or do i need a seperate API?

any input appreciated!

ps: i hate bitmaps!!!

If somethings hard to do, its not worth doing - Homer Simpson
------------------------------------------------------------------------
A General Guide To Excel in VB FAQ222-3383
File Formats Galore @
 
Just as a side note, the reason why DirectDraw was copying stuff off of the desktop is because DirectDraw refers to the screen, not your form, so a coordinate from your form will probably be off of you form. This can be solved with the ClientToScreen API. As for how confusing DirectDraw is, most of it is just to setup everything, so it shouldn't be that hard once you have some sample code... Don't ask me, though! I'm bad enough with it! :)
 
Strongm:

I think I may be missing something. I don't now if this is possible, but can you use this code to do the following two things?

1. Rotate a picture box around a centre point, instead of around the top left corner of picture box 2?

2. Can you rotate non-visible objects, as I don't want the use to see the original, but want to keep the original in a standard orientation, and then rotate it quickyl each time, rather than calculate the difference between angle a and angle b, and loose picture quality after 30 movements.

I'm not sure either of these are possible, but I figure that someone out there may well have tried and succeeded where I am trying and failing slowly.

BB
 
>I think I may be missing something

No, not missing anything. The code I posted is a simple proof of concept, not a solution to a particular problem.

Both the things you want to do are possible.

Here's some clues:

1) In the buildXForm function cehck out the lines that read
[tt]
buildXForm.eDx = x0 'x0 - Cos(q) * x0 + Sin(q) * y0
buildXForm.eDy = y0 'y0 - Cos(q) * y0 - Sin(q) * x0
[/tt]
And reinstate the commented-out bits. This will restore the functions ability to rotate about an arbitary point. You will, of course, often also need to modify your rendering commands to take into account this displaced center of rotation (e.g. in this example you'd need to look at
[tt]
BitBlt hdcTarget, 0, 0, 500, 500, hdcSource, 0, 0, vbSrcCopy
[/tt]
and change the first two 0s

2) We're only using picture boxes in this example becaue they are a quick and easy way to get handles to device contexts. However, we don't need the picture boxes at all. We just need device contexts, and we can create memory device contexts (rhater than visible screen device contexts) using the API. A keyword search in this forum will find several examples from myself (and others) on doing just that.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top