[AD] clipping, sub bitmaps |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
- To: "Coordination of admins/developers of the game programming library Allegro" <alleg-developers@xxxxxxxxxx>
- Subject: [AD] clipping, sub bitmaps
- From: Matthew Leverton <meffer@xxxxxxxxxx>
- Date: Fri, 7 Aug 2009 22:22:17 -0500
The A4 documentation for create_sub_bitmap reads: "... the origin
point must lie within the parent region."
It seems like A4.9 has the same restrictions. Is there any way in 4.9
to create a clipped, translated drawing area with an origin outside
the target bitmap?
e.g., To create a 32x32 clipped virtual bitmap, where the bottom-right
16x16 pixels would lie in the top-left 16x16 pixels of the target
bitmap, and the rest would be off-bitmap:
al_set_translation(-16, -16);
al_set_clipping_rectangle(0, 0, 16, 16); // if in relation to the
real, untranslated coordinates
al_set_target_bitmap(parent);
al_draw_filled_rectangle(0, 0, 15, 15, white, 1); // actually drawn
off bitmap to (-16,-16, -1,-1)
al_draw_filled_rectangle(16, 16, 31, 31, black, 1); // drawn to
top-left 16x16 of bitmap
or:
child = al_create_sub_bitmap(parent, -16, -16, 32, 32);
al_set_target_bitmap(child);
al_draw_filled_rectangle(0, 0, 15, 15, white, 1); // actually drawn
off bitmap to (-16,-16, -1,-1)
al_draw_filled_rectangle(16, 16, 31, 31, black, 1); // drawn to
top-left 16x16 of bitmap
--
Matthew Leverton