Skip to content

Commit 967a972

Browse files
committed
Update to v5.0.0
1 parent 81924be commit 967a972

File tree

5 files changed

+40
-11
lines changed

5 files changed

+40
-11
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cmake_minimum_required(VERSION 3.11)
22
project (raylib_aseprite
3-
VERSION 4.5.0
3+
VERSION 5.0.0
44
DESCRIPTION "raylib_aseprite: Use Aseprite files in raylib"
55
HOMEPAGE_URL "https://github.com/robloach/raylib-aseprite"
66
LANGUAGES C)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ See the [examples directory](examples) for more demonstrations of how to use *ra
7171
``` c
7272
// Aseprite functions
7373
Aseprite LoadAseprite(const char* fileName); // Load an .aseprite file
74-
Aseprite LoadAsepriteFromMemory(unsigned char* fileData, unsigned int size); // Load an aseprite file from memory
74+
Aseprite LoadAsepriteFromMemory(unsigned char* fileData, int size); // Load an aseprite file from memory
7575
bool IsAsepriteReady(Aseprite aseprite); // Check if the given Aseprite was loaded successfully
7676
void UnloadAseprite(Aseprite aseprite); // Unloads the aseprite file
7777
void TraceAseprite(Aseprite aseprite); // Display all information associated with the aseprite

examples/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ if (NOT raylib_FOUND)
55
FetchContent_Declare(
66
raylib
77
GIT_REPOSITORY https://github.com/raysan5/raylib.git
8-
GIT_TAG 4.5.0
8+
GIT_TAG 5.0
99
)
1010
FetchContent_GetProperties(raylib)
1111
if (NOT raylib_POPULATED) # Have we downloaded raylib yet?

include/cute_aseprite.h

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Licensing information can be found at the end of the file.
44
------------------------------------------------------------------------------
55
6-
cute_aseprite.h - v1.02
6+
cute_aseprite.h - v1.04
77
88
To create implementation (the function definitions)
99
#define CUTE_ASEPRITE_IMPLEMENTATION
@@ -45,6 +45,8 @@
4545
1.01 (08/31/2020) fixed memleaks, tag parsing bug (crash), blend bugs
4646
1.02 (02/05/2022) fixed icc profile parse bug, support transparent pal-
4747
ette index, can parse 1.3 files (no tileset support)
48+
1.03 (11/27/2023) fixed slice pivot parse bug
49+
1.04 (02/20/2024) chunck 0x0004 support
4850
*/
4951

5052
/*
@@ -212,6 +214,7 @@ struct ase_tag_t
212214
int from_frame;
213215
int to_frame;
214216
ase_animation_direction_t loop_animation_direction;
217+
int repeat;
215218
uint8_t r, g, b;
216219
const char* name;
217220
ase_udata_t udata;
@@ -991,6 +994,30 @@ ase_t* cute_aseprite_load_from_memory(const void* memory, int size, void* mem_ct
991994
uint8_t* chunk_start = s->in;
992995

993996
switch (chunk_type) {
997+
case 0x0004: // Old Palette chunk (used when there are no colors with alpha in the palette)
998+
{
999+
int nbPackets = (int)s_read_uint16(s);
1000+
for (int k = 0; k < nbPackets ; k++ ) {
1001+
uint16_t maxColor=0;
1002+
uint8_t skip = s_read_uint8(s);
1003+
uint16_t nbColors = s_read_uint8(s);
1004+
if (nbColors == 0) nbColors = 256;
1005+
1006+
for (int l = 0; l < nbColors; l++) {
1007+
ase_palette_entry_t entry;
1008+
entry.color.r = s_read_uint8(s);
1009+
entry.color.g = s_read_uint8(s);
1010+
entry.color.b = s_read_uint8(s);
1011+
entry.color.a = 255;
1012+
entry.color_name = NULL;
1013+
ase->palette.entries[skip+l] = entry;
1014+
if (skip+l > maxColor) maxColor = skip+l;
1015+
}
1016+
1017+
ase->palette.entry_count = maxColor+1;
1018+
}
1019+
1020+
} break;
9941021
case 0x2004: // Layer chunk.
9951022
{
9961023
CUTE_ASEPRITE_ASSERT(ase->layer_count < CUTE_ASEPRITE_MAX_LAYERS);
@@ -1099,7 +1126,8 @@ ase_t* cute_aseprite_load_from_memory(const void* memory, int size, void* mem_ct
10991126
tag.from_frame = (int)s_read_uint16(s);
11001127
tag.to_frame = (int)s_read_uint16(s);
11011128
tag.loop_animation_direction = (ase_animation_direction_t)s_read_uint8(s);
1102-
s_skip(s, 8); // For future (set to zero).
1129+
tag.repeat = s_read_uint16(s);
1130+
s_skip(s, 6); // For future (set to zero).
11031131
tag.r = s_read_uint8(s);
11041132
tag.g = s_read_uint8(s);
11051133
tag.b = s_read_uint8(s);
@@ -1176,7 +1204,8 @@ ase_t* cute_aseprite_load_from_memory(const void* memory, int size, void* mem_ct
11761204
slice.center_y = (int)s_read_int32(s);
11771205
slice.center_w = (int)s_read_uint32(s);
11781206
slice.center_h = (int)s_read_uint32(s);
1179-
} else if (flags & 2) {
1207+
}
1208+
if (flags & 2) {
11801209
// Has pivot information.
11811210
slice.has_pivot = 1;
11821211
slice.pivot_x = (int)s_read_int32(s);

include/raylib-aseprite.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Copyright 2021 Rob Loach (@RobLoach)
66
*
77
* DEPENDENCIES:
8-
* raylib 4.2+ https://www.raylib.com/
8+
* raylib 5.0+ https://www.raylib.com/
99
*
1010
* LICENSE: zlib/libpng
1111
*
@@ -44,7 +44,7 @@ typedef struct AsepriteSlice AsepriteSlice; // A slice i
4444

4545
// Aseprite functions
4646
Aseprite LoadAseprite(const char* fileName); // Load an .aseprite file
47-
Aseprite LoadAsepriteFromMemory(unsigned char* fileData, unsigned int size); // Load an aseprite file from memory
47+
Aseprite LoadAsepriteFromMemory(unsigned char* fileData, int size); // Load an aseprite file from memory
4848
bool IsAsepriteReady(Aseprite aseprite); // Check if the given Aseprite was loaded successfully
4949
void UnloadAseprite(Aseprite aseprite); // Unloads the aseprite file
5050
void TraceAseprite(Aseprite aseprite); // Display all information associated with the aseprite
@@ -100,7 +100,7 @@ extern "C" {
100100

101101
#define CUTE_ASEPRITE_ASSERT(condition) do { if (!(condition)) { TraceLog(LOG_WARNING, "ASEPRITE: Failed assert \"%s\" in %s:%i", #condition, __FILE__, __LINE__); } } while(0)
102102

103-
#define CUTE_ASEPRITE_ALLOC(size, ctx) MemAlloc((int)(size))
103+
#define CUTE_ASEPRITE_ALLOC(size, ctx) MemAlloc((unsigned int)(size))
104104
#define CUTE_ASEPRITE_FREE(mem, ctx) MemFree((void*)(mem))
105105

106106
#define CUTE_ASEPRITE_SEEK_SET 0
@@ -163,7 +163,7 @@ struct AsepriteSlice {
163163
* @see UnloadAseprite()
164164
* @see LoadAseprite()
165165
*/
166-
Aseprite LoadAsepriteFromMemory(unsigned char* fileData, unsigned int size) {
166+
Aseprite LoadAsepriteFromMemory(unsigned char* fileData, int size) {
167167
struct Aseprite aseprite;
168168
aseprite.ase = 0;
169169

@@ -240,7 +240,7 @@ Aseprite LoadAsepriteFromMemory(unsigned char* fileData, unsigned int size) {
240240
* @see IsAsepriteReady()
241241
*/
242242
Aseprite LoadAseprite(const char* fileName) {
243-
unsigned int bytesRead;
243+
int bytesRead;
244244
unsigned char* fileData = LoadFileData(fileName, &bytesRead);
245245
if (bytesRead == 0 || fileData == 0) {
246246
TraceLog(LOG_ERROR, "ASEPRITE: Failed to load aseprite file \"%s\"", fileName);

0 commit comments

Comments
 (0)