MCPcopy Create free account
hub / github.com/assaultcube/AC / checkgrayscale

Function checkgrayscale

source/src/texture.cpp:214–225  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

212}
213
214bool checkgrayscale(SDL_Surface *s)
215{
216 // gray scale images have 256 levels, no colorkey, and the palette is a ramp
217 if(s->format->palette)
218 {
219 Uint32 ck = 0;
220 if(s->format->palette->ncolors != 256 || SDL_GetColorKey(s, &ck) == -1) return false;
221 const SDL_Color *colors = s->format->palette->colors;
222 loopi(256) if(colors[i].r != i || colors[i].g != i || colors[i].b != i) return false;
223 }
224 return true;
225}
226
227int fixcl(SDL_Surface *s, int threshold)
228{

Callers 1

fixsurfaceformatFunction · 0.85

Calls 1

loopiFunction · 0.70

Tested by

no test coverage detected