diff options
Diffstat (limited to 'filter/source/graphicfilter/ipsd/ipsd.cxx')
-rw-r--r-- | filter/source/graphicfilter/ipsd/ipsd.cxx | 188 |
1 files changed, 94 insertions, 94 deletions
diff --git a/filter/source/graphicfilter/ipsd/ipsd.cxx b/filter/source/graphicfilter/ipsd/ipsd.cxx index 5a52c17956ed..8e7fea60e387 100644 --- a/filter/source/graphicfilter/ipsd/ipsd.cxx +++ b/filter/source/graphicfilter/ipsd/ipsd.cxx @@ -45,15 +45,15 @@ typedef struct { - UINT32 nSignature; - UINT16 nVersion; - UINT32 nPad1; - UINT16 nPad2; - UINT16 nChannels; - UINT32 nRows; - UINT32 nColumns; - UINT16 nDepth; - UINT16 nMode; + sal_uInt32 nSignature; + sal_uInt16 nVersion; + sal_uInt32 nPad1; + sal_uInt16 nPad2; + sal_uInt16 nChannels; + sal_uInt32 nRows; + sal_uInt32 nColumns; + sal_uInt16 nDepth; + sal_uInt16 nMode; } PSDFileHeader; @@ -75,17 +75,17 @@ private: BitmapReadAccess* mpReadAcc; BitmapWriteAccess* mpWriteAcc; BitmapWriteAccess* mpMaskWriteAcc; - USHORT mnDestBitDepth; - BOOL mbCompression; // RLE decoding - BYTE* mpPalette; + sal_uInt16 mnDestBitDepth; + sal_Bool mbCompression; // RLE decoding + sal_uInt8* mpPalette; - BOOL ImplReadBody(); - BOOL ImplReadHeader(); + sal_Bool ImplReadBody(); + sal_Bool ImplReadHeader(); public: PSDReader(); ~PSDReader(); - BOOL ReadPSD( SvStream & rPSD, Graphic & rGraphic ); + sal_Bool ReadPSD( SvStream & rPSD, Graphic & rGraphic ); }; //=================== Methoden von PSDReader ============================== @@ -94,8 +94,8 @@ PSDReader::PSDReader() : mpFileHeader ( NULL ), mnXResFixed ( 0 ), mnYResFixed ( 0 ), - mbStatus ( TRUE ), - mbTransparent ( FALSE ), + mbStatus ( sal_True ), + mbTransparent ( sal_False ), mpReadAcc ( NULL ), mpWriteAcc ( NULL ), mpMaskWriteAcc ( NULL ), @@ -111,35 +111,35 @@ PSDReader::~PSDReader() // ------------------------------------------------------------------------ -BOOL PSDReader::ReadPSD( SvStream & rPSD, Graphic & rGraphic ) +sal_Bool PSDReader::ReadPSD( SvStream & rPSD, Graphic & rGraphic ) { if ( rPSD.GetError() ) - return FALSE; + return sal_False; mpPSD = &rPSD; mpPSD->SetNumberFormatInt( NUMBERFORMAT_INT_BIGENDIAN ); // Kopf einlesen: - if ( ImplReadHeader() == FALSE ) - return FALSE; + if ( ImplReadHeader() == sal_False ) + return sal_False; Size aBitmapSize( mpFileHeader->nColumns, mpFileHeader->nRows ); maBmp = Bitmap( aBitmapSize, mnDestBitDepth ); if ( ( mpWriteAcc = maBmp.AcquireWriteAccess() ) == NULL ) - mbStatus = FALSE; + mbStatus = sal_False; if ( ( mpReadAcc = maBmp.AcquireReadAccess() ) == NULL ) - mbStatus = FALSE; + mbStatus = sal_False; if ( mbTransparent && mbStatus ) { maMaskBmp = Bitmap( aBitmapSize, 1 ); if ( ( mpMaskWriteAcc = maMaskBmp.AcquireWriteAccess() ) == NULL ) - mbStatus = FALSE; + mbStatus = sal_False; } if ( mpPalette && mbStatus ) { mpWriteAcc->SetPaletteEntryCount( 256 ); - for ( USHORT i = 0; i < 256; i++ ) + for ( sal_uInt16 i = 0; i < 256; i++ ) { mpWriteAcc->SetPaletteColor( i, Color( mpPalette[ i ], mpPalette[ i + 256 ], mpPalette[ i + 512 ] ) ); } @@ -164,7 +164,7 @@ BOOL PSDReader::ReadPSD( SvStream & rPSD, Graphic & rGraphic ) } } else - mbStatus = FALSE; + mbStatus = sal_False; if ( mpWriteAcc ) maBmp.ReleaseAccess( mpWriteAcc ); if ( mpReadAcc ) @@ -176,32 +176,32 @@ BOOL PSDReader::ReadPSD( SvStream & rPSD, Graphic & rGraphic ) // ------------------------------------------------------------------------ -BOOL PSDReader::ImplReadHeader() +sal_Bool PSDReader::ImplReadHeader() { - UINT16 nCompression; - UINT32 nColorLength, nResourceLength, nLayerMaskLength; + sal_uInt16 nCompression; + sal_uInt32 nColorLength, nResourceLength, nLayerMaskLength; mpFileHeader = new PSDFileHeader; if ( !mpFileHeader ) - return FALSE; + return sal_False; *mpPSD >> mpFileHeader->nSignature >> mpFileHeader->nVersion >> mpFileHeader->nPad1 >> mpFileHeader->nPad2 >> mpFileHeader->nChannels >> mpFileHeader->nRows >> mpFileHeader->nColumns >> mpFileHeader->nDepth >> mpFileHeader->nMode; if ( ( mpFileHeader->nSignature != 0x38425053 ) || ( mpFileHeader->nVersion != 1 ) ) - return FALSE; + return sal_False; if ( mpFileHeader->nRows == 0 || mpFileHeader->nColumns == 0 ) - return FALSE; + return sal_False; if ( ( mpFileHeader->nRows > 30000 ) || ( mpFileHeader->nColumns > 30000 ) ) - return FALSE; + return sal_False; - UINT16 nDepth = mpFileHeader->nDepth; + sal_uInt16 nDepth = mpFileHeader->nDepth; if (!( ( nDepth == 1 ) || ( nDepth == 8 ) || ( nDepth == 16 ) ) ) - return FALSE; + return sal_False; mnDestBitDepth = ( nDepth == 16 ) ? 8 : nDepth; @@ -211,27 +211,27 @@ BOOL PSDReader::ImplReadHeader() switch ( mpFileHeader->nChannels ) { case 5 : - mbTransparent = TRUE; + mbTransparent = sal_True; case 4 : mnDestBitDepth = 24; break; default : - return FALSE; + return sal_False; } } else switch ( mpFileHeader->nChannels ) { case 2 : - mbTransparent = TRUE; + mbTransparent = sal_True; case 1 : break; case 4 : - mbTransparent = TRUE; + mbTransparent = sal_True; case 3 : mnDestBitDepth = 24; break; default: - return FALSE; + return sal_False; } switch ( mpFileHeader->nMode ) @@ -239,17 +239,17 @@ BOOL PSDReader::ImplReadHeader() case PSD_BITMAP : { if ( nColorLength || ( nDepth != 1 ) ) - return FALSE; + return sal_False; } break; case PSD_INDEXED : { if ( nColorLength != 768 ) // we need the color map - return FALSE; - mpPalette = new BYTE[ 768 ]; + return sal_False; + mpPalette = new sal_uInt8[ 768 ]; if ( mpPalette == NULL ) - return FALSE; + return sal_False; mpPSD->Read( mpPalette, 768 ); } break; @@ -260,13 +260,13 @@ BOOL PSDReader::ImplReadHeader() case PSD_GRAYSCALE : { if ( nColorLength ) - return FALSE; - mpPalette = new BYTE[ 768 ]; + return sal_False; + mpPalette = new sal_uInt8[ 768 ]; if ( mpPalette == NULL ) - return FALSE; - for ( USHORT i = 0; i < 256; i++ ) + return sal_False; + for ( sal_uInt16 i = 0; i < 256; i++ ) { - mpPalette[ i ] = mpPalette[ i + 256 ] = mpPalette[ i + 512 ] = (BYTE)i; + mpPalette[ i ] = mpPalette[ i + 256 ] = mpPalette[ i + 512 ] = (sal_uInt8)i; } } break; @@ -277,12 +277,12 @@ BOOL PSDReader::ImplReadHeader() case PSD_LAB : { if ( nColorLength ) // color table is not supported by the other graphic modes - return FALSE; + return sal_False; } break; default: - return FALSE; + return sal_False; } *mpPSD >> nResourceLength; sal_uInt32 nLayerPos = mpPSD->Tell() + nResourceLength; @@ -327,27 +327,27 @@ BOOL PSDReader::ImplReadHeader() *mpPSD >> nCompression; if ( nCompression == 0 ) { - mbCompression = FALSE; + mbCompression = sal_False; } else if ( nCompression == 1 ) { mpPSD->SeekRel( ( mpFileHeader->nRows * mpFileHeader->nChannels ) << 1 ); - mbCompression = TRUE; + mbCompression = sal_True; } else - return FALSE; + return sal_False; - return TRUE; + return sal_True; } // ------------------------------------------------------------------------ -BOOL PSDReader::ImplReadBody() +sal_Bool PSDReader::ImplReadBody() { - ULONG nX, nY; + sal_uLong nX, nY; char nRunCount = 0; signed char nBitCount = -1; - BYTE nDat = 0, nDummy, nRed, nGreen, nBlue; + sal_uInt8 nDat = 0, nDummy, nRed, nGreen, nBlue; BitmapColor aBitmapColor; nX = nY = 0; @@ -370,9 +370,9 @@ BOOL PSDReader::ImplReadBody() nDat ^= 0xff; nBitCount = 7; } - for ( USHORT i = 0; i < ( -nRunCount + 1 ); i++ ) + for ( sal_uInt16 i = 0; i < ( -nRunCount + 1 ); i++ ) { - mpWriteAcc->SetPixel( nY, nX, (BYTE)nDat >> nBitCount-- ); + mpWriteAcc->SetPixel( nY, nX, (sal_uInt8)nDat >> nBitCount-- ); if ( ++nX == mpFileHeader->nColumns ) { nX = 0; @@ -385,7 +385,7 @@ BOOL PSDReader::ImplReadBody() } else // a raw packet { - for ( USHORT i = 0; i < ( ( nRunCount & 0x7f ) + 1 ); i++ ) + for ( sal_uInt16 i = 0; i < ( ( nRunCount & 0x7f ) + 1 ); i++ ) { if ( nBitCount == -1 ) // bits left in nDat ? { @@ -393,7 +393,7 @@ BOOL PSDReader::ImplReadBody() nDat ^= 0xff; nBitCount = 7; } - mpWriteAcc->SetPixel( nY, nX, (BYTE)nDat >> nBitCount-- ); + mpWriteAcc->SetPixel( nY, nX, (sal_uInt8)nDat >> nBitCount-- ); if ( ++nX == mpFileHeader->nColumns ) { nX = 0; @@ -420,9 +420,9 @@ BOOL PSDReader::ImplReadBody() *mpPSD >> nDat; if ( mpFileHeader->nDepth == 16 ) // 16 bit depth is to be skipped *mpPSD >> nDummy; - for ( USHORT i = 0; i < ( -nRunCount + 1 ); i++ ) + for ( sal_uInt16 i = 0; i < ( -nRunCount + 1 ); i++ ) { - mpWriteAcc->SetPixel( nY, nX, (BYTE)nDat ); + mpWriteAcc->SetPixel( nY, nX, (sal_uInt8)nDat ); if ( ++nX == mpFileHeader->nColumns ) { nX = 0; @@ -434,12 +434,12 @@ BOOL PSDReader::ImplReadBody() } else // a raw packet { - for ( USHORT i = 0; i < ( ( nRunCount & 0x7f ) + 1 ); i++ ) + for ( sal_uInt16 i = 0; i < ( ( nRunCount & 0x7f ) + 1 ); i++ ) { *mpPSD >> nDat; if ( mpFileHeader->nDepth == 16 ) // 16 bit depth is to be skipped *mpPSD >> nDummy; - mpWriteAcc->SetPixel( nY, nX, (BYTE)nDat ); + mpWriteAcc->SetPixel( nY, nX, (sal_uInt8)nDat ); if ( ++nX == mpFileHeader->nColumns ) { nX = 0; @@ -469,9 +469,9 @@ BOOL PSDReader::ImplReadBody() *mpPSD >> nRed; if ( mpFileHeader->nDepth == 16 ) // 16 bit depth is to be skipped *mpPSD >> nDummy; - for ( USHORT i = 0; i < ( -nRunCount + 1 ); i++ ) + for ( sal_uInt16 i = 0; i < ( -nRunCount + 1 ); i++ ) { - mpWriteAcc->SetPixel( nY, nX, BitmapColor( nRed, (BYTE)0, (BYTE)0 ) ); + mpWriteAcc->SetPixel( nY, nX, BitmapColor( nRed, (sal_uInt8)0, (sal_uInt8)0 ) ); if ( ++nX == mpFileHeader->nColumns ) { nX = 0; @@ -483,12 +483,12 @@ BOOL PSDReader::ImplReadBody() } else // a raw packet { - for ( USHORT i = 0; i < ( ( nRunCount & 0x7f ) + 1 ); i++ ) + for ( sal_uInt16 i = 0; i < ( ( nRunCount & 0x7f ) + 1 ); i++ ) { *mpPSD >> nRed; if ( mpFileHeader->nDepth == 16 ) // 16 bit depth is to be skipped *mpPSD >> nDummy; - mpWriteAcc->SetPixel( nY, nX, BitmapColor( nRed, (BYTE)0, (BYTE)0 ) ); + mpWriteAcc->SetPixel( nY, nX, BitmapColor( nRed, (sal_uInt8)0, (sal_uInt8)0 ) ); if ( ++nX == mpFileHeader->nColumns ) { nX = 0; @@ -509,7 +509,7 @@ BOOL PSDReader::ImplReadBody() *mpPSD >> nGreen; if ( mpFileHeader->nDepth == 16 ) // 16 bit depth is to be skipped *mpPSD >> nDummy; - for ( USHORT i = 0; i < ( -nRunCount + 1 ); i++ ) + for ( sal_uInt16 i = 0; i < ( -nRunCount + 1 ); i++ ) { aBitmapColor = mpReadAcc->GetPixel( nY, nX ); mpWriteAcc->SetPixel( nY, nX, BitmapColor( aBitmapColor.GetRed(), nGreen, aBitmapColor.GetBlue() ) ); @@ -524,7 +524,7 @@ BOOL PSDReader::ImplReadBody() } else // a raw packet { - for ( USHORT i = 0; i < ( ( nRunCount & 0x7f ) + 1 ); i++ ) + for ( sal_uInt16 i = 0; i < ( ( nRunCount & 0x7f ) + 1 ); i++ ) { *mpPSD >> nGreen; if ( mpFileHeader->nDepth == 16 ) // 16 bit depth is to be skipped @@ -551,7 +551,7 @@ BOOL PSDReader::ImplReadBody() *mpPSD >> nBlue; if ( mpFileHeader->nDepth == 16 ) // 16 bit depth is to be skipped *mpPSD >> nDummy; - for ( USHORT i = 0; i < ( -nRunCount + 1 ); i++ ) + for ( sal_uInt16 i = 0; i < ( -nRunCount + 1 ); i++ ) { aBitmapColor = mpReadAcc->GetPixel( nY, nX ); mpWriteAcc->SetPixel( nY, nX, BitmapColor( aBitmapColor.GetRed(), aBitmapColor.GetGreen(), nBlue ) ); @@ -566,7 +566,7 @@ BOOL PSDReader::ImplReadBody() } else // a raw packet { - for ( USHORT i = 0; i < ( ( nRunCount & 0x7f ) + 1 ); i++ ) + for ( sal_uInt16 i = 0; i < ( ( nRunCount & 0x7f ) + 1 ); i++ ) { *mpPSD >> nBlue; if ( mpFileHeader->nDepth == 16 ) // 16 bit depth is to be skipped @@ -585,8 +585,8 @@ BOOL PSDReader::ImplReadBody() } if ( mpFileHeader->nMode == PSD_CMYK ) { - UINT32 nBlack, nBlackMax = 0; - BYTE* pBlack = new BYTE[ mpFileHeader->nRows * mpFileHeader->nColumns ]; + sal_uInt32 nBlack, nBlackMax = 0; + sal_uInt8* pBlack = new sal_uInt8[ mpFileHeader->nRows * mpFileHeader->nColumns ]; nY = 0; while ( nY < mpFileHeader->nRows ) { @@ -600,15 +600,15 @@ BOOL PSDReader::ImplReadBody() if ( mpFileHeader->nDepth == 16 ) // 16 bit depth is to be skipped *mpPSD >> nDummy; - for ( USHORT i = 0; i < ( -nRunCount + 1 ); i++ ) + for ( sal_uInt16 i = 0; i < ( -nRunCount + 1 ); i++ ) { - nBlack = (BYTE)mpReadAcc->GetPixel( nY, nX ).GetRed() + nDat; + nBlack = (sal_uInt8)mpReadAcc->GetPixel( nY, nX ).GetRed() + nDat; if ( nBlack > nBlackMax ) nBlackMax = nBlack; - nBlack = (BYTE)mpReadAcc->GetPixel( nY, nX ).GetGreen() + nDat; + nBlack = (sal_uInt8)mpReadAcc->GetPixel( nY, nX ).GetGreen() + nDat; if ( nBlack > nBlackMax ) nBlackMax = nBlack; - nBlack = (BYTE)mpReadAcc->GetPixel( nY, nX ).GetBlue() + nDat; + nBlack = (sal_uInt8)mpReadAcc->GetPixel( nY, nX ).GetBlue() + nDat; if ( nBlack > nBlackMax ) nBlackMax = nBlack; pBlack[ nX + nY * mpFileHeader->nColumns ] = nDat ^ 0xff; @@ -623,19 +623,19 @@ BOOL PSDReader::ImplReadBody() } else // a raw packet { - for ( USHORT i = 0; i < ( ( nRunCount & 0x7f ) + 1 ); i++ ) + for ( sal_uInt16 i = 0; i < ( ( nRunCount & 0x7f ) + 1 ); i++ ) { *mpPSD >> nDat; if ( mpFileHeader->nDepth == 16 ) // 16 bit depth is to be skipped *mpPSD >> nDummy; - nBlack = (BYTE)mpReadAcc->GetPixel( nY, nX ).GetRed() + nDat; + nBlack = (sal_uInt8)mpReadAcc->GetPixel( nY, nX ).GetRed() + nDat; if ( nBlack > nBlackMax ) nBlackMax = nBlack; - nBlack = (BYTE)mpReadAcc->GetPixel( nY, nX ).GetGreen() + nDat; + nBlack = (sal_uInt8)mpReadAcc->GetPixel( nY, nX ).GetGreen() + nDat; if ( nBlack > nBlackMax ) nBlackMax = nBlack; - nBlack = (BYTE)mpReadAcc->GetPixel( nY, nX ).GetBlue() + nDat; + nBlack = (sal_uInt8)mpReadAcc->GetPixel( nY, nX ).GetBlue() + nDat; if ( nBlack > nBlackMax ) nBlackMax = nBlack; pBlack[ nX + nY * mpFileHeader->nColumns ] = nDat ^ 0xff; @@ -654,12 +654,12 @@ BOOL PSDReader::ImplReadBody() { for ( nX = 0; nX < mpFileHeader->nColumns; nX++ ) { - INT32 nDAT = pBlack[ nX + nY * mpFileHeader->nColumns ] * ( nBlackMax - 256 ) / 0x1ff; + sal_Int32 nDAT = pBlack[ nX + nY * mpFileHeader->nColumns ] * ( nBlackMax - 256 ) / 0x1ff; aBitmapColor = mpReadAcc->GetPixel( nY, nX ); - BYTE cR = (BYTE) MinMax( aBitmapColor.GetRed() - nDAT, 0L, 255L ); - BYTE cG = (BYTE) MinMax( aBitmapColor.GetGreen() - nDAT, 0L, 255L ); - BYTE cB = (BYTE) MinMax( aBitmapColor.GetBlue() - nDAT, 0L, 255L ); + sal_uInt8 cR = (sal_uInt8) MinMax( aBitmapColor.GetRed() - nDAT, 0L, 255L ); + sal_uInt8 cG = (sal_uInt8) MinMax( aBitmapColor.GetGreen() - nDAT, 0L, 255L ); + sal_uInt8 cB = (sal_uInt8) MinMax( aBitmapColor.GetBlue() - nDAT, 0L, 255L ); mpWriteAcc->SetPixel( nY, nX, BitmapColor( cR, cG, cB ) ); } } @@ -688,9 +688,9 @@ BOOL PSDReader::ImplReadBody() nDat = 1; if ( mpFileHeader->nDepth == 16 ) // 16 bit depth is to be skipped *mpPSD >> nDummy; - for ( USHORT i = 0; i < ( -nRunCount + 1 ); i++ ) + for ( sal_uInt16 i = 0; i < ( -nRunCount + 1 ); i++ ) { - mpMaskWriteAcc->SetPixel( nY, nX, (BYTE)nDat ); + mpMaskWriteAcc->SetPixel( nY, nX, (sal_uInt8)nDat ); if ( ++nX == mpFileHeader->nColumns ) { nX = 0; @@ -702,7 +702,7 @@ BOOL PSDReader::ImplReadBody() } else // a raw packet { - for ( USHORT i = 0; i < ( ( nRunCount & 0x7f ) + 1 ); i++ ) + for ( sal_uInt16 i = 0; i < ( ( nRunCount & 0x7f ) + 1 ); i++ ) { *mpPSD >> nDat; if ( nDat ) @@ -711,7 +711,7 @@ BOOL PSDReader::ImplReadBody() nDat = 1; if ( mpFileHeader->nDepth == 16 ) // 16 bit depth is to be skipped *mpPSD >> nDummy; - mpMaskWriteAcc->SetPixel( nY, nX, (BYTE)nDat ); + mpMaskWriteAcc->SetPixel( nY, nX, (sal_uInt8)nDat ); if ( ++nX == mpFileHeader->nColumns ) { nX = 0; @@ -723,12 +723,12 @@ BOOL PSDReader::ImplReadBody() } } } - return TRUE; + return sal_True; } //================== GraphicImport - die exportierte Funktion ================ -extern "C" BOOL __LOADONCALLAPI GraphicImport(SvStream & rStream, Graphic & rGraphic, FilterConfigItem*, BOOL ) +extern "C" sal_Bool __LOADONCALLAPI GraphicImport(SvStream & rStream, Graphic & rGraphic, FilterConfigItem*, sal_Bool ) { PSDReader aPSDReader; |