MCPcopy Create free account
hub / github.com/ARM-software/ComputeLibrary / stbi__compute_transparency

Function stbi__compute_transparency

include/stb/stb_image.h:4906–4929  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

stbi__parse_png_fileFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected