|
Cropping a Bitmap (Allegro 5) |
Henrique Rocha
Member #13,042
July 2011
|
Hello again, I am having troubles with cropping a bitmap #define MAGENTA al_map_rgb(255,0,255) void crop_bmp(ALLEGRO_BITMAP ** bmp, int ix, int iy, int fx , int iy){ this is the error (it's in Portuguese): What is wrong? I don't want to create a sub bitmap. Just making a new one but shorter. Thanks
|
Arthur Kalliokoski
Second in Command
February 2005
|
hdlopesrocha said: void crop_bmp(ALLEGRO_BITMAP ** bmp, int ix, int iy, int fx , int iy) temp = al_create_bitmap(fx-ix, fy-iy) Where does the second line get fy from? They all watch too much MSNBC... they get ideas. |
Henrique Rocha
Member #13,042
July 2011
|
sorry It was a mistake when I was writting here, void crop_bmp(BITMAP ** bmp, int ix, int iy, int fx, int fy) the error is the same.
|
Arthur Kalliokoski
Second in Command
February 2005
|
For one thing, you don't pass the contents of a bitmap to al_draw_bitmap() and friends, you just pass the pointer. al_draw_bitmap(*bmp, -ix, -iy, 0); should be al_draw_bitmap(bmp, -ix, -iy, 0); and you're not checking return values temp = al_create_bitmap(fx-ix, fy-iy); al_set_target_bitmap(temp); should be more like temp = al_create_bitmap(fx-ix, fy-iy); if(!temp) { put some sort of error message here return 1; } al_set_target_bitmap(temp);
They all watch too much MSNBC... they get ideas. |
SiegeLord
Member #7,827
October 2006
|
Perhaps ix is greater than fx (or the same for y) and your al_create_bitmap call is failing? "For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18 |
Henrique Rocha
Member #13,042
July 2011
|
void crop_bmp(ALLEGRO_BITMAP ** bmp, int ix, int iy, int fx , int iy) al_draw_bitmap(*bmp, -ix, -iy, 0); The strange is that with allegro 4.2.2 works great. 1void crop_bmp(BITMAP ** bmp, int ix, int iy, int fx , int fy){
2 BITMAP * temp;
3
4 temp = create_bitmap(fx-ix, fy-iy);
5 clear_to_color(temp, MAGENTA);
6
7 draw_sprite(temp,*bmp,-ix,-iy);
8
9 destroy_bitmap(*bmp);
10 *bmp = temp;
11}
But I am trying to convert it for allegro 5. PS: Sorry problem is not here. pixel = al_get_pixel(bmp,x,y); The bitmap is MAGENTA but that printf is always I am using getpixel to calculate ix and fx PS: Problem solved! Thanks for your support
|
|