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