Can you not stretch a canvas like you could in B+? I am setting the layout with Canvas.SetLayout 1, 1, 1, 1 and it becomes all garbled with the render remaining unscaled. I am using the D3D7Max2DDriver.
max gui canvas stretching
BlitzMax Forums/BlitzMax Beginners Area/max gui canvas stretching edit:
I used this method (for displaying images which fit in the window) but I'm sure there is a better alternative ..
(NOTE: The canvas is also set to 1,1,1,1 layout)
Full example:
I used this method (for displaying images which fit in the window) but I'm sure there is a better alternative ..
(NOTE: The canvas is also set to 1,1,1,1 layout)
If EventID()=EVENT_GADGETPAINT SetGraphics CanvasGraphics(canvas) SetViewport 0,0,canvas.Width,canvas.Height Cls Local sx#=Float(canvas.ClientWidth())/Float(img.Width) Local sy#=Float(canvas.ClientHeight())/Float(img.Height) SetScale sx,sy DrawImage img,0,0 Flip EndIf
Full example:
AppTitle$="Canvas - Scale image to fit window" Const winstyle%=WINDOW_TITLEBAR|WINDOW_RESIZABLE Global win:TGadget=CreateWindow(AppTitle$, 80, 50, 256, 256 ,Null,winstyle) Global can:TGadget=CreateCanvas(0,0,win.ClientWidth(),win.ClientHeight(),win) SetGadgetLayout can,EDGE_ALIGNED,EDGE_ALIGNED,EDGE_ALIGNED,EDGE_ALIGNED SetMinWindowSize win,96,96 RedrawGadget can Global img:TImage=LoadImage("testimage.png") If Not img End Repeat ' DebugLog currentevent.ToString() Select WaitEvent() Case EVENT_GADGETPAINT DrawScaledImageToCanvas img,can Case EVENT_WINDOWCLOSE Exit End Select Forever End ' draw an image scaled to fill the canvas dimensions Function DrawScaledImageToCanvas(i:TImage,c:TGadget) SetGraphics CanvasGraphics(c) Cls SetViewport 0,0,c.Width,c.Height Local sx#=Float(c.ClientWidth())/Float(i.Width) Local sy#=Float(c.ClientHeight())/Float(i.Height) SetScale sx,sy DrawImage i,0,0 Flip End Function
I can't believe this isn't handled automatically. Thanks for your help.
I have the exact same problem.