var bytes = surface_get_width(application_surface) * surface_get_height(application_surface) * 4;//w*h == total pixels and each pixel has 4 bytes
var buffer = buffer_create(bytes,buffer_fast,1);
buffer_get_surface(buffer,application_surface,0,0,0);
for (var i = 0; i < bytes; i+=4) {//buffer_get_surface gets pixel data in BGRA format
var blue = buffer_peek(buffer,i,buffer_u8);
var green = buffer_peek(buffer,i+1,buffer_u8);
var red = buffer_peek(buffer,i+2,buffer_u8);
var alpha = buffer_peek(buffer,i+3,buffer_u8);
}
buffer_delete(buffer);
var col=draw_getpixel(room_width/2,room_height/2);
if (col==make_colour_rgb(255,0,0) //red
{
}
if (surface_exists(application_surface)) {
color = surface_getpixel(application_surface,mouse_x,mouse_y);
}
I didn't set the application surface to anything, would that be a problem? or what changes between view in room and application surface? Is apllication surface port on screen?Well you should definitely read into both of them as they can be extremely useful. But I also just realized I over-complicated things.
You can just use surface_getpixel which is surprisingly fast
The code snippet above will return the color that the mouse is on. I did this on a 1280x720 room and was getting 1000+ fpsCode:if (surface_exists(application_surface)) { color = surface_getpixel(application_surface,mouse_x,mouse_y); }
var c = draw_getpixel(x,y);
var r = colour_get_red(c);
var g = colour_get_green(c);
var b = colour_get_blue(c);
if ( (r == 255) && (g == 255) && (b == 255) )
{
QuestionType = WennWeil;
}
if ( (r == 100) && (g == 100) && (b == 100) )
{
QuestionType = SomethingElse;
}
The application_surface is what you're seeing. It's automatically created and is the default surface being drawn too. You can use it with the surface functions the same as you would with surfaces that you created.I didn't set the application surface to anything, would that be a problem? or what changes between view in room and application surface? Is apllication surface port on screen?