MCPcopy Create free account
hub / github.com/OpenFodder/openfodder / stbi__psd_decode_rle

Function stbi__psd_decode_rle

Source/Utils/stb_image.h:6085–6121  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6083}
6084
6085static 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
6123static void *stbi__psd_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri, int bpc)
6124{

Callers 1

stbi__psd_loadFunction · 0.85

Calls 1

stbi__get8Function · 0.85

Tested by

no test coverage detected