[AD] clipping, sub bitmaps

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


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




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/