Misu

Last Login:
May 16, 2017
Warn:

Rank:
Member



User Profile
Follow

Hits: 2,099
Joined September 19, 2012


buffer_getpixel for Game Maker Studio
Posted on May 09, 2017 at 14:09

Are you a game maker user?
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:
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)


LINK:
https://marketplace.yoyogames.com/assets/5344/buffer_getpixel

Try it out if you like and give feedback.
Any problems, doubts, questions, do reply back if you like!




Been 3 years already...
Posted on May 08, 2017 at 09:06

Hello everyone. I havent been in this website for like more than 3 years already. I have been through terrible phase the last time I was on. I never really was bright or any of a good person but I finally came back after leaving college, dumping out everything from the past, and doing some good deeds and progress with Game Maker and the community. I dont really have much to say but Im actually back at this place to make good use of it for sharing anything new I make. I work alone now (in case you have remembered me).

Anyway cant wait to hear from you all. :)



Prev Page | Next Page

Recent Activity
 
Active Users (0)