{{indexmenu_n>999}} ====== Pixel ====== ### //BitMap.Pixel(b, i, j, Color, alpha)// sets the color of one pixel of the [[documentation:language_reference:objects:bitmap:start|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. ### ===== Input ===== * //b// : a BitMap object. * //i// : Integer, the column, from 1 (left) to the width of the bitmap. * //j// : Integer, the row, from 1 (top) to the height of the bitmap. * //Color// : 32 bit integer 0xAARRGGBB, the color of the pixel, //AA// the transparency (00 opaque). * //alpha// : (optional) Integer from 0 to 255, the opacity, on top of the transparency of //Color//: 255 keeps the color as it is, 128 makes an opaque color half transparent and 0 fully transparent. Default value 255 ===== Output ===== ### None; the pixel of //b// is changed. ### ===== Example ===== ### 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. ### ==== Input ==== -- 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)) ==== Result ==== 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 [[documentation:language_reference:objects:bitmap:start|BitMap]] page for a picture made pixel by pixel. ### ===== Table of contents ===== {{indexmenu>../#2|tsort}}