| 6083 | } |
| 6084 | |
| 6085 | static int stbi__psd_decode_rle(stbi__context *s, stbi_uc *p, int pixelCount) |
| 6086 | { |
| 6087 | int count, nleft, len; |
| 6088 | |
| 6089 | count = 0; |
| 6090 | while ((nleft = pixelCount - count) > 0) { |
| 6091 | len = stbi__get8(s); |
| 6092 | if (len == 128) { |
| 6093 | // No-op. |
| 6094 | } else if (len < 128) { |
| 6095 | // Copy next len+1 bytes literally. |
| 6096 | len++; |
| 6097 | if (len > nleft) return 0; // corrupt data |
| 6098 | count += len; |
| 6099 | while (len) { |
| 6100 | *p = stbi__get8(s); |
| 6101 | p += 4; |
| 6102 | len--; |
| 6103 | } |
| 6104 | } else if (len > 128) { |
| 6105 | stbi_uc val; |
| 6106 | // Next -len+1 bytes in the dest are replicated from next source byte. |
| 6107 | // (Interpret len as a negative 8-bit int.) |
| 6108 | len = 257 - len; |
| 6109 | if (len > nleft) return 0; // corrupt data |
| 6110 | val = stbi__get8(s); |
| 6111 | count += len; |
| 6112 | while (len) { |
| 6113 | *p = val; |
| 6114 | p += 4; |
| 6115 | len--; |
| 6116 | } |
| 6117 | } |
| 6118 | } |
| 6119 | |
| 6120 | return 1; |
| 6121 | } |
| 6122 | |
| 6123 | static void *stbi__psd_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri, int bpc) |
| 6124 | { |
no test coverage detected