Alien-FreeImage
view release on metacpan or search on metacpan
src/Source/FreeImage/PSDParser.cpp view on Meta::CPAN
}
else if ( len > 128 ) { //< MSB is set
// RLE compressed packet
// One byte of data is repeated (âlen + 1) times
len ^= 0xFF; // same as (-len + 1) & 0xFF
len += 2; //
// assert we don't write beyound eol
memset(line, *rle_line++, line + len > line_end ? line_end - line : len);
line += len;
}
else if ( 128 == len ) {
// Do nothing
}
}//< rle_line
// - write line to destination -
if(ch >= dstChannels) {
// @todo write to extra channels
break;
}
// byte by byte copy a single channel to pixel
for (BYTE *line = line_start, *dst_line = dst_line_start; line < line_start + lineSize;
line += bytes, dst_line += dstBpp) {
#ifdef FREEIMAGE_BIGENDIAN
memcpy(dst_line + channelOffset, line, bytes);
#else
// reverse copy bytes
for (unsigned b = 0; b < bytes; ++b) {
dst_line[channelOffset + b] = line[(bytes-1) - b];
}
#endif // FREEIMAGE_BIGENDIAN
}
}//< h
}//< ch
SAFE_DELETE_ARRAY(line_start);
SAFE_DELETE_ARRAY(rleLineSizeList);
SAFE_DELETE_ARRAY(rle_line_start);
}
break;
case 2: // ZIP without prediction, no specification
break;
case 3: // ZIP with prediction, no specification
break;
default: // Unknown format
break;
}
// --- Further process the bitmap ---
if((mode == PSDP_CMYK || mode == PSDP_MULTICHANNEL)) {
// CMYK values are "inverted", invert them back
if(mode == PSDP_MULTICHANNEL) {
invertColor(bitmap);
} else {
FreeImage_Invert(bitmap);
}
if((_fi_flags & PSD_CMYK) == PSD_CMYK) {
// keep as CMYK
if(mode == PSDP_MULTICHANNEL) {
//### we force CMY to be CMYK, but CMY has no ICC.
// Create empty profile and add the flag.
FreeImage_CreateICCProfile(bitmap, NULL, 0);
FreeImage_GetICCProfile(bitmap)->flags |= FIICC_COLOR_IS_CMYK;
}
}
else {
// convert to RGB
ConvertCMYKtoRGBA(bitmap);
// The ICC Profile is no longer valid
_iccProfile.clear();
// remove the pending A if not present in source
if(nChannels == 4 || nChannels == 3 ) {
FIBITMAP* t = RemoveAlphaChannel(bitmap);
if(t) {
FreeImage_Unload(bitmap);
bitmap = t;
} // else: silently fail
}
}
}
else if ( mode == PSDP_LAB && !((_fi_flags & PSD_LAB) == PSD_LAB)) {
ConvertLABtoRGB(bitmap);
}
else {
if (needPalette && FreeImage_GetPalette(bitmap)) {
if(mode == PSDP_BITMAP) {
CREATE_GREYSCALE_PALETTE_REVERSE(FreeImage_GetPalette(bitmap), 2);
}
else if(mode == PSDP_INDEXED) {
if(!_colourModeData._plColourData || _colourModeData._Length != 768 || _ColourCount < 0) {
FreeImage_OutputMessageProc(_fi_format_id, "Indexed image has no palette. Using the default grayscale one.");
} else {
_colourModeData.FillPalette(bitmap);
}
}
// GRAYSCALE, DUOTONE - use default grayscale palette
}
#if FREEIMAGE_COLORORDER == FREEIMAGE_COLORORDER_BGR
if(FreeImage_GetImageType(bitmap) == FIT_BITMAP) {
SwapRedBlue32(bitmap);
( run in 0.954 second using v1.01-cache-2.11-cpan-ceb78f64989 )