PSDTranslator: Add indexed color mode
This commit is contained in:
parent
9d4b8b1f71
commit
03ad24c9c1
@ -37,8 +37,10 @@ PSDLoader::PSDLoader(BPositionIO *src)
|
||||
fDepth = _GetInt16FromStream(fStream);
|
||||
fColorFormat = _GetInt16FromStream(fStream);
|
||||
|
||||
// Skip mode data
|
||||
_SkipStreamBlock(fStream, _GetInt32FromStream(fStream));
|
||||
fColorModeDataSize = _GetInt32FromStream(fStream);
|
||||
fColorModeDataPos = fStream->Position();
|
||||
_SkipStreamBlock(fStream, fColorModeDataSize);
|
||||
|
||||
// Skip image resources
|
||||
_SkipStreamBlock(fStream, _GetInt32FromStream(fStream));
|
||||
// Skip reserved data
|
||||
@ -160,6 +162,10 @@ PSDLoader::_ColorFormat(void)
|
||||
if (fChannels >= 1)
|
||||
format = PSD_COLOR_FORMAT_DUOTONE;
|
||||
break;
|
||||
case PSD_COLOR_MODE_INDEXED:
|
||||
if (fChannels >= 1 && fColorModeDataSize >= 3)
|
||||
format = PSD_COLOR_FORMAT_INDEXED;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
};
|
||||
@ -275,6 +281,32 @@ PSDLoader::Decode(BPositionIO *target)
|
||||
target->Write(imageData[0], rowBytes);
|
||||
break;
|
||||
}
|
||||
case PSD_COLOR_FORMAT_INDEXED:
|
||||
{
|
||||
int32 paletteSize = fColorModeDataSize / 3;
|
||||
|
||||
uint8 *colorData = new uint8[fColorModeDataSize];
|
||||
fStream->Seek(fColorModeDataPos, SEEK_SET);
|
||||
fStream->Read(colorData, fColorModeDataSize);
|
||||
|
||||
uint8 *redPalette = colorData;
|
||||
uint8 *greenPalette = colorData + paletteSize;
|
||||
uint8 *bluePalette = colorData + paletteSize * 2;
|
||||
uint8 *cCh = imageData[0];
|
||||
for (int h = 0; h < fHeight; h++) {
|
||||
uint8 *ptr = lineData;
|
||||
for (int w = 0; w < fWidth; w++) {
|
||||
uint8 c = *cCh++;
|
||||
*ptr++ = bluePalette[c];
|
||||
*ptr++ = greenPalette[c];
|
||||
*ptr++ = redPalette[c];
|
||||
*ptr++ = 255;
|
||||
}
|
||||
target->Write(lineData, fWidth * sizeof(uint32));
|
||||
}
|
||||
delete colorData;
|
||||
break;
|
||||
}
|
||||
case PSD_COLOR_FORMAT_DUOTONE:
|
||||
case PSD_COLOR_FORMAT_GRAY:
|
||||
case PSD_COLOR_FORMAT_GRAY_A:
|
||||
|
@ -53,7 +53,8 @@ enum psd_color_format {
|
||||
PSD_COLOR_FORMAT_CMYK_A,
|
||||
PSD_COLOR_FORMAT_LAB,
|
||||
PSD_COLOR_FORMAT_LAB_A,
|
||||
PSD_COLOR_FORMAT_DUOTONE
|
||||
PSD_COLOR_FORMAT_DUOTONE,
|
||||
PSD_COLOR_FORMAT_INDEXED
|
||||
};
|
||||
|
||||
|
||||
@ -82,6 +83,9 @@ private:
|
||||
size_t fStreamSize;
|
||||
size_t fStreamPos;
|
||||
|
||||
size_t fColorModeDataSize;
|
||||
size_t fColorModeDataPos;
|
||||
|
||||
int32 fSignature;
|
||||
int16 fVersion;
|
||||
int16 fChannels;
|
||||
|
@ -21,7 +21,7 @@
|
||||
#define DOCUMENT_COUNT "/documentCount"
|
||||
#define DOCUMENT_INDEX "/documentIndex"
|
||||
|
||||
#define PSD_TRANSLATOR_VERSION B_TRANSLATION_MAKE_VERSION(1, 1, 1)
|
||||
#define PSD_TRANSLATOR_VERSION B_TRANSLATION_MAKE_VERSION(1, 1, 2)
|
||||
#define PSD_IMAGE_FORMAT 'PSD '
|
||||
|
||||
#define PSD_IN_QUALITY 0.5
|
||||
|
@ -7,9 +7,9 @@ resource app_signature "application/x-vnd.Haiku-PSDTranslator";
|
||||
resource app_version {
|
||||
major = 1,
|
||||
middle = 1,
|
||||
minor = 0,
|
||||
minor = 2,
|
||||
variety = 0,
|
||||
internal = 0,
|
||||
short_info = "1.1.0",
|
||||
short_info = "1.1.2",
|
||||
long_info = "Haiku PSDTranslator Add-Ons."
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user