gbdk-2020 | GameBoy Development Kit |
| download: https://git.y1.nz/archives/gbdk.tar.gz | |
| README | Files | Log | Refs | LICENSE |
commit 8dac1ce694ea115b26cf524362706e676d1cfcbc parent 41da13930cfb969d3a46fc5f6a6b410e919841d0 Author: bbbbbr <bbbbbr@users.noreply.github.com> Date: Sat, 28 Oct 2023 16:09:47 -0700 Merge pull request #590 from bbbbbr/png2asset/fixes png2asset: palette and warning fixes Diffstat:
| M | gbdk-support/png2asset/image_data.cpp | 5 | +++-- |
| M | gbdk-support/png2asset/main.cpp | 3 | ++- |
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/gbdk-support/png2asset/image_data.cpp b/gbdk-support/png2asset/image_data.cpp @@ -143,6 +143,8 @@ int ReadImageData_Default(PNG2AssetData* assetData, string input_filename) { assetData->image.total_color_count = palette_count * assetData->image.colors_per_pal; assetData->image.palette = new unsigned char[palette_count * assetData->image.colors_per_pal * RGBA32_SZ]; // total color count * 4 bytes each + // Pre-fill palette to all black. Prevents garbage in palette color slots that are unused (ex: only 3 colors when colors-per-pal is 4) + memset(assetData->image.palette, 0, palette_count * assetData->image.colors_per_pal * RGBA32_SZ); // If we are using a sourcetileset and have more palettes than it defines if(assetData->args->source_tilesets.size() > 0 && (assetData->image.total_color_count > assetData->args->source_total_color_count)) { @@ -152,8 +154,7 @@ int ReadImageData_Default(PNG2AssetData* assetData, string input_filename) { { int* color_ptr = (int*)&assetData->image.palette[p * assetData->image.colors_per_pal * RGBA32_SZ]; - //TODO: if palettes[p].size() != image.colors_per_pal we should probably try to fill the gaps based on grayscale values - + // When palettes[p].size() != image.colors_per_pal the unused colors are left as black (see memset above) for(SetPal::iterator it = assetData->palettes[p].begin(); it != assetData->palettes[p].end(); ++it, color_ptr++) { unsigned char* c = (unsigned char*)&(*it); diff --git a/gbdk-support/png2asset/main.cpp b/gbdk-support/png2asset/main.cpp @@ -47,7 +47,7 @@ int main(int argc, char* argv[]) vector<string>::iterator sourceTilesetsIterator = arguments.source_tilesets.begin(); // Iterate through each source tileset and execute - for(sourceTilesetsIterator; sourceTilesetsIterator < arguments.source_tilesets.end(); sourceTilesetsIterator++) { + while (sourceTilesetsIterator < arguments.source_tilesets.end()) { // Run with our source tileset filename errorCode = png2AssetInstance.Execute(&arguments, *sourceTilesetsIterator); @@ -57,6 +57,7 @@ int main(int argc, char* argv[]) return errorCode; } + sourceTilesetsIterator++; } // Save these values for later usage on the main execution
This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.