CopyPixelFast.htm 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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>CopyPixelFast src_x,src_y,src_buffer,dest_x,dest_y,[dest_buffer]</h1>
  8. <h1>Parameters</h1>
  9. <table>
  10. <tr>
  11. <td>
  12. src_x - x-coordinate of source pixel to copy from <br />
  13. src_y - y-coordinate of source pixel to copy from <br />
  14. src_buffer - name of buffer to copy from, e.g. ImageBuffer() <br />
  15. dest_x - x-coordinate of destination pixel to copy to <br />
  16. dest_y - y-coordinate of destination pixel to copy to <br />
  17. dest_buffer (optional) - name of buffer to copy to, e.g. BackBuffer()
  18. </td>
  19. </tr>
  20. </table>
  21. <h1>Description</h1>
  22. <table>
  23. <tr>
  24. <td>
  25. IMPORTANT: <br />
  26. <br />
  27. You *must* use this command on a locked buffer, otherwise the command will fail. See LockBuffer. <br />
  28. <br />
  29. Also, you must make sure that the coordinates that you are copying from and to are valid, otherwise you will end up overwriting other areas of memory. <br />
  30. <br />
  31. WARNING: <br />
  32. <br />
  33. By not following the above advice, you may cause your computer to crash. <br />
  34. <br />
  35. See also: CopyPixel.
  36. </td>
  37. </tr>
  38. </table>
  39. <h1><a href=../2d_examples/CopyPixelFast.bb>Example</a></h1>
  40. <table>
  41. <tr>
  42. <td>
  43. ; CopyPixel/CopyPixelFast Example <br />
  44. ; ------------------------------- <br />
  45. <br />
  46. Graphics 640,480,16 <br />
  47. <br />
  48. Print "Press a key to use CopyPixel to copy the top half of an image to the frontbuffer" <br />
  49. WaitKey() <br />
  50. <br />
  51. ; Load an image - can be anything <br />
  52. pic=LoadImage("media/blitz_pic.bmp") <br />
  53. <br />
  54. ; Use CopyPixel to copy the top half of the image to the frontbuffer <br />
  55. For y=0 To ImageHeight(pic)/2 <br />
  56. For x=0 To ImageWidth(pic) <br />
  57. CopyPixel x,y,ImageBuffer(pic),x,y <br />
  58. Next <br />
  59. Next <br />
  60. <br />
  61. Locate 0,GraphicsHeight()/2 <br />
  62. Print "Press a key to use CopyPixelFast to copy the bottom half of the image" <br />
  63. Print "Once this has finished, you can then press a key to end the program" <br />
  64. <br />
  65. WaitKey() <br />
  66. <br />
  67. ; Lock buffer before using CopyPixelFast <br />
  68. LockBuffer <br />
  69. <br />
  70. ; Use CopyPixelFast to copy the bottom half of the image to the frontbuffer <br />
  71. For y=0 To (ImageHeight(pic)/2)+ImageHeight(pic) <br />
  72. For x=0 To ImageWidth(pic) <br />
  73. CopyPixelFast x,y,ImageBuffer(pic),x,y <br />
  74. Next <br />
  75. Next <br />
  76. <br />
  77. ; Unlock buffer after using CopyPixelFast <br />
  78. UnlockBuffer <br />
  79. <br />
  80. WaitKey()
  81. </td>
  82. </tr>
  83. </table>
  84. <br>
  85. <a target=_top href=../index.htm>Index</a><br>
  86. <br>
  87. Click <a href=http://www.blitzbasic.co.nz/b3ddocs/command.php?name=CopyPixelFast&ref=comments target=_blank>here</a> to view the latest version of this page online</body>
  88. </html>