| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- <html>
- <head>
- <title>Blitz3D Docs</title>
- <link rel=stylesheet href=../css/commands.css type=text/css>
- </head>
- <body>
- <h1>CreateImage (width,height[,frames])</h1>
- <h1>Parameters</h1>
- <table>
- <tr>
- <td>
- width=width of the new image (or its frames)
<br />
- height=height of the new image
<br />
- frames= optional number of frames (assumed to be a single frame)
- </td>
- </tr>
- </table>
- <h1>Description</h1>
- <table>
- <tr>
- <td>
- 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.
- </td>
- </tr>
- </table>
- <h1><a href=../2d_examples/CreateImage.bb>Example</a></h1>
- <table>
- <tr>
- <td>
- ; CreateImage/TileImage/ImageBuffer example
<br />
-
<br />
- ; Again, we'll use globals even tho we don't need them here
<br />
- ; One variable for the graphic we'll create, one for a timer
<br />
- Global gfxStarfield, tmrScreen
<br />
-
<br />
- ; Declare graphic mode
<br />
- Graphics 640,480,16
<br />
-
<br />
- ; Create a blank image that is 32 pixels wide and 32 high with 10 frames of 32x32
<br />
- gfxStarfield=CreateImage(32,32,10)
<br />
-
<br />
- ; loop through each frame of the graphic we just made
<br />
- For t = 0 To 9
<br />
- ; Set the drawing buffer to the graphic frame so we can write on it
<br />
- SetBuffer ImageBuffer(gfxStarfield,t)
<br />
- ; put 50 stars in the frame at random locations
<br />
- For y = 1 To 50
<br />
- Plot Rnd(32),Rnd(32)
<br />
- Next
<br />
- Next
<br />
-
<br />
- ; Double buffer mode for smooth screen drawing
<br />
- SetBuffer BackBuffer()
<br />
-
<br />
- ; Loop until ESC is pressed
<br />
- While Not KeyHit(1)
<br />
-
<br />
- ; Only update the screen every 300 milliseconds. Change 300 for faster or
<br />
- ; slower screen updates
<br />
- If MilliSecs() > tmrScreen+300 Then
<br />
- Cls ; clear the screen
<br />
-
<br />
- ; Tile the screen with a random frame from our new graphic starting at
<br />
- ; x=0 and y=0 location.
<br />
- TileImage gfxStarfield,0,0,Rnd(9)
<br />
- Flip ; Flip the screen into view
<br />
- tmrScreen=MilliSecs() ; reset the time
<br />
- End If
<br />
- Wend
- </td>
- </tr>
- </table>
- <br>
- <a target=_top href=../index.htm>Index</a><br>
- <br>
- 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>
- </html>
|