Larger sprite into smaller area (width, height)
BlitzMax Forums/BlitzMax Programming/Larger sprite into smaller area (width, height)
| ||
| This should be pretty simple but for some reason its just not having it. I have some images that are larger than my "image preview" area and I need them to be scaled down to fit inside this area of say 200 x 200 pixels but I cannot seem to calc the scale value 0.0 - 1.0 Any ideas peeps? Some images are not square and some images are smaller than the preview area (they could do with being scaled up to fit better also) |
| ||
| DrawImageRect |
| ||
| doh.... lol |
| ||
This what your looking for?
SuperStrict
Graphics 1024,768,0,60
SetBlend(alphablend)
SetClsColor(111,111,111)
Local image:TImage = LoadImage(OpenFile("http::www.blitzbasic.com/gallery/pics/2110.jpg"))
Local w#,h#
w = 100#/image.width
h = 100#/image.height
While Not KeyHit(key_escape)
DrawRect 10,10,100,100
SetAlpha(0.5)
DrawImage(image,MouseX(),MouseY())
SetScale w,h
SetAlpha(1)
DrawImage(image,MouseX(),MouseY())
SetScale 1,1
Flip
Cls
Wend
|
| ||
| Pretty much, turns out it was a type style problem... as most of the time it was correct just not... lol |