2020-09-21 18:43:37 +03:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <stddef.h>
|
2020-10-01 02:08:08 +03:00
|
|
|
#include <lib/config.h>
|
2022-08-27 00:44:47 +03:00
|
|
|
#include <lib/misc.h>
|
2020-10-01 02:08:08 +03:00
|
|
|
#include <mm/pmm.h>
|
2020-09-21 18:43:37 +03:00
|
|
|
#include <lib/bmp.h>
|
|
|
|
|
2021-04-09 02:26:39 +03:00
|
|
|
void image_make_centered(struct image *image, int frame_x_size, int frame_y_size, uint32_t back_colour) {
|
|
|
|
image->type = IMAGE_CENTERED;
|
|
|
|
|
|
|
|
image->x_displacement = frame_x_size / 2 - image->x_size / 2;
|
|
|
|
image->y_displacement = frame_y_size / 2 - image->y_size / 2;
|
|
|
|
image->back_colour = back_colour;
|
|
|
|
}
|
|
|
|
|
2021-07-07 03:46:40 +03:00
|
|
|
|
|
|
|
void image_make_stretched(struct image *image, int new_x_size, int new_y_size) {
|
|
|
|
image->type = IMAGE_STRETCHED;
|
|
|
|
|
|
|
|
image->x_size = new_x_size;
|
|
|
|
image->y_size = new_y_size;
|
|
|
|
}
|
|
|
|
|
2021-10-21 03:37:05 +03:00
|
|
|
struct image *image_open(struct file_handle *file) {
|
|
|
|
struct image *image = ext_mem_alloc(sizeof(struct image));
|
2020-09-21 18:43:37 +03:00
|
|
|
|
2021-04-09 02:26:39 +03:00
|
|
|
image->type = IMAGE_TILED;
|
|
|
|
|
2021-10-21 03:37:05 +03:00
|
|
|
if (bmp_open_image(image, file))
|
|
|
|
return image;
|
|
|
|
|
|
|
|
pmm_free(image, sizeof(struct image));
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void image_close(struct image *image) {
|
|
|
|
pmm_free(image->img, image->allocated_size);
|
|
|
|
pmm_free(image, sizeof(struct image));
|
2020-09-21 18:43:37 +03:00
|
|
|
}
|