Skip to content

cute_aseprite: continued support#421

Closed
mathewmariani wants to merge 4 commits intoRandyGaul:masterfrom
mathewmariani:master
Closed

cute_aseprite: continued support#421
mathewmariani wants to merge 4 commits intoRandyGaul:masterfrom
mathewmariani:master

Conversation

@mathewmariani
Copy link
Contributor

@mathewmariani mathewmariani commented Jan 6, 2026

This pull requests adds support for color modes grayscale and indexed color modes, as well as, support for tilesets and tilemaps

struct ase_frame_t now has a field void* pixels; instead of a ase_color_t* pixels to reflect how the specs defined a pixel. We can cast to our desired color types (struct ase_color_t, struct ase_grayscale_t, and struct ase_index) as needed.

A pixel as described in the specs:

* `PIXEL`: One pixel, depending on the image pixel format:
  - **RGBA**: `BYTE[4]`, each pixel have 4 bytes in this order Red, Green, Blue, Alpha.
  - **Grayscale**: `BYTE[2]`, each pixel have 2 bytes in the order Value, Alpha.
  - **Indexed**: `BYTE`, each pixel uses 1 byte (the index).

Because blending is not supported for indexed color the blending step is skipped for routes where ase->mode == ASE_MODE_INDEXED.

I also added support chunk 0x2023; tilesets and tilemaps through struct ase_tileset_t and struct ase_cel_tilemap_t respectively.

An example of loading and reading the pixels of a tileset:

ase_t *ase = cute_aseprite_load_from_file(path, NULL);
ase_tileset_t ase_tileset = ase->tileset;

// `struct ase_color_t`, `struct ase_grayscale_t`, or `struct ase_index`
const ase_color_t *pixels = (ase_color_t *) ase_tileset.pixels;

An example of loading and reading the tiles from a tilemap:

ase_t *ase = cute_aseprite_load_from_file(path, NULL);

for (int i = 0; i < ase->frame_count; ++i) {
  ase_frame_t *frame = ase->frames + i;
  for (int j = 0; j < frame->cel_count; ++j) {
    ase_cel_t *cel = frame->cels + j;
    if (cel->is_tilemap) {
      memcpy(tilemap, cel->tiles, size);
    }
  }
}

cute_aseprite_free(ase);

@RandyGaul
Copy link
Owner

Put your name in the docs credits somewhere!

@mathewmariani
Copy link
Contributor Author

Put your name in the docs credits somewhere!

Many thanks ! I added credits along with the date.

@RobLoach
Copy link
Contributor

I tried this out, and while I haven't dove into the root cause, I think there's a regression in how the pixels are loaded? By just replacing the old cute_aseprite with this one in pntr_aseprite, it aseprite character no longer displays.

@mathewmariani
Copy link
Contributor Author

I tried this out, and while I haven't dove into the root cause, I think there's a regression in how the pixels are loaded? By just replacing the old cute_aseprite with this one in pntr_aseprite, it aseprite character no longer displays.

Thank you @RobLoach. Ill take a look at it later this week

@RobLoach
Copy link
Contributor

Same with this one too:
https://github.com/RobLoach/raylib-aseprite

Again, I'm unsure what goes wrong with it, could likely dive deeper on it next week.

@RandyGaul
Copy link
Owner

I think to merge this in it would be much easier to separate into smaller and different PRs. Suggestion: One for tileset, one for tilemap (if it's different enough from tileset, I haven't looked and don't know), one for greyscale/indexed. It's risky to adjust code and takes a lot of time/effort to test, so smaller more atomic PR really help save me time. Otherwise I don't feel like we can merge it in as-is.

@mathewmariani
Copy link
Contributor Author

I have broken up the pull request starting with indexed and grayscale color mode #423.

@RandyGaul
Copy link
Owner

Closing this for now since we're breaking it up into smaller PRs.

@RandyGaul RandyGaul closed this Feb 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants