101 lines
2.8 KiB
HTML
101 lines
2.8 KiB
HTML
<html>
|
|
<head>
|
|
<title>Blitz3D Docs</title>
|
|
<link rel=stylesheet href=../css/commands.css type=text/css>
|
|
</head>
|
|
<body>
|
|
<h1>WritePixelFast x,y,rgb,[buffer]</h1>
|
|
<h1>Parameters</h1>
|
|
<table>
|
|
<tr>
|
|
<td>
|
|
x - y-coordinate of pixel
|
|
<br />
|
|
y - y-coordinate of pixel
|
|
<br />
|
|
argb - argb colour value of pixel (alpha, red, green, blue)
|
|
<br />
|
|
buffer (optional) - name of buffer to write colour value to, e.g. BackBuffer()
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
<h1>Description</h1>
|
|
<table>
|
|
<tr>
|
|
<td>
|
|
Writes a colour value to either the current buffer or the specified buffer.
|
|
|
|
<br />
|
|
|
|
<br />
|
|
IMPORTANT:
|
|
|
|
<br />
|
|
|
|
<br />
|
|
You *must* use this command on a locked buffer, otherwise the command will fail. See LockBuffer.
|
|
|
|
<br />
|
|
|
|
<br />
|
|
Also, you must make sure that the coordinates that you are writing to are valid, otherwise you will end up overwriting other areas of memory.
|
|
|
|
<br />
|
|
|
|
<br />
|
|
WARNING:
|
|
|
|
<br />
|
|
|
|
<br />
|
|
By not following the above advice, you may cause your computer to crash.
|
|
|
|
<br />
|
|
|
|
<br />
|
|
See also: Plot, WritePixel.
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
<h1><a href=../2d_examples/WritePixelFast.bb>Example</a></h1>
|
|
<table>
|
|
<tr>
|
|
<td>
|
|
; ReadPixelFast/WritePixeFast Example
|
|
<br />
|
|
; -----------------------------------
|
|
<br />
|
|
|
|
<br />
|
|
Graphics 640,480,16
|
|
<br />
|
|
|
|
<br />
|
|
Print "Press a key to read color values"
|
|
<br />
|
|
WaitKey()
|
|
<br />
|
|
|
|
<br />
|
|
; Load and draw an image on to the screen - can be anything
|
|
<br />
|
|
pic=LoadImage("media/blitz_pic.bmp")
|
|
<br />
|
|
DrawImage pic,0,0
|
|
<br />
|
|
|
|
<br />
|
|
; Initialise an array big enough to fit all the color information of the screen
|
|
<br />
|
|
Dim pix(GraphicsWidth(),GraphicsHeight())
|
|
<br />
|
|
|
|
<br />
|
|
; Lock buffer before using ReadPixelFast
|
|
<br />
|
|
LockBuffer
|
|
<br />
|
|
|
|
<br />
|
|
; Use ReadPixel to get all the color information of the screen
|
|
<br />
|
|
For y=0 To GraphicsHeight()
|
|
<br />
|
|
For x=0 To GraphicsWidth()
|
|
<br />
|
|
pix(x,y)=ReadPixelFast(x,y)
|
|
<br />
|
|
Next
|
|
<br />
|
|
Next
|
|
<br />
|
|
|
|
<br />
|
|
; Lock buffer after using ReadPixelFast
|
|
<br />
|
|
UnlockBuffer
|
|
<br />
|
|
|
|
<br />
|
|
Cls
|
|
<br />
|
|
Locate 0,0
|
|
<br />
|
|
Print "Press a key to write pixels"
|
|
<br />
|
|
Print "Once this has finished, you can then press a key to end the program"
|
|
<br />
|
|
|
|
<br />
|
|
WaitKey()
|
|
<br />
|
|
|
|
<br />
|
|
; Lock buffer before using WritePixelFast
|
|
<br />
|
|
LockBuffer
|
|
<br />
|
|
|
|
<br />
|
|
; Use WritePixel to redraw the screen using the color information we got earlier
|
|
<br />
|
|
For y=0 To GraphicsHeight()
|
|
<br />
|
|
For x=0 To GraphicsWidth()
|
|
<br />
|
|
WritePixelFast x,y,pix(x,GraphicsHeight()-y) ; get y array value in backwards order, to flip screen
|
|
<br />
|
|
Next
|
|
<br />
|
|
Next
|
|
<br />
|
|
|
|
<br />
|
|
; Unlock buffer after using WritePixelFast
|
|
<br />
|
|
UnlockBuffer
|
|
<br />
|
|
|
|
<br />
|
|
WaitKey()
|
|
<br />
|
|
|
|
</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=WritePixelFast&ref=comments target=_blank>here</a> to view the latest version of this page online</body>
|
|
</html>
|