mirror of
https://git.planet-casio.com/Lephenixnoir/gint.git
synced 2024-12-29 13:03:36 +01:00
image: add image_linear_alloc()
This commit is contained in:
parent
09c13676d3
commit
c2ff07427b
3 changed files with 23 additions and 0 deletions
|
@ -176,6 +176,7 @@ set(SOURCES_CG
|
||||||
src/image/image_hflip_alloc.c
|
src/image/image_hflip_alloc.c
|
||||||
src/image/image_linear.c
|
src/image/image_linear.c
|
||||||
src/image/image_linear.S
|
src/image/image_linear.S
|
||||||
|
src/image/image_linear_alloc.c
|
||||||
src/image/image_rotate.c
|
src/image/image_rotate.c
|
||||||
src/image/image_rotate_around.c
|
src/image/image_rotate_around.c
|
||||||
src/image/image_rotate_around_scale.c
|
src/image/image_rotate_around_scale.c
|
||||||
|
|
|
@ -6,6 +6,8 @@ bool image_copy_palette(image_t const *src, image_t *dst, int size)
|
||||||
{
|
{
|
||||||
if(!image_valid(src) || !dst)
|
if(!image_valid(src) || !dst)
|
||||||
return false;
|
return false;
|
||||||
|
if(!IMAGE_IS_INDEXED(dst->format))
|
||||||
|
return true;
|
||||||
|
|
||||||
if(size < 0)
|
if(size < 0)
|
||||||
size = src->color_count;
|
size = src->color_count;
|
||||||
|
|
20
src/image/image_linear_alloc.c
Normal file
20
src/image/image_linear_alloc.c
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
#include <gint/image.h>
|
||||||
|
|
||||||
|
image_t *image_linear_alloc(image_t const *src, struct image_linear_map *map)
|
||||||
|
{
|
||||||
|
if(!image_valid(src) || IMAGE_IS_P4(src->format))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
int f = IMAGE_IS_RGB16(src->format) ? IMAGE_RGB565A : IMAGE_P8_RGB565A;
|
||||||
|
image_t *dst = image_alloc(map->dst_w, map->dst_h, f);
|
||||||
|
if(!dst)
|
||||||
|
return NULL;
|
||||||
|
if(f == IMAGE_P8_RGB565A && !image_copy_palette(src, dst, -1)) {
|
||||||
|
image_free(dst);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
image_clear(dst);
|
||||||
|
image_linear(src, dst, map);
|
||||||
|
return dst;
|
||||||
|
}
|
Loading…
Reference in a new issue