| 6698 | } |
| 6699 | |
| 6700 | static int stbi__psd_decode_rle(stbi__context* s, stbi_uc* p, int pixelCount) { |
| 6701 | int count, nleft, len; |
| 6702 | |
| 6703 | count = 0; |
| 6704 | while ((nleft = pixelCount - count) > 0) { |
| 6705 | len = stbi__get8(s); |
| 6706 | if (len == 128) { |
| 6707 | // No-op. |
| 6708 | } else if (len < 128) { |
| 6709 | // Copy next len+1 bytes literally. |
| 6710 | len++; |
| 6711 | if (len > nleft) |
| 6712 | return 0; // corrupt data |
| 6713 | count += len; |
| 6714 | while (len) { |
| 6715 | *p = stbi__get8(s); |
| 6716 | p += 4; |
| 6717 | len--; |
| 6718 | } |
| 6719 | } else if (len > 128) { |
| 6720 | stbi_uc val; |
| 6721 | // Next -len+1 bytes in the dest are replicated from next source byte. |
| 6722 | // (Interpret len as a negative 8-bit int.) |
| 6723 | len = 257 - len; |
| 6724 | if (len > nleft) |
| 6725 | return 0; // corrupt data |
| 6726 | val = stbi__get8(s); |
| 6727 | count += len; |
| 6728 | while (len) { |
| 6729 | *p = val; |
| 6730 | p += 4; |
| 6731 | len--; |
| 6732 | } |
| 6733 | } |
| 6734 | } |
| 6735 | |
| 6736 | return 1; |
| 6737 | } |
| 6738 | |
| 6739 | static void* stbi__psd_load( |
| 6740 | stbi__context* s, int* x, int* y, int* comp, int req_comp, |
no test coverage detected