mirror of
https://gitlab.com/dosowisko.net/libsuperderpy.git
synced 2025-02-01 19:16:44 +01:00
fixes for scaling performance
This commit is contained in:
parent
535f5abc94
commit
334adcf9c0
1 changed files with 7 additions and 3 deletions
10
src/main.c
10
src/main.c
|
@ -128,9 +128,11 @@ void ScaleBitmap(ALLEGRO_BITMAP* source, int width, int height, float val) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int x, y;
|
int x, y;
|
||||||
for (y = 0; y <= height; y++) {
|
al_lock_bitmap(al_get_target_bitmap(), ALLEGRO_PIXEL_FORMAT_ANY, ALLEGRO_LOCK_WRITEONLY);
|
||||||
|
al_lock_bitmap(source, ALLEGRO_PIXEL_FORMAT_ANY, ALLEGRO_LOCK_READONLY);
|
||||||
|
for (y = 0; y < height; y++) {
|
||||||
float pixy = ((float)y / height) * al_get_bitmap_height(source);
|
float pixy = ((float)y / height) * al_get_bitmap_height(source);
|
||||||
for (x = 0; x <= width; x++) {
|
for (x = 0; x < width; x++) {
|
||||||
float pixx = ((float)x / width) * al_get_bitmap_width(source);
|
float pixx = ((float)x / width) * al_get_bitmap_width(source);
|
||||||
ALLEGRO_COLOR a = al_get_pixel(source, pixx-val, pixy-val);
|
ALLEGRO_COLOR a = al_get_pixel(source, pixx-val, pixy-val);
|
||||||
ALLEGRO_COLOR b = al_get_pixel(source, pixx+val, pixy-val);
|
ALLEGRO_COLOR b = al_get_pixel(source, pixx+val, pixy-val);
|
||||||
|
@ -142,9 +144,11 @@ void ScaleBitmap(ALLEGRO_BITMAP* source, int width, int height, float val) {
|
||||||
(a.b+b.g+c.b+d.b) / 4,
|
(a.b+b.g+c.b+d.b) / 4,
|
||||||
(a.a+b.a+c.a+d.a) / 4
|
(a.a+b.a+c.a+d.a) / 4
|
||||||
);
|
);
|
||||||
al_draw_pixel(x, y, result);
|
al_put_pixel(x, y, result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
al_unlock_bitmap(al_get_target_bitmap());
|
||||||
|
al_unlock_bitmap(source);
|
||||||
}
|
}
|
||||||
|
|
||||||
ALLEGRO_BITMAP* LoadFromCache(struct Game *game, char* filename, int width, int height) {
|
ALLEGRO_BITMAP* LoadFromCache(struct Game *game, char* filename, int width, int height) {
|
||||||
|
|
Loading…
Reference in a new issue