52 std::unique_ptr<vcl::bitmap::RawBitmap>
mpBitmap;
60 PCDResolution eResolution;
68 sal_uInt32 nBMPHeight;
70 void CheckPCDImagePacFile();
73 void ReadOrientation();
80 explicit PCDReader(
SvStream &rStream)
84 , eResolution(PCDRES_BASE16)
105 CheckPCDImagePacFile();
111 eResolution = PCDRES_BASE;
114 sal_Int32 nResolution = pConfigItem->
ReadInt32(
"Resolution", 2 );
115 if ( nResolution == 1 )
116 eResolution = PCDRES_BASE4;
117 else if ( nResolution == 0 )
118 eResolution = PCDRES_BASE16;
146 if ( ( nOrientation & 0x01 ) == 0 )
149 nBMPHeight = nHeight;
165void PCDReader::CheckPCDImagePacFile()
170 m_rPCD.ReadBytes(Buf, 7);
172 if (!m_rPCD.good() || Buf != std::string_view(
"PCD_IPI"))
176void PCDReader::ReadOrientation()
180 m_rPCD.Seek( 194635 );
181 m_rPCD.ReadUChar( nOrientation );
182 nOrientation &= 0x03;
185void PCDReader::ReadImage()
192 sal_uInt32 nW2 = nWidth>>1;
193 sal_uInt32 nH2 = nHeight>>1;
196 std::vector<sal_uInt8> aL0(nWidth);
198 std::vector<sal_uInt8> aL1(nWidth);
200 std::vector<sal_uInt8> aCb(nW2 + 1);
202 std::vector<sal_uInt8> aCr(nW2 + 1);
204 std::vector<sal_uInt8> aL0N(nWidth);
205 std::vector<sal_uInt8> aL1N(nWidth);
206 std::vector<sal_uInt8> aCbN(nW2 + 1);
207 std::vector<sal_uInt8> aCrN(nW2 + 1);
218 m_rPCD.Seek( nImagePos );
221 if (m_rPCD.ReadBytes(pL0N, nWidth) != nWidth ||
222 m_rPCD.ReadBytes(pL1N, nWidth) != nWidth ||
223 m_rPCD.ReadBytes(pCbN, nW2) != nW2 ||
224 m_rPCD.ReadBytes(pCrN, nW2) != nW2)
229 pCbN[ nW2 ] = pCbN[ nW2 - 1 ];
230 pCrN[ nW2 ] = pCrN[ nW2 - 1 ];
232 for (sal_uInt32 nYPair = 0; nYPair < nH2; ++nYPair)
236 pt=pL0; pL0=pL0N; pL0N=
pt;
237 pt=pL1; pL1=pL1N; pL1N=
pt;
238 pt=pCb; pCb=pCbN; pCbN=
pt;
239 pt=pCr; pCr=pCrN; pCrN=
pt;
242 if ( nYPair < nH2 - 1 )
244 m_rPCD.ReadBytes( pL0N, nWidth );
245 m_rPCD.ReadBytes( pL1N, nWidth );
246 m_rPCD.ReadBytes( pCbN, nW2 );
247 m_rPCD.ReadBytes( pCrN, nW2 );
248 pCbN[nW2]=pCbN[ nW2 - 1 ];
249 pCrN[nW2]=pCrN[ nW2 - 1 ];
253 for (sal_uInt32 nXPair = 0; nXPair < nW2; ++nXPair)
255 pCbN[ nXPair ] = pCb[ nXPair ];
256 pCrN[ nXPair ] = pCr[ nXPair ];
261 for (sal_uInt32 ndy = 0; ndy < 2; ++ndy)
263 sal_uInt32
ny = ( nYPair << 1 ) + ndy;
266 for (sal_uInt32 nx = 0;
nx < nWidth; ++
nx)
269 sal_uInt32 nXPair =
nx >> 1;
273 if (( nx & 1 ) == 0 )
286 if ( ( nx & 1 ) == 0 )
303 tools::Long nRed = ( nL + nCr * 119374 + 0x8000 ) >> 16;
308 tools::Long nGreen = ( nL - nCb * 28198 - nCr * 60761 + 0x8000 ) >> 16;
313 tools::Long nBlue = ( nL + nCb * 145352 + 0x8000 ) >> 16;
320 if ( nOrientation < 2 )
322 if ( nOrientation == 0 )
329 if ( nOrientation == 2 )
337 if ( m_rPCD.GetError() )
348 PCDReader aPCDReader(rStream);
349 return aPCDReader.ReadPCD(rGraphic, pConfigItem);
sal_Int32 ReadInt32(const OUString &rKey, sal_Int32 nDefault)
Intended to be used to feed into CreateFromData to create a BitmapEx.
bool ImportPcdGraphic(SvStream &rStream, Graphic &rGraphic, FilterConfigItem *pConfigItem)
BitmapEx CreateFromData(sal_uInt8 const *pData, sal_Int32 nWidth, sal_Int32 nHeight, sal_Int32 nStride, sal_Int8 nBitCount, bool bReversColors, bool bReverseAlpha)
Copy block of image data into the bitmap.