Permalink
Browse files

Warn when PNGs have too few bits per pixel

Fixes #93
  • Loading branch information...
blacktm committed Jan 1, 2019
1 parent 2c7067d commit fad5a15ecf954e05964d6c4abc8064fa500085ba
Showing with 8 additions and 0 deletions.
  1. +8 −0 src/image.c
@@ -29,6 +29,14 @@ S2D_Image *S2D_CreateImage(const char *path) {
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
img->path = path;
img->x = 0;

0 comments on commit fad5a15

Please sign in to comment.