BitMap.Pixel(b, i, j, Color, alpha) sets the color of one pixel of the BitMap object b, the pixel in column i and row j. Columns are counted from 1 at the left, rows from 1 at the top. The bitmap is changed; the function returns nothing.
None; the pixel of b is changed.
A bitmap of 3 by 2 pixels with three colored pixels. The script prints the colors row by row from the top, as Graphics.ToTable gives them for a page with the bitmap on it.
-- a bitmap of 3 by 2 pixels, opaque white b = BitMap.New(3, 2) BitMap.Pixel(b, 1, 1, 0xFF0000) -- column 1, row 1: the top left pixel, red BitMap.Pixel(b, 3, 1, 0x80FF0000) -- the top right pixel, half transparent red BitMap.Pixel(b, 3, 2, 0x0000FF, 128) -- the bottom right pixel, blue, half transparent by the opacity 128 -- the pixels, row by row from the top, as they are on a page P = Graphics.ToTable(Graphics.Add(Graphics.New(), b)).BitMap[1].Pixels for j = 1, 2 do local row = "" for i = 1, 3 do row = row.." 0x"..string.sub(P, 8*(3*(j-1)+i)-7, 8*(3*(j-1)+i)) end print("row "..j..":"..row) end -- a column or row outside the bitmap is an error print(pcall(BitMap.Pixel, b, 4, 1, 0x000000))
row 1: 0x00FF0000 0x00FFFFFF 0x80FF0000 row 2: 0x00FFFFFF 0x00FFFFFF 0x7F0000FF false Error: can not index column 4 from 3 available
See the example on the BitMap page for a picture made pixel by pixel.