[英]Allegro 5 how to draw a scaled bitmap region
我的allegro 5游戲需要繪制一個tilesheet的區域,然后我使用al_draw_bitmap_region
,但是現在我添加了更改屏幕分辨率的功能,所以現在我還需要縮放該位圖,但是allegro 5沒有al_draw_scaled_bitmap_region之類的東西, al_draw_bitmap_region and
al_draw_scaled_bitmap`,但不能同時使用。 有人可以幫助我如何同時使用兩者?
沒有al_draw_scaled_bitmap_region
,但是有al_draw_tinted_scaled_rotated_bitmap_region
。 您可以將“默認”值傳遞給不需要的參數。
al_draw_tinted_scaled_rotated_bitmap_region(
bitmap,
sx, sy, sw, sh, // source bitmap region
al_map_rgb(1, 1, 1), // color, just use white if you don't want a tint
cx, cy, // center of rotation/scaling
float dx, float dy, // destination
xscale, yscale, // scale
0, 0)); // angle and flags
您還可以使用變換來縮放位圖:
ALLEGRO_TRANSFORM trans, prevTrans;
// back up the current transform
al_copy_transform(&prevTrans, al_get_current_transform());
// scale using the new transform
al_identity_transform(&trans);
al_scale_transform(&trans, xscale, yscale);
al_use_transform(&trans);
al_draw_bitmap_region(*bitmap, sx, sy, sw, sh, dx, dy, 0));
// restore the old transform
al_use_transform(&prevTrans);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.