DirectX:DirectDraw:Tutorials:VB:DX7:Zooming

From GPWiki

(Redirected from VB:DX7 Zooming)

Files:GUITutorial_warn.gif The Game Programming Wiki has moved! Files:GUITutorial_warn.gif

The wiki is now hosted by GameDev.NET at wiki.gamedev.net. All gpwiki.org content has been moved to the new server.

However, the GPWiki forums are still active! Come say hello.

So what if you want to display a bitmap at 1/2 the ordinary size? Or twice the ordinary size? You'd need to ZOOM, wouldn't you? Well, zoom through this tutorial and you'll be zooming in no time! (WEAK!)

Dim Zoom as Single
 
    With DestRect
        .Bottom = 60 * Zoom
        .Left = 0
        .Right = 60 * Zoom
        .Top = 0
    End With
 
    BackBuffer.Blt DestRect, Ship(Facing), SrcRect, DDBLT_KEYSRC Or DDBLT_WAIT

All you have to do is multiply the size of the destination rectangle by some fraction and the BackBuffer.Blt function will handle the stretching of the bitmap to fit the size you give it. Just multiply the size of the sprite by the Zoom variable to obtain this effect. If you alter the Zoom variable below 1, you will be zooming out (making your sprite smaller), if you alter the Zoom variable above 1 you will be zooming in (making your sprite larger).

Click here for sample source code demonstrating this principle.