听起来您想要一种在 allegro 中缩放图像的方法。有两种方法可以实现这一点:
- 使用
al_draw_tinted_scaled_rotated_bitmap_region。将您的比例因子(例如2.0)作为xscale 和yscale 参数传递。
void al_draw_tinted_scaled_rotated_bitmap_region(ALLEGRO_BITMAP *bitmap,
0, 0, 32, 32, // draw the first 32x32 sprite in the sheet
al_map_rgb(255, 255, 255), // don't tint the sprite
16, 16, // the origin is 16, 16, half the 32x32 size
200, 200, // draw at the point 200, 200 on the display
2.0, 2.0, // scale by 2 in the x and y directions
0, 0); // don't apply any angle or flags
- 使用transform 缩放您的图像。
ALLEGRO_TRANSFORM trans;
al_identity_transform(&trans);
al_scale_transform(&trans, 2, 2); // scale by a factor of 2
al_use_transform(&trans);
// draw here
请注意,在任何情况下(包括缩放 spritesheet 的原始解决方案),放大图像都会使其看起来更加像素化。