WritePixel.htm 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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>WritePixel x,y,argb,[buffer]</h1>
  8. <h1>Parameters</h1>
  9. <table>
  10. <tr>
  11. <td>
  12. x - y-coordinate of pixel <br />
  13. y - y-coordinate of pixel <br />
  14. argb - argb colour value of pixel (alpha, red, green, blue) <br />
  15. buffer (optional) - name of buffer to write colour value to, e.g. BackBuffer()
  16. </td>
  17. </tr>
  18. </table>
  19. <h1>Description</h1>
  20. <table>
  21. <tr>
  22. <td>
  23. Writes a color value to either the current buffer or the specified buffer. <br />
  24. <br />
  25. You can use this command on a locked buffer for a slight speed-up.
  26. <br>
  27. <br>
  28. See also: <a class=small href=Plot.htm>Plot</a>, <a class=small href=WritePixelFast.htm>WritePixelFast</a>, <a class=small href=LockBuffer.htm>LockBuffer</a>.
  29. </td>
  30. </tr>
  31. </table>
  32. <h1><a href=../2d_examples/WritePixel.bb>Example</a></h1>
  33. <table>
  34. <tr>
  35. <td>
  36. ; ReadPixel/WritePixel Example <br />
  37. ; ---------------------------- <br />
  38. <br />
  39. Graphics 640,480,16 <br />
  40. <br />
  41. Print "Press a key to read color values (this may take a few seconds)" <br />
  42. WaitKey() <br />
  43. <br />
  44. ; Load and draw an image on to the screen - can be anything <br />
  45. pic=LoadImage("media/blitz_pic.bmp") <br />
  46. DrawImage pic,0,0 <br />
  47. <br />
  48. ; Initialise an array big enough to fit all the color information of the screen <br />
  49. Dim pix(GraphicsWidth(),GraphicsHeight()) <br />
  50. <br />
  51. ; Use ReadPixel to get all the color information of the screen <br />
  52. For y=0 To GraphicsHeight() <br />
  53. For x=0 To GraphicsWidth() <br />
  54. pix(x,y)=ReadPixel(x,y) <br />
  55. Next <br />
  56. Next <br />
  57. <br />
  58. Cls <br />
  59. Locate 0,0 <br />
  60. Print "Press a key to write pixels (this may takes a few seconds)" <br />
  61. Print "Once this has finished, you can then press a key to end the program" <br />
  62. <br />
  63. WaitKey() <br />
  64. <br />
  65. ; Use WritePixel to redraw the screen using the color information we got earlier <br />
  66. For y=0 To GraphicsHeight() <br />
  67. For x=0 To GraphicsWidth() <br />
  68. WritePixel x,y,pix(x,GraphicsHeight()-y) ; get y array value in backwards order, to flip screen <br />
  69. Next <br />
  70. Next <br />
  71. <br />
  72. WaitKey()
  73. </td>
  74. </tr>
  75. </table>
  76. <br>
  77. <a target=_top href=../index.htm>Index</a><br>
  78. <br>
  79. Click <a href=http://www.blitzbasic.co.nz/b3ddocs/command.php?name=WritePixel&ref=comments target=_blank>here</a> to view the latest version of this page online</body>
  80. </html>