Pixmap add FitPixmap Func.
BlitzMax Forums/BlitzMax Module Tweaks/Pixmap add FitPixmap Func.
| ||
Function FitPixmap:TPixmap(pix:TPixmap,w:Float,h:Float,Zoom:Int=True) 'MR 10.07.2005 'Fit a Pixmap to width,height with correct ratio If pix=Null Then Return Null Local f1:Float,f2:Float Local pw:Float,ph:Float pw=pix.width ph=pix.height f1 = 1.0 f2 = 1.0 If Zoom Then If pw <> w Then 'with ZOOM <> f1 = w / pw End If If ph <> h Then f2 = h / ph End If Else If pw > w Then 'without ZOOM > f1 = w / pw End If If ph > h Then f2 = h / ph End If EndIf If f2 < f1 Then f1 = f2 pix=ResizePixmap(pix,f1*pw,f1*ph) Return pix End Function |