GrabImage fails when using a virtual resolution
Archives Forums/BlitzMax Bug Reports/GrabImage fails when using a virtual resolution
| ||
Run this code as is, all works fine. Uncomment line 2, run it again - fail. Its only grabbing the top-left portion of the requested area (which is probably 512x512 in the physical screen res). It would be easy enough to calculate the correct width and height... but not much good if you're still trying to fit that into a 512x512 image. Graphics 1024,768 'SetVirtualResolution(800,600) Global img:TImage = CreateImage(512,512) DrawLine 10,10,502,10 DrawLine 502,10,502,502 DrawLine 502,502,10,502 DrawLine 10,502,10,10 GrabImage(img,0,0) SetBlend solidblend SetClsColor 255,0,0 While Not KeyDown(key_escape) Cls DrawImage img,VirtualMouseX(),VirtualMouseY() Flip Wend |
| ||
...and a work-around (which adds more than 50% to the processing time):Graphics 1024,768 SetVirtualResolution(800,600) Global img:TImage Global px:TPixmap DrawLine 10,10,502,10 DrawLine 502,10,502,502 DrawLine 502,502,10,502 DrawLine 10,502,10,10 Global ratio:Float = GraphicsWidth() / VirtualResolutionWidth() px = GrabPixmap(0,0,512*ratio,512*ratio) px = ResizePixmap(px,512,512) img = LoadImage(px) SetBlend solidblend SetClsColor 255,0,0 While Not KeyDown(key_escape) Cls DrawImage img,VirtualMouseX(),VirtualMouseY() Flip Wend [edit] Actually there's quite a lot of quality loss from ResizePixmap, so that's a no-go. Last edited 2011 |