Graphics 640, 480, 16, 2 SetBuffer BackBuffer() img = LoadImage("test.bmp"): MaskImage img, 255, 0, 255 Global fpsCount = 0, fpsCurrent = 0, fpsTime# = MilliSecs() + 1 Local tmp# = 1, tmpDir% = 0 While Not KeyDown(1) fpsCount = fpsCount + 1 If MilliSecs() >= fpsTime Then fpsCurrent = fpsCount: fpsCount = 0: fpsTime = fpsTime + 1000 tmpImg = Scale_Image(img, tmp, tmp) DrawImage tmpImg, 320 - ImageWidth(tmpImg) / 2, 240 - ImageHeight(tmpImg) / 2 FreeImage tmpImg If tmpDir = 0 Then tmp = tmp - .01 Else tmp = tmp + .01 If tmp <= .1 Then tmpDir = 1 ElseIf tmp >= 1 Then tmpDir = 0 Text 1, 1, (TotalVidMem() - AvailVidMem()) / 1024 + "kbs" Text 1, 14, fpsCurrent Flip 0: Cls Wend: End Function Scale_Image(SrcImage, ScaleX#, ScaleY#) Local SrcWidth, SrcHeight Local DestWidth, DestHeight Local ScratchImage, DestImage Local SrcBuffer, ScratchBuffer, DestBuffer Local X1, Y1, X2, Y2 ; If the image does not need to be scaled, just copy the image and exit the function. If (ScaleX# = 1) And (ScaleY# = 1) Then Return CopyImage(SrcImage) ; Get the width and height of the source image. SrcWidth = ImageWidth(SrcImage) SrcHeight = ImageHeight(SrcImage) ; Calculate the width and height of the dest image. DestWidth = Floor(SrcWidth * ScaleX#) DestHeight = Floor(SrcHeight * ScaleY#) ; Create a scratch image that is as tall as the source image, and as wide as the destination image. ScratchImage = CreateImage(DestWidth, SrcHeight) ; Create the destination image. DestImage = CreateImage(DestWidth, DestHeight) ; Get pointers to the image buffers. SrcBuffer = ImageBuffer(SrcImage) ScratchBuffer = ImageBuffer(ScratchImage) DestBuffer = ImageBuffer(DestImage) ; Duplicate columns from source image to scratch image. For X2 = 0 To DestWidth-1 X1 = Floor(X2 / ScaleX#) CopyRect X1, 0, 1, SrcHeight, X2, 0, SrcBuffer, ScratchBuffer Next ; Duplicate rows from scratch image to destination image. For Y2 = 0 To DestHeight-1 Y1 = Floor(Y2 / ScaleY#) CopyRect 0, Y1, DestWidth, 1, 0, Y2, ScratchBuffer, DestBuffer Next ; Free the scratch image. FreeImage ScratchImage ; Return the new image. Return DestImage End Function