MCPcopy Create free account
hub / github.com/ARM-software/ComputeLibrary / stbi__psd_decode_rle

Function stbi__psd_decode_rle

include/stb/stb_image.h:6088–6124  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

stbi__psd_loadFunction · 0.85

Calls 1

stbi__get8Function · 0.85

Tested by

no test coverage detected