| 4903 | } |
| 4904 | |
| 4905 | static 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 | |
| 4930 | static int stbi__compute_transparency16(stbi__png *z, stbi__uint16 tc[3], int out_n) |
| 4931 | { |
no outgoing calls
no test coverage detected