handle=variable holding the image's handle frame=optional frame to draw to if using an imagestrip image |
There are 1000 reasons for this command. Simply put, you may want to 'draw' on an existing image you've loaded (LoadImage or LoadAnimImage) or created (dxCreateImage). You could, for example, have a blank wall graphic and you want to add 'graffiti' to it based on the user action (Jet Grind Radio baybeee! Sorry...). Instead of trying to draw a dozen images all over the wall, just use the dxSetBuffer command to denote the wall graphic as the 'target' buffer, and draw away! Next time you display that graphic (DrawImage), you will see your changes! This is a powerful command! |
; dxCreateImage/TileImage/dxImageBuffer example ; Again, we'll use globals even tho we don't need them here ; One variable for the graphic we'll create, one for a timer Global gfxStarfield, tmrScreen ; Declare graphic mode Graphics 640,480,16 ; Create a blank image that is 320 pixels wide and 32 high with 10 frames of 32x32 gfxStarfield=dxCreateImage(32,32,10) ; loop through each frame of the graphic we just made For t = 0 To 9 ; Set the drawing buffer to the graphic frame so we can dxWrite on it dxSetBuffer dxImageBuffer(gfxStarfield,t) ; put 50 stars in the frame at random locations For y = 1 To 50 dxPlot dxRnd(32),dxRnd(32) Next Next ; Double buffer mode for smooth screen drawing dxSetBuffer dxBackBuffer() ; Loop until ESC is pressed While Not dxKeyHit(1) ; Only update the screen every 300 milliseconds. Change 300 for faster or ; slower screen updates If MilliSecs() > tmrScreen+300 Then dxCls ; clear the screen ; Tile the screen with a random frame from our new graphic starting at ; x=0 and y=0 location. TileImage gfxStarfield,0,0,dxRnd(9) dxFlip ; dxFlip the screen into view tmrScreen=MilliSecs() ; reset the time End If Wend |