ImageBuffer.htm 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <html>
  2. <head>
  3. <title>Blitz3D Docs</title>
  4. <link rel=stylesheet href=../css/commands.css type=text/css>
  5. </head>
  6. <body>
  7. <h1>ImageBuffer (handle[,frame])</h1>
  8. <h1>Parameters</h1>
  9. <table>
  10. <tr>
  11. <td>
  12. handle=variable holding the image's handle <br />
  13. frame=optional frame to draw to if using an imagestrip image
  14. </td>
  15. </tr>
  16. </table>
  17. <h1>Description</h1>
  18. <table>
  19. <tr>
  20. <td>
  21. 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 (CreateImage). 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 SetBuffer 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!
  22. </td>
  23. </tr>
  24. </table>
  25. <h1><a href=../2d_examples/ImageBuffer.bb>Example</a></h1>
  26. <table>
  27. <tr>
  28. <td>
  29. ; CreateImage/TileImage/ImageBuffer example <br />
  30. <br />
  31. ; Again, we'll use globals even tho we don't need them here <br />
  32. ; One variable for the graphic we'll create, one for a timer <br />
  33. Global gfxStarfield, tmrScreen <br />
  34. <br />
  35. ; Declare graphic mode <br />
  36. Graphics 640,480,16 <br />
  37. <br />
  38. ; Create a blank image that is 320 pixels wide and 32 high with 10 frames of 32x32 <br />
  39. gfxStarfield=CreateImage(32,32,10) <br />
  40. <br />
  41. ; loop through each frame of the graphic we just made <br />
  42. For t = 0 To 9 <br />
  43. ; Set the drawing buffer to the graphic frame so we can write on it <br />
  44. SetBuffer ImageBuffer(gfxStarfield,t) <br />
  45. ; put 50 stars in the frame at random locations <br />
  46. For y = 1 To 50 <br />
  47. Plot Rnd(32),Rnd(32) <br />
  48. Next <br />
  49. Next <br />
  50. <br />
  51. ; Double buffer mode for smooth screen drawing <br />
  52. SetBuffer BackBuffer() <br />
  53. <br />
  54. ; Loop until ESC is pressed <br />
  55. While Not KeyHit(1) <br />
  56. <br />
  57. ; Only update the screen every 300 milliseconds. Change 300 for faster or <br />
  58. ; slower screen updates <br />
  59. If MilliSecs() > tmrScreen+300 Then <br />
  60. Cls ; clear the screen <br />
  61. <br />
  62. ; Tile the screen with a random frame from our new graphic starting at <br />
  63. ; x=0 and y=0 location. <br />
  64. TileImage gfxStarfield,0,0,Rnd(9) <br />
  65. Flip ; Flip the screen into view <br />
  66. tmrScreen=MilliSecs() ; reset the time <br />
  67. End If <br />
  68. Wend <br />
  69. </td>
  70. </tr>
  71. </table>
  72. <br>
  73. <a target=_top href=../index.htm>Index</a><br>
  74. <br>
  75. Click <a href=http://www.blitzbasic.co.nz/b3ddocs/command.php?name=ImageBuffer&ref=comments target=_blank>here</a> to view the latest version of this page online</body>
  76. </html>