mirror of
https://github.com/nothings/stb
synced 2024-12-16 12:52:34 +03:00
Merge branch 'psd16' of https://github.com/rmitton/stb into working
This commit is contained in:
commit
69d6fd573c
15
stb_image.h
15
stb_image.h
@ -5065,6 +5065,7 @@ static stbi_uc *stbi__psd_load(stbi__context *s, int *x, int *y, int *comp, int
|
|||||||
int pixelCount;
|
int pixelCount;
|
||||||
int channelCount, compression;
|
int channelCount, compression;
|
||||||
int channel, i, count, len;
|
int channel, i, count, len;
|
||||||
|
int bitdepth;
|
||||||
int w,h;
|
int w,h;
|
||||||
stbi_uc *out;
|
stbi_uc *out;
|
||||||
|
|
||||||
@ -5089,8 +5090,9 @@ static stbi_uc *stbi__psd_load(stbi__context *s, int *x, int *y, int *comp, int
|
|||||||
w = stbi__get32be(s);
|
w = stbi__get32be(s);
|
||||||
|
|
||||||
// Make sure the depth is 8 bits.
|
// Make sure the depth is 8 bits.
|
||||||
if (stbi__get16be(s) != 8)
|
bitdepth = stbi__get16be(s);
|
||||||
return stbi__errpuc("unsupported bit depth", "PSD bit depth is not 8 bit");
|
if (bitdepth != 8 && bitdepth != 16)
|
||||||
|
return stbi__errpuc("unsupported bit depth", "PSD bit depth is not 8 or 16 bit");
|
||||||
|
|
||||||
// Make sure the color mode is RGB.
|
// Make sure the color mode is RGB.
|
||||||
// Valid options are:
|
// Valid options are:
|
||||||
@ -5202,8 +5204,13 @@ static stbi_uc *stbi__psd_load(stbi__context *s, int *x, int *y, int *comp, int
|
|||||||
*p = channel == 3 ? 255 : 0;
|
*p = channel == 3 ? 255 : 0;
|
||||||
} else {
|
} else {
|
||||||
// Read the data.
|
// Read the data.
|
||||||
for (i = 0; i < pixelCount; i++, p += 4)
|
if (bitdepth == 16) {
|
||||||
*p = stbi__get8(s);
|
for (i = 0; i < pixelCount; i++, p += 4)
|
||||||
|
*p = stbi__get16be(s) * 255 / 65535;
|
||||||
|
} else {
|
||||||
|
for (i = 0; i < pixelCount; i++, p += 4)
|
||||||
|
*p = stbi__get8(s);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user