easy drawing in color images

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

easy drawing in color images

leo durosemont
Those of you who (just like me) do not always feel at ease with bit operations, will be able to use this custom setRGBPixel() macro function. It accepts x,y and R,G and B arguments that are converted to a 24 bit word needed by the setPixel(x,y,value) base function to set pixel value in RGB images.
 
Leo.
 
newImage("demo", "RGB", 256, 256, 1);
for (x=0; x<256; x++) {
 for (y=0; y<256; y++) {
  setRGBPixel(x,y,x,y,128);
 }
}
function setRGBPixel (x,y,r,g,b) {
setPixel(x,y,(r&0xff<<16+g&0xff<<8+b&0xff));
}

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com