getPixels <bitmap> <coord_point2> <num_pixels>
Retrieve a sequence of pixels from a row in the bitmap as an array of color values. The coord_point2 argument specifies the starting pixel coordinate with [0,0] at the top-left-hand pixel. The .x component of the Point2 coordinate is the column, and the .y component is the row. The sequence must come from one row only; you cannot retrieve a sequence of pixels that spans multiple rows. Using any out of-bounds coordinates or retrieving over row boundaries will fail and yield an empty array.
setPixels <bitmap> <coord_point2> <color_value_array>
Sets the sequence of pixels in a row in the bitmap starting at the Point2 coordinate to the values in the given array. The .x component of the Point2 coordinate is the column, and the .y component is the row. The number of pixels to set is taken from the size of the array. As with getPixels(), you cannot set pixel sequences across a row boundary.
Exaple:
===================================================
(
b=selectbitmap() -- open image file browser
bname="bitmap_"+(getfilenamefile b.filename) -- build name from filename
w=b.width -- get properties of bitmap
h=b.height
format "----------\nfn load_% = (\n" bname -- start defining function
format "local %=bitmap % %\n" bname w h -- create bitmap in function
-- write out a function that unpacks an integer into a pixel color
format "fn unpack val = for p in val collect (r=p/256^2; g=p/256-r*256; b=mod p 256; color r g b)\n"
for r=0 to h-1 do -- for each row in the bitmap
-- have function write the column of pixels to the bitmap
( format "setpixels % [0,%] (unpack #(" bname r
pixels=getpixels b [0,r] w -- read in the column of pixels
for c=1 to w do -- loop through each pixel
( p=pixels[c] -- get the pixel
-- pack the pixel into an integer and write it out
format "%" (((p.r as integer)*256+(p.g as integer))*256+(p.b as integer))
if c != w then -- if not at end of data
format ", " -- write a comma
else
format "))\n" -- else close out the line
)
)
format "return %\n" bname -- function returns the bitmap
format ")\n----------\n" -- finish off function definition
)
>И как можно написать инструменты рисования на битмапе
Теоритически наверно это возможно сделать но скрипт не предназначен
для такой работы по этому будет много гимора - функции для работы с мышю
в основном предназначены для работы в окнах проекции
если ты собрался написать скрипт для рисования по обьктам
то лутьше возми один из плугинов на эту тему
GHOSTPAINTER
или
http://www.max3dstuff.com/max5/3dPainterPrototype/help.html