Exemplo n.º 1
0
int main(int argc, char *argv[]) {

  read_png_file(argv[1]);
  process_png_file();
//  write_png_file(argv[2]);

  return 0;
}
Exemplo n.º 2
0
bool loadThemeImage(char * path, char * description, int expectedWidth, int expectedHeight, u8 * alphaMask, int imageID, themeImage images[]) {
    themeImage * aThemeImage = &(images[imageID]);
    aThemeImage->exists = false;

    if (aThemeImage->spriteData) {
        free(aThemeImage->spriteData);
    }

    aThemeImage->spriteData = NULL;

//    free(aThemeImage->spriteData);

    if (!fileExists(path, &sdmcArchive)) {
        return false;
    }

    bool success = read_png_file(path);

    if (success) {
        if (pngWidth != expectedWidth || pngHeight != expectedHeight) {
            char error[256];
            sprintf(error, "%s must be %dx%d pixels", description, expectedWidth, expectedHeight);
            logText(error);
            return false;
        }
        else {
            u8 * out = process_png_file();

            if (out) {
                if (alphaMask) {
                    u8 * masked = malloc(expectedWidth*expectedHeight*4);
                    MAGFXApplyAlphaMask(out, alphaMask, masked, expectedWidth, expectedHeight, (bytesPerPixel==4));
                    aThemeImage->spriteData = masked;
                    free(out);
                    aThemeImage->hasAlpha = true;
                }
                else {
                    aThemeImage->spriteData = out;
                    aThemeImage->hasAlpha = (bytesPerPixel==4);
                }


                aThemeImage->exists = true;
                aThemeImage->w = expectedWidth;
                aThemeImage->h = expectedHeight;

                return true;
            }
            else {
                return false;
            }
        }
    }
    else {
        return false;
    }
}