Hi again:
I have a question about saving bitmaps. I can save the backbuffer
with no problem. My question is how to save just the bitmap without
saving the complete backbuffer?
temp_image = al_create_bitmap(screen_width, working_screen_height);
al_set_target_bitmap(temp_image);
al_draw_bitmap(al_get_backbuffer(display), 0, 0, 0);
al_save_bitmap("sample.png", temp_image);
al_destroy_bitmap(temp_image);
This will save the complete backbuffer
Thanks for your time!
Hi Scooter.
The answer is relatvely simple. Just pass a different bitmap pointer to al_save_bitmap.
edit
Maybe I'm misunderstanding you. Use a smaller bitmap and draw a bitmap region instead of a bitmap.
Hi Edgar:
Thanks for the tip. It seems my problem stems from the fact that
I do not know how to get the width and height of the rotated bitmap.
After rotation I use al_get bitmap_width and al_get_bitmap_height and
it returns the width and height of the original bitmap, not the rotated
one. If you could give me a hint on this I believe I could figure the
rest out on my own.
Thanks!
The concept of saving a rotated bitmap doesn’t really make much sense, all bitmaps are square/rectangle. You could either save a square, which has a height and width of the biggest original w/h (ie, a 320x240 bitmap would be saved as 320x320), or you could add some logic to determine the minimum rectangle size required based on rotation…
To get the rotated width and height you need a little trigonometry. I'll write it out when I get home.
Hi Edgar:
After seeing your reply, I know exactly what to do:
I know the 4 corners of the image before rotating. I
can rotate the 4 corners for the new positions. If I
take the 2 extremes I will know the width and height.
Very good! Thanks for the tip!