SetPixel

Bitmaps
Aptilis 1

SetPixel(BitmapHandle, x, y, Colour)

SetPixel is the most basic graphic instruction that allows you to set a single pixel (or point) in a previously created bitmap.
You indicate a colour by its index, which you get from functions like RGB or hexColor or you can pick an index and define its colour value with SetColor.

Return Value:
0 if everything was OK or -1 if you indicated a non-valid bitmap.

Example:

b = createBitmap(250, 250)
if b = -1
print("Oops, it was impossible to create a bitmap...\n")
else

white = RGB(255, 255, 255)
black = RGB(0, 0, 0)

clearBitmap(b, white)

box(b, 25, 25, 225, 225, black, 0)

// Random points: random position, random colours
for i=0 to 400

setPixel(b, 26 + random(198), 26 + random(198), random(255))

end for

saveGifFile("points.gif", b)

deleteBitmap(b)
end if
Result:

For more details see the Bitmap topic.