Lines Matching refs:img_n

806    int img_n, img_out_n;
1735 // generic converter from built-in img_n to req_comp
1753 static unsigned char *stbi__convert_format(unsigned char *data, int img_n, int req_comp, unsigned int x, unsigned int y)
1758 if (req_comp == img_n) return data;
1768 unsigned char *src = data + j * x * img_n ;
1773 // convert source image with img_n components to one with req_comp components;
1775 switch (STBI__COMBO(img_n, req_comp)) {
1810 static stbi__uint16 *stbi__convert_format16(stbi__uint16 *data, int img_n, int req_comp, unsigned int x, unsigned int y)
1815 if (req_comp == img_n) return data;
1825 stbi__uint16 *src = data + j * x * img_n ;
1830 // convert source image with img_n components to one with req_comp components;
1832 switch (STBI__COMBO(img_n, req_comp)) {
3083 for (n=0; n < z->s->img_n; ++n) {
3206 if (z->scan_n < 1 || z->scan_n > 4 || z->scan_n > (int) z->s->img_n) return stbi__err("bad SOS component count","Corrupt JPEG");
3211 for (which = 0; which < z->s->img_n; ++which)
3214 if (which == z->s->img_n) return 0; // no match
3274 s->img_n = c;
3280 if (Lf != 8+3*s->img_n) return stbi__err("bad SOF len","Corrupt JPEG");
3283 for (i=0; i < s->img_n; ++i) {
3286 if (s->img_n == 3 && z->img_comp[i].id == rgb[i])
3296 if (!stbi__mad3sizes_valid(s->img_x, s->img_y, s->img_n, 0)) return stbi__err("too large", "Image too large to decode");
3298 for (i=0; i < s->img_n; ++i) {
3305 for (i=0; i < s->img_n; ++i) {
3319 for (i=0; i < s->img_n; ++i) {
3843 stbi__free_jpeg_components(j, j->s->img_n, 0);
3866 z->s->img_n = 0; // make stbi__cleanup_jpeg safe
3875 n = req_comp ? req_comp : z->s->img_n >= 3 ? 3 : 1;
3877 is_rgb = z->s->img_n == 3 && (z->rgb == 3 || (z->app14_color_transform == 0 && !z->jfif));
3879 if (z->s->img_n == 3 && n < 3 && !is_rgb)
3882 decode_n = z->s->img_n;
3942 if (z->s->img_n == 3) {
3954 } else if (z->s->img_n == 4) {
3993 } else if (z->s->img_n == 4 && z->app14_color_transform == 0) {
4003 } else if (z->s->img_n == 4 && z->app14_color_transform == 2) {
4021 if (comp) *comp = z->s->img_n >= 3 ? 3 : 1; // report original components, not output
4062 if (comp) *comp = j->s->img_n >= 3 ? 3 : 1;
4657 int img_n = s->img_n; // copy it into a local for later
4660 int filter_bytes = img_n*bytes;
4663 STBI_ASSERT(out_n == s->img_n || out_n == s->img_n+1);
4667 if (!stbi__mad3sizes_valid(img_n, x, depth, 7)) return stbi__err("too large", "Corrupt PNG");
4668 img_width_bytes = (((img_n * x * depth) + 7) >> 3);
4709 if (img_n != out_n)
4710 cur[img_n] = 255; // first pixel
4711 raw += img_n;
4715 if (img_n != out_n) {
4729 if (depth < 8 || img_n == out_n) {
4747 STBI_ASSERT(img_n+1 == out_n);
4792 for (k=x*img_n; k >= 2; k-=2, ++in) {
4798 for (k=x*img_n; k >= 4; k-=4, ++in) {
4808 for (k=x*img_n; k >= 8; k-=8, ++in) {
4826 if (img_n != out_n) {
4830 if (img_n == 1) {
4836 STBI_ASSERT(img_n == 3);
4884 stbi__uint32 img_len = ((((a->s->img_n * x * depth) + 7) >> 3) + 1) * y;
5121 s->img_n = (color & 2 ? 3 : 1) + (color & 4 ? 1 : 0);
5122 if ((1 << 30) / s->img_x / s->img_n < s->img_y) return stbi__err("too large", "Image too large to decode");
5125 // img_n is # components to decompress/filter.
5126 s->img_n = 1;
5151 if (scan == STBI__SCAN_header) { s->img_n = 4; return 1; }
5158 if (!(s->img_n & 1)) return stbi__err("tRNS with alpha","Corrupt PNG");
5159 if (c.length != (stbi__uint32) s->img_n*2) return stbi__err("bad tRNS len","Corrupt PNG");
5162 if (scan == STBI__SCAN_header) { ++s->img_n; return 1; }
5164 for (k = 0; k < s->img_n; ++k) tc16[k] = (stbi__uint16)stbi__get16be(s); // copy the values as-is
5166 for (k = 0; k < s->img_n; ++k) tc[k] = (stbi_uc)(stbi__get16be(s) & 255) * stbi__depth_scale_table[z->depth]; // non 8-bit images will be larger
5178 s->img_n = pal_img_n;
5205 raw_len = bpl * s->img_y * s->img_n /* pixels */ + s->img_y /* filter mode per row */;
5209 if ((req_comp == s->img_n+1 && req_comp != 3 && !pal_img_n) || has_trans)
5210 s->img_out_n = s->img_n+1;
5212 s->img_out_n = s->img_n;
5225 s->img_n = pal_img_n; // record the actual colors we had
5232 ++s->img_n;
5285 if (n) *n = p->s->img_n;
5317 if (comp) *comp = p->s->img_n;
5584 s->img_n = 3;
5586 s->img_n = ma ? 4 : 3;
5590 target = s->img_n; // if they want monochrome, we'll post-convert
5729 if (comp) *comp = s->img_n;
7516 ri->bits_per_channel = stbi__pnm_info(s, (int *)&s->img_x, (int *)&s->img_y, (int *)&s->img_n);
7525 if (comp) *comp = s->img_n;
7527 if (!stbi__mad4sizes_valid(s->img_n, s->img_x, s->img_y, ri->bits_per_channel / 8, 0))
7530 out = (stbi_uc *) stbi__malloc_mad4(s->img_n, s->img_x, s->img_y, ri->bits_per_channel / 8, 0);
7532 if (!stbi__getn(s, out, s->img_n * s->img_x * s->img_y * (ri->bits_per_channel / 8))) {
7537 if (req_comp && req_comp != s->img_n) {
7539 out = (stbi_uc *) stbi__convert_format16((stbi__uint16 *) out, s->img_n, req_comp, s->img_x, s->img_y);
7541 out = stbi__convert_format(out, s->img_n, req_comp, s->img_x, s->img_y);