Skip to content

Commit

Permalink
Warn when PNGs have too few bits per pixel
Browse files Browse the repository at this point in the history
Fixes #93
  • Loading branch information
blacktm committed Jan 1, 2019
1 parent 2c7067d commit fad5a15
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/image.c
Expand Up @@ -29,6 +29,14 @@ S2D_Image *S2D_CreateImage(const char *path) {
return NULL; return NULL;
} }


int bits_per_color = img->surface->format->Amask == 0 ?
img->surface->format->BitsPerPixel / 3 :
img->surface->format->BitsPerPixel / 4;

if (bits_per_color < 8) {
S2D_Log(S2D_WARN, "`%s` has less than 8 bits per color and will likely not render correctly", path, bits_per_color);
}

// Initialize values // Initialize values
img->path = path; img->path = path;
img->x = 0; img->x = 0;
Expand Down

0 comments on commit fad5a15

Please sign in to comment.