Hi
Is there a method to scale an image ??? i have try resize
pixmap but i don't use pixmap , but timage.
Is there a method to scale an image ??? i have try resize
pixmap but i don't use pixmap , but timage.
SetScale 2.0,2.0 '2x the size SetScale 6.0,6.0 '6x the size SetScale 0.5,0.5 'Half size SetScale 0.25,0.25 'Quater size SetScale 1.0,1.0 'Normal size
' ------------ ' Open graphic ' ------------ Graphics 1024,768,0 Global MyIMage01:Timage=LoadImage("colourblind.jpeg") Global MyIMage02:Timage=ResizeImage(MyIMage01,256,256) ' ------------- ' The main loop ' ------------- While Not KeyHit(KEY_ESCAPE) Cls DrawImage MyIMage02,0,0 ' ------------------------ ' Swap buffer and flushmem ' ------------------------ Flip Wend Function ResizeImage:Timage(Image:TImage,Tx:Int,Ty:Int) Local x Local y Local c Local Pixmap:TPixmap Local Duplicate:TPixmap Local Output:Timage Duplicate=CreatePixmap(ImageWidth(Image),ImageHeight(Image),PF_RGB888) Pixmap = LockImage(Image) For x = 0 To ImageWidth(Image) - 1 For y = 0 To ImageHeight(Image) - 1 c=ReadPixel(Pixmap, x, y) WritePixel(Duplicate, x,y,c) Next Next UnlockImage(Image) Pixmap= Null Resized=ResizePixmap(Duplicate,Tx,Ty) Output=CreateImage(Tx,Ty) Pixmap=LockImage(Output) For x = 0 To Tx-1 For y = 0 To Ty-1 c=ReadPixel(Resized, x, y) WritePixel(Pixmap, x,y,c) Next Next UnlockImage(Output) Duplicate= Null Pixmap= Null Return Output End Function