


#include <flare_gui/image.h>




FGUIImage::FGUIImage(FGUIParent *parent, ALLEGRO_BITMAP *bitmap, float x, float y)
	: FGUIWidget(parent, new FGUICollisionBox(x, y, bitmap ? al_get_bitmap_width(bitmap) : 0, bitmap ? al_get_bitmap_height(bitmap) : 0))
	, bitmap(bitmap)
{}




void FGUIImage::on_draw()
{
	if (bitmap) al_draw_tinted_bitmap(bitmap, color, 0, 0, NULL);
}




void FGUIImage::set_bitmap(ALLEGRO_BITMAP *bitmap)
{
	this->bitmap = bitmap;
	gimmie_placement()->w = bitmap ? al_get_bitmap_width(bitmap) : 0;
	gimmie_placement()->h = bitmap ? al_get_bitmap_height(bitmap) : 0;
}



void FGUIImage::set_color(ALLEGRO_COLOR color)
{
	this->color = color;
}
