MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / stbi__psd_decode_rle

Function stbi__psd_decode_rle

lite/example/cpp_example/mge/cv/stb_image.h:6700–6737  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6698}
6699
6700static 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
6739static void* stbi__psd_load(
6740 stbi__context* s, int* x, int* y, int* comp, int req_comp,

Callers 1

stbi__psd_loadFunction · 0.85

Calls 1

stbi__get8Function · 0.85

Tested by

no test coverage detected