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

Function stbi__psd_load

include/stb/stb_image.h:6126–6325  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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{
6128 int pixelCount;
6129 int channelCount, compression;
6130 int channel, i;
6131 int bitdepth;
6132 int w,h;
6133 stbi_uc *out;
6134 STBI_NOTUSED(ri);
6135
6136 // Check identifier
6137 if (stbi__get32be(s) != 0x38425053) // "8BPS"
6138 return stbi__errpuc("not PSD", "Corrupt PSD image");
6139
6140 // Check file type version.
6141 if (stbi__get16be(s) != 1)
6142 return stbi__errpuc("wrong version", "Unsupported version of PSD image");
6143
6144 // Skip 6 reserved bytes.
6145 stbi__skip(s, 6 );
6146
6147 // Read the number of channels (R, G, B, A, etc).
6148 channelCount = stbi__get16be(s);
6149 if (channelCount < 0 || channelCount > 16)
6150 return stbi__errpuc("wrong channel count", "Unsupported number of channels in PSD image");
6151
6152 // Read the rows and columns of the image.
6153 h = stbi__get32be(s);
6154 w = stbi__get32be(s);
6155
6156 if (h > STBI_MAX_DIMENSIONS) return stbi__errpuc("too large","Very large image (corrupt?)");
6157 if (w > STBI_MAX_DIMENSIONS) return stbi__errpuc("too large","Very large image (corrupt?)");
6158
6159 // Make sure the depth is 8 bits.
6160 bitdepth = stbi__get16be(s);
6161 if (bitdepth != 8 && bitdepth != 16)
6162 return stbi__errpuc("unsupported bit depth", "PSD bit depth is not 8 or 16 bit");
6163
6164 // Make sure the color mode is RGB.
6165 // Valid options are:
6166 // 0: Bitmap
6167 // 1: Grayscale
6168 // 2: Indexed color
6169 // 3: RGB color
6170 // 4: CMYK color
6171 // 7: Multichannel
6172 // 8: Duotone
6173 // 9: Lab color
6174 if (stbi__get16be(s) != 3)
6175 return stbi__errpuc("wrong color format", "PSD is not in RGB color format");
6176
6177 // Skip the Mode Data. (It's the palette for indexed color; other info for other modes.)
6178 stbi__skip(s,stbi__get32be(s) );
6179
6180 // Skip the image resources. (resolution, pen tool paths, etc)
6181 stbi__skip(s, stbi__get32be(s) );
6182
6183 // Skip the reserved data.

Callers 1

stbi__load_mainFunction · 0.85

Calls 10

stbi__get32beFunction · 0.85
stbi__get16beFunction · 0.85
stbi__skipFunction · 0.85
stbi__mad3sizes_validFunction · 0.85
stbi__malloc_mad3Function · 0.85
stbi__mallocFunction · 0.85
stbi__psd_decode_rleFunction · 0.85
stbi__get8Function · 0.85
stbi__convert_format16Function · 0.85
stbi__convert_formatFunction · 0.85

Tested by

no test coverage detected