gamemaker将画布信息存入buffer

1
surface_set_target(_surf);
1
{
1
 draw_clear_alpha(c_black,0);
1
 draw_sprite(_sprite,i,0,0);
1
}
1
surface_reset_target();
1
//Find all unique colors
1
var _buff = buffer_create(_sprite_width*_sprite_height*4, buffer_fixed, 4);
1
buffer_get_surface(_buff, _surf, 0, 0, 0);
1
for(var _x=0; _x<_sprite_width; _x++)
1
{
1
 for(var _y=0; _y<_sprite_height; _y++)
1
 {
1
 var _col = buffer_read(_buff, buffer_u32);
1
 var _a = (_col >> 24) & 255;
1
 var _r = (_col >> 16) & 255;
1
 var _g = (_col >> 8) & 255;
1
 var _b = _col & 255;
1
 var _col=make_colour_rgb(_r, _g, _b);
1
 if(ds_list_find_index(_temp_colors,_col) == -1)
1
 { //First time encountering this color for this sprite.
1
 ds_list_add(_temp_colors,_col);
1
 if(ds_list_find_index(Unique_Colors,_col) == -1)
1
 { //First time across all sprites.
1
 _new_color_count++;
1
 //But don't add it yet... need to make sure it doesn't make us
1
 //Go over the limit.
1
 }
1
 }
1
 }
1
}
1
///Save Sprite
1
ds_list_add(_sprite_list,sprite_create_from_surface(_surf,0,0,_sprite_width,_sprite_height,false,false,0,0));
1
buffer_delete(_buff);
58 Views
Loading Likes...
0 回复

发表评论

Want to join the discussion?
Feel free to contribute!

发表评论

电子邮件地址不会被公开。