mirror of
https://github.com/libretro/retroluxury.git
synced 2024-11-23 07:39:47 +00:00
rl_image_create now requires a pre-allocated rl_image_t
This commit is contained in:
parent
636ec2a9a5
commit
3a8db2f439
@ -17,40 +17,34 @@ void rl_image_translate( int x, int y )
|
||||
tslt_y = y;
|
||||
}
|
||||
|
||||
const rl_image_t* rl_image_create( const rl_imagedata_t* imagedata, int check_transp, uint16_t transparent )
|
||||
int rl_image_create( rl_image_t* image, const rl_imagedata_t* imagedata, int check_transp, uint16_t transparent )
|
||||
{
|
||||
size_t size;
|
||||
const void* data = rl_imagedata_rle_encode( &size, imagedata, check_transp, transparent );
|
||||
|
||||
if ( data )
|
||||
{
|
||||
rl_image_t* image = (rl_image_t*)rl_malloc( sizeof( rl_image_t ) );
|
||||
|
||||
if ( image )
|
||||
union
|
||||
{
|
||||
union
|
||||
{
|
||||
const void* v;
|
||||
const uint8_t* u8;
|
||||
const uint16_t* u16;
|
||||
const uint32_t* u32;
|
||||
}
|
||||
ptr;
|
||||
|
||||
image->rle = ptr.v = data;
|
||||
|
||||
image->width = *ptr.u16++;
|
||||
image->height = *ptr.u16++;
|
||||
image->used = *ptr.u32++;
|
||||
image->data = ptr.u8;
|
||||
|
||||
return image;
|
||||
const void* v;
|
||||
const uint8_t* u8;
|
||||
const uint16_t* u16;
|
||||
const uint32_t* u32;
|
||||
}
|
||||
ptr;
|
||||
|
||||
rl_free( (void*)data );
|
||||
image->rle = ptr.v = data;
|
||||
|
||||
image->width = *ptr.u16++;
|
||||
image->height = *ptr.u16++;
|
||||
image->used = *ptr.u32++;
|
||||
image->data = ptr.u8;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
rl_free( (void*)data );
|
||||
return -1;
|
||||
}
|
||||
|
||||
void rl_image_blit_nobg( const rl_image_t* image, int x, int y )
|
||||
|
@ -5,7 +5,6 @@
|
||||
#include <rl_imgdata.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
/*
|
||||
An image with RLE-encoded pixels and per-pixel alpha of 0, 25, 50, 75 and 100%.
|
||||
@ -35,15 +34,15 @@ void rl_image_init( void );
|
||||
void rl_image_translate( int x, int y );
|
||||
|
||||
/* Creates an image from a rl_imagedata_t. */
|
||||
const rl_image_t* rl_image_create( const rl_imagedata_t* imagedata, int check_transp, uint16_t transparent );
|
||||
int rl_image_create( rl_image_t* image, const rl_imagedata_t* imagedata, int check_transp, uint16_t transparent );
|
||||
/* Destroys an image. */
|
||||
#define rl_image_destroy( image ) do { rl_free( (void*)image->rle ); rl_free( (void*)image ); } while ( 0 )
|
||||
#define rl_image_destroy( image ) do { rl_free( (void*)image->rle ); } while ( 0 )
|
||||
|
||||
/* Blits an image to the given background. */
|
||||
void rl_image_blit_nobg( const rl_image_t* image, int x, int y );
|
||||
void rl_image_blit_nobg( const rl_image_t* image, int x, int y );
|
||||
/* Blits an image to the given background, saving overwritten pixels in bg. */
|
||||
uint16_t* rl_image_blit( const rl_image_t* image, int x, int y, uint16_t* bg );
|
||||
/* Erases an image from the given background, restoring overwritten pixels from bg. */
|
||||
void rl_image_unblit( const rl_image_t* image, int x, int y, const uint16_t* bg );
|
||||
void rl_image_unblit( const rl_image_t* image, int x, int y, const uint16_t* bg );
|
||||
|
||||
#endif /* RL_IMAGE_H */
|
||||
|
Loading…
Reference in New Issue
Block a user