MCPcopy Create free account
hub / github.com/OpenFodder/openfodder / stbi__compute_transparency

Function stbi__compute_transparency

Source/Utils/stb_image.h:4905–4928  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4903}
4904
4905static int stbi__compute_transparency(stbi__png *z, stbi_uc tc[3], int out_n)
4906{
4907 stbi__context *s = z->s;
4908 stbi__uint32 i, pixel_count = s->img_x * s->img_y;
4909 stbi_uc *p = z->out;
4910
4911 // compute color-based transparency, assuming we've
4912 // already got 255 as the alpha value in the output
4913 STBI_ASSERT(out_n == 2 || out_n == 4);
4914
4915 if (out_n == 2) {
4916 for (i=0; i < pixel_count; ++i) {
4917 p[1] = (p[0] == tc[0] ? 0 : 255);
4918 p += 2;
4919 }
4920 } else {
4921 for (i=0; i < pixel_count; ++i) {
4922 if (p[0] == tc[0] && p[1] == tc[1] && p[2] == tc[2])
4923 p[3] = 0;
4924 p += 4;
4925 }
4926 }
4927 return 1;
4928}
4929
4930static int stbi__compute_transparency16(stbi__png *z, stbi__uint16 tc[3], int out_n)
4931{

Callers 1

stbi__parse_png_fileFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected