| 7126 | } |
| 7127 | |
| 7128 | static void* stbi__pic_load( |
| 7129 | stbi__context* s, int* px, int* py, int* comp, int req_comp, |
| 7130 | stbi__result_info* ri) { |
| 7131 | stbi_uc* result; |
| 7132 | int i, x, y, internal_comp; |
| 7133 | STBI_NOTUSED(ri); |
| 7134 | |
| 7135 | if (!comp) |
| 7136 | comp = &internal_comp; |
| 7137 | |
| 7138 | for (i = 0; i < 92; ++i) |
| 7139 | stbi__get8(s); |
| 7140 | |
| 7141 | x = stbi__get16be(s); |
| 7142 | y = stbi__get16be(s); |
| 7143 | |
| 7144 | if (y > STBI_MAX_DIMENSIONS) |
| 7145 | return stbi__errpuc("too large", "Very large image (corrupt?)"); |
| 7146 | if (x > STBI_MAX_DIMENSIONS) |
| 7147 | return stbi__errpuc("too large", "Very large image (corrupt?)"); |
| 7148 | |
| 7149 | if (stbi__at_eof(s)) |
| 7150 | return stbi__errpuc("bad file", "file too short (pic header)"); |
| 7151 | if (!stbi__mad3sizes_valid(x, y, 4, 0)) |
| 7152 | return stbi__errpuc("too large", "PIC image too large to decode"); |
| 7153 | |
| 7154 | stbi__get32be(s); // skip `ratio' |
| 7155 | stbi__get16be(s); // skip `fields' |
| 7156 | stbi__get16be(s); // skip `pad' |
| 7157 | |
| 7158 | // intermediate buffer is RGBA |
| 7159 | result = (stbi_uc*)stbi__malloc_mad3(x, y, 4, 0); |
| 7160 | if (!result) |
| 7161 | return stbi__errpuc("outofmem", "Out of memory"); |
| 7162 | memset(result, 0xff, x * y * 4); |
| 7163 | |
| 7164 | if (!stbi__pic_load_core(s, x, y, comp, result)) { |
| 7165 | STBI_FREE(result); |
| 7166 | result = 0; |
| 7167 | } |
| 7168 | *px = x; |
| 7169 | *py = y; |
| 7170 | if (req_comp == 0) |
| 7171 | req_comp = *comp; |
| 7172 | result = stbi__convert_format(result, 4, req_comp, x, y); |
| 7173 | |
| 7174 | return result; |
| 7175 | } |
| 7176 | |
| 7177 | static int stbi__pic_test(stbi__context* s) { |
| 7178 | int r = stbi__pic_test_core(s); |
no test coverage detected