Dreamora's routine doesn't seem to take power of two texture rescaling into account?
I've fixed the scaling thing, pulled out the dx and dy as they seemed a bit pointless to me, renamed the variables and slapped in some compiler directives for good measure...
I've fixed the scaling thing, pulled out the dx and dy as they seemed a bit pointless to me, renamed the variables and slapped in some compiler directives for good measure...
Strict Graphics 800,600 Global hImage:Timage = LoadImage ("griffe.png") SetImageHandle hImage, 0,0 While Not KeyDown (KEY_ESCAPE) Cls SetColor 255, 255,255 DrawRect 300,100,200,150 DrawImage hImage, 250,100 DrawRect 300,300,200,150 DrawImageArea hImage, 300,300, 50, 0, 200, 150 Flip Wend End Function DrawImageArea(image:TImage, x#, y#, rx#, ry#, rw#, rh#, frame=0) Local origin_x#, origin_y# ; GetOrigin (origin_x, origin_y) Local tw = Pow2Size(image.width) Local th = Pow2Size(image.height) Local rw1# = rx + rw Local rh1# = ry + rh Local x0# = -image.handle_x, x1# = x0 + rw Local y0# = -image.handle_y, y1# = y0 + rh If rw1 > image.width x1 = x0 + rw + image.width - rw1 rw1 = image.width EndIf If rh1 > image.height y1 = y0 + rh + image.height - rh1 rh1 = image.height EndIf ?Win32 If TD3D7ImageFrame(image.frame(frame)) Local frame:TD3D7ImageFrame = TD3D7ImageFrame(image.frame(frame)) frame.setUV(rx / tw, ry / th, rw1 / tw, rh1 / th) frame.Draw x0, y0, x1, y1, x + origin_x, y + origin_y frame.setUV(0, 0, image.width / Float(tw), image.height / Float(th)) Else ? Local frame:TGLImageFrame = TGLImageFrame (image.frame(frame)) frame.u0 = rx / tw frame.v0 = ry / th frame.u1 = rw1 / tw frame.v1 = rh1 / th frame.Draw x0, y0, x1, y1, x + origin_x, y + origin_y frame.u0 = 0 frame.v0 = 0 frame.u1 = image.width / Float(tw) frame.v1 = image.height / Float(th) ?Win32 EndIf ? Function Pow2Size(n) Local ry = 1 While ry < n ry :* 2 Wend Return ry End Function End Function