All pastes #743704 Raw Edit

Someone

public text v1 · immutable
·published 2007-10-20 18:00 UTC
rendered paste body
   /* Make a translucent copy of the ship */
   ALLEGRO_BITMAP *old_target = al_get_target_bitmap();
   al_set_target_bitmap(trans_bitmap);
   int bitmap_format = al_get_bitmap_format(bitmap);
   int trans_format = al_get_bitmap_format(trans_bitmap);
   for (int py = 0; py < al_get_bitmap_height(bitmap); py++) {
      for (int px = 0; px < al_get_bitmap_height(bitmap); px++) {
         ALLEGRO_COLOR color;
         al_get_pixel(bitmap, px, py, &color);
         unsigned char r, g, b, a;
         al_unmap_rgba_ex(bitmap_format, &color, &r, &g, &b, &a);
         al_set_target_bitmap(trans_bitmap);
         if (a != 0) {
            a = 160;
            al_map_rgba_ex(trans_format, &color, r, g, b, a);
         }
         al_put_pixel(px, py, &color);
      }
   }
   al_set_target_bitmap(old_target);