M
Misu
Guest
Get buffer_getpixel at the marketplace!
Need a faster surface_getpixel? You come to the right place!
This asset comes with a small list of scripts that will help you get a pixel color super fast and its totally free.
How to use each command:
buffer_getpixel_begin(surface) = creates the buffer for checking using a specified surface id
(or surface drawing) and returns you a buffer index.
(NOTE: application_surface only picks the regular Draw events;
not the GUI events.)
If your surface image is static, you can set it to create event,
otherwise, set it in the event that you will get the pixel.
buffer_getpixel(ind,x,y,width,height) = Gets the RGB of a pixel within the specified buffer id (surface).
buffer_getpixel_ext(ind,x,y,width,height) = Gets the RGBA of a pixel within the specified buffer id.
buffer_getpixel_r(ind x,y,width,height) = Gets the Red value of a pixel
buffer_getpixel_g(ind x,y,width,height) = Gets the Green value of a pixel
buffer_getpixel_b(ind x,y,width,height) = Gets the Blue value of a pixel
buffer_getpixel_a(ind x,y,width,height) = Gets the Alpha value of a pixel
//////////////////////////////////////////////////////////////////////////////
The file comes with the scripts and a demonstration of how it works (for dynamic images);
In case your image does not need to update the drawing at all, here's an example on how it works for static images (performance is more noticeable from this):
Code:
//CREATE EVENT
var ss = surface_create(800,450);
surface_set_target(ss);
draw_clear(0)
draw_sprite(spr_0,0,x,y)
surface_reset_target()
WIDE = surface_get_width(ss);
HIGH = surface_get_height(ss);
buff = buffer_getpixel_begin(ss);
/////////////////////////////////////////////////////////////////////////////
//DRAW EVENT (or any other event)
var pixel = buffer_getpixel(buff,16,16,WIDE,HIGH);
draw_text(64,8,string(pixel));
/////////////////////////////////////////////////////////////////////////////
//GAME END EVENT
buffer_getpixel_end(buff)
Any problems, doubts, questions, do reply back if you like!
Last edited: