draw a area of an image
BlitzMax Forums/BlitzMax Beginners Area/draw a area of an image
| ||
| Hi ! Is there a command to draw a area of an image ? Drawimagerect draw the entire image with deformation, not a portion of the image Thanks ! |
| ||
| Check in the Code Archives, I am sure someone gave a solution to this. ** EDIT Here you go. http://www.blitzbasic.com/codearcs/codearcs.php?code=1422 |
| ||
| Thanks, but i prefer use classic bmax 2dcommands for compatibility. I fact i want do this : -- but without the black rectangle !!! -- perhaps have you some ideas ! (in my game i use a background image, so i can't use this technic). i want only draw the image.
Graphics 800, 600
Global hImageGriffe = LoadImage ("Griffe.png")
l = ImageWidth (hImageGriffe)
Temps = MilliSecs()
inc = 0
Sens = 1
x = 400
w = ImageWidth(hImageGriffe)
While Not KeyDown (KEY_ESCAPE)
Cls
If Temps + 500 < MilliSecs() Then
DrawImageRect hImageGRiffe, x, 250, w, ImageHeight(hImageGriffe)
If sens = 1 Then
If inc < l Then
inc = inc + 1
Else
sens = - 1
End If
End If
If Sens = - 1 Then
If inc > 0 Then
Inc = Inc - 1
Else
sens = 1
End If
End If
x = 400 - inc
End If
SetAlpha 0.8
SetColor 0,0,0
DrawRect 400,200,400,200
SetAlpha 1.0
SetColor 255,255,255
Flip
Wend
image here : |
| ||
| I thing this will do the trick Edit:"setViewport" |
| ||
One from the archives...Function DrawImageRectClip(image:TImage, x#, y#, rx#, ry#, rw#, rh#, frame=0) Local vx, vy, vw, vh, hx#, hy# hx# = image.handle_x hy# = image.handle_y SetImageHandle image, 0, 0 GetViewport(vx, vy, vw, vh) SetViewport x#, y#, rx# + rw#, ry# + rh# DrawImage image, x# - rx#, y# - ry#, frame SetViewport vx, vy, vw, vh SetImageHandle image, hx#, hy# End Function |
| ||
| Many thanks for your help. This seems works fine now ! |