summaryrefslogtreecommitdiff
path: root/filter
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2021-02-15 10:23:27 +0900
committerTomaž Vajngerl <quikee@gmail.com>2021-02-17 05:54:36 +0100
commit68012eaaab9968f6ccfdfc018bcc5befa36a7a2f (patch)
tree4e8bb8efdcca069906f0d1c9d87cc8cc2daf6d8b /filter
parentd338dc277d7dbe381d669728e30a1c2606a4814a (diff)
Move PCD reader from filter module into VCL
Change-Id: Icd23d1343f5231c09dd8197943ca472f4b573bfc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111018 Tested-by: Tomaž Vajngerl <quikee@gmail.com> Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'filter')
-rw-r--r--filter/CppunitTest_filter_pcd_test.mk38
-rw-r--r--filter/Library_gie.mk1
-rw-r--r--filter/Module_filter.mk1
-rw-r--r--filter/qa/cppunit/data/pcd/fail/.gitignore0
-rw-r--r--filter/qa/cppunit/data/pcd/indeterminate/.gitignore1
-rw-r--r--filter/qa/cppunit/data/pcd/pass/.gitignore0
-rw-r--r--filter/qa/cppunit/data/pcd/pass/blank-square.pcdbin788480 -> 0 bytes
-rw-r--r--filter/qa/cppunit/filters-pcd-test.cxx67
-rw-r--r--filter/source/config/fragments/internalgraphicfilters/pcd_Import_Base.xcu21
-rw-r--r--filter/source/config/fragments/internalgraphicfilters/pcd_Import_Base16.xcu21
-rw-r--r--filter/source/config/fragments/internalgraphicfilters/pcd_Import_Base4.xcu21
-rw-r--r--filter/source/graphicfilter/ipcd/ipcd.cxx363
12 files changed, 33 insertions, 501 deletions
diff --git a/filter/CppunitTest_filter_pcd_test.mk b/filter/CppunitTest_filter_pcd_test.mk
deleted file mode 100644
index 3741d5c9bf5a..000000000000
--- a/filter/CppunitTest_filter_pcd_test.mk
+++ /dev/null
@@ -1,38 +0,0 @@
-# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
-#
-# This file is part of the LibreOffice project.
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-#
-
-$(eval $(call gb_CppunitTest_CppunitTest,filter_pcd_test))
-
-$(eval $(call gb_CppunitTest_use_external,filter_pcd_test,boost_headers))
-
-$(eval $(call gb_CppunitTest_add_exception_objects,filter_pcd_test, \
- filter/qa/cppunit/filters-pcd-test \
-))
-
-$(eval $(call gb_CppunitTest_use_libraries,filter_pcd_test, \
- gie \
- sal \
- test \
- tl \
- unotest \
- vcl \
-))
-
-$(eval $(call gb_CppunitTest_use_sdk_api,filter_pcd_test))
-
-$(eval $(call gb_CppunitTest_use_ure,filter_pcd_test))
-$(eval $(call gb_CppunitTest_use_vcl,filter_pcd_test))
-
-$(eval $(call gb_CppunitTest_use_components,filter_pcd_test,\
- configmgr/source/configmgr \
-))
-
-$(eval $(call gb_CppunitTest_use_configuration,filter_pcd_test))
-
-# vim: set noet sw=4 ts=4:
diff --git a/filter/Library_gie.mk b/filter/Library_gie.mk
index 29e7b131fae4..d5ab8b8169a5 100644
--- a/filter/Library_gie.mk
+++ b/filter/Library_gie.mk
@@ -60,7 +60,6 @@ $(eval $(call gb_Library_add_exception_objects,gie,\
filter/source/graphicfilter/idxf/dxftblrd \
filter/source/graphicfilter/idxf/dxfvec \
filter/source/graphicfilter/idxf/idxf \
- filter/source/graphicfilter/ipcd/ipcd \
))
# vim: set noet sw=4 ts=4:
diff --git a/filter/Module_filter.mk b/filter/Module_filter.mk
index 82eade49ffa1..678c882dce88 100644
--- a/filter/Module_filter.mk
+++ b/filter/Module_filter.mk
@@ -56,7 +56,6 @@ $(eval $(call gb_Module_add_check_targets,filter,\
ifneq ($(DISABLE_CVE_TESTS),TRUE)
$(eval $(call gb_Module_add_check_targets,filter,\
CppunitTest_filter_dxf_test \
- CppunitTest_filter_pcd_test \
CppunitTest_filter_ppm_test \
CppunitTest_filter_svg \
))
diff --git a/filter/qa/cppunit/data/pcd/fail/.gitignore b/filter/qa/cppunit/data/pcd/fail/.gitignore
deleted file mode 100644
index e69de29bb2d1..000000000000
--- a/filter/qa/cppunit/data/pcd/fail/.gitignore
+++ /dev/null
diff --git a/filter/qa/cppunit/data/pcd/indeterminate/.gitignore b/filter/qa/cppunit/data/pcd/indeterminate/.gitignore
deleted file mode 100644
index 23ad7d155635..000000000000
--- a/filter/qa/cppunit/data/pcd/indeterminate/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-*.pcd-*
diff --git a/filter/qa/cppunit/data/pcd/pass/.gitignore b/filter/qa/cppunit/data/pcd/pass/.gitignore
deleted file mode 100644
index e69de29bb2d1..000000000000
--- a/filter/qa/cppunit/data/pcd/pass/.gitignore
+++ /dev/null
diff --git a/filter/qa/cppunit/data/pcd/pass/blank-square.pcd b/filter/qa/cppunit/data/pcd/pass/blank-square.pcd
deleted file mode 100644
index a626b5f2309b..000000000000
--- a/filter/qa/cppunit/data/pcd/pass/blank-square.pcd
+++ /dev/null
Binary files differ
diff --git a/filter/qa/cppunit/filters-pcd-test.cxx b/filter/qa/cppunit/filters-pcd-test.cxx
deleted file mode 100644
index dc32e33469e7..000000000000
--- a/filter/qa/cppunit/filters-pcd-test.cxx
+++ /dev/null
@@ -1,67 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- */
-
-#include <unotest/filters-test.hxx>
-#include <test/bootstrapfixture.hxx>
-#include <vcl/FilterConfigItem.hxx>
-#include <tools/stream.hxx>
-#include <vcl/graph.hxx>
-
-extern "C"
-{
- SAL_DLLPUBLIC_EXPORT bool SAL_CALL
- icdGraphicImport(SvStream & rStream, Graphic & rGraphic,
- FilterConfigItem*);
-}
-
-using namespace ::com::sun::star;
-
-/* Implementation of Filters test */
-
-class PcdFilterTest
- : public test::FiltersTest
- , public test::BootstrapFixture
-{
-public:
- PcdFilterTest() : BootstrapFixture(true, false) {}
-
- virtual bool load(const OUString &,
- const OUString &rURL, const OUString &,
- SfxFilterFlags, SotClipboardFormatId, unsigned int) override;
-
- /**
- * Ensure CVEs remain unbroken
- */
- void testCVEs();
-
- CPPUNIT_TEST_SUITE(PcdFilterTest);
- CPPUNIT_TEST(testCVEs);
- CPPUNIT_TEST_SUITE_END();
-};
-
-bool PcdFilterTest::load(const OUString &,
- const OUString &rURL, const OUString &,
- SfxFilterFlags, SotClipboardFormatId, unsigned int)
-{
- SvFileStream aFileStream(rURL, StreamMode::READ);
- Graphic aGraphic;
- return icdGraphicImport(aFileStream, aGraphic, nullptr);
-}
-
-void PcdFilterTest::testCVEs()
-{
- testDir(OUString(),
- m_directories.getURLFromSrc(u"/filter/qa/cppunit/data/pcd/"));
-}
-
-CPPUNIT_TEST_SUITE_REGISTRATION(PcdFilterTest);
-
-CPPUNIT_PLUGIN_IMPLEMENT();
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/filter/source/config/fragments/internalgraphicfilters/pcd_Import_Base.xcu b/filter/source/config/fragments/internalgraphicfilters/pcd_Import_Base.xcu
index c5a0094b86e4..29c7b846ddae 100644
--- a/filter/source/config/fragments/internalgraphicfilters/pcd_Import_Base.xcu
+++ b/filter/source/config/fragments/internalgraphicfilters/pcd_Import_Base.xcu
@@ -15,13 +15,14 @@
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
-->
- <node oor:name="pcd_Import_Base" oor:op="replace" >
- <prop oor:name="Type"><value>pcd_Photo_CD_Base</value></prop>
- <prop oor:name="FormatName"><value>icd</value></prop>
- <prop oor:name="RealFilterName"><value>draw_PCD_Photo_CD_Base</value></prop>
- <prop oor:name="UIComponent"/>
- <prop oor:name="UIName">
- <value xml:lang="en-US">PCD - Kodak Photo CD (768x512)</value>
- </prop>
- <prop oor:name="Flags"><value>IMPORT</value></prop>
- </node>
+
+<node oor:name="pcd_Import_Base" oor:op="replace" >
+ <prop oor:name="Type"><value>pcd_Photo_CD_Base</value></prop>
+ <prop oor:name="FormatName"><value>SVPCD</value></prop>
+ <prop oor:name="RealFilterName"><value>draw_PCD_Photo_CD_Base</value></prop>
+ <prop oor:name="UIComponent"/>
+ <prop oor:name="UIName">
+ <value xml:lang="en-US">PCD - Kodak Photo CD (768x512)</value>
+ </prop>
+ <prop oor:name="Flags"><value>IMPORT</value></prop>
+</node>
diff --git a/filter/source/config/fragments/internalgraphicfilters/pcd_Import_Base16.xcu b/filter/source/config/fragments/internalgraphicfilters/pcd_Import_Base16.xcu
index 27a471a2c75f..b61fde810697 100644
--- a/filter/source/config/fragments/internalgraphicfilters/pcd_Import_Base16.xcu
+++ b/filter/source/config/fragments/internalgraphicfilters/pcd_Import_Base16.xcu
@@ -15,13 +15,14 @@
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
-->
- <node oor:name="pcd_Import_Base16" oor:op="replace" >
- <prop oor:name="Type"><value>pcd_Photo_CD_Base16</value></prop>
- <prop oor:name="FormatName"><value>icd</value></prop>
- <prop oor:name="RealFilterName"><value>draw_PCD_Photo_CD_Base16</value></prop>
- <prop oor:name="UIComponent"/>
- <prop oor:name="UIName">
- <value xml:lang="en-US">PCD - Kodak Photo CD (192x128)</value>
- </prop>
- <prop oor:name="Flags"><value>IMPORT</value></prop>
- </node>
+
+<node oor:name="pcd_Import_Base16" oor:op="replace" >
+ <prop oor:name="Type"><value>pcd_Photo_CD_Base16</value></prop>
+ <prop oor:name="FormatName"><value>SVPCD</value></prop>
+ <prop oor:name="RealFilterName"><value>draw_PCD_Photo_CD_Base16</value></prop>
+ <prop oor:name="UIComponent"/>
+ <prop oor:name="UIName">
+ <value xml:lang="en-US">PCD - Kodak Photo CD (192x128)</value>
+ </prop>
+ <prop oor:name="Flags"><value>IMPORT</value></prop>
+</node>
diff --git a/filter/source/config/fragments/internalgraphicfilters/pcd_Import_Base4.xcu b/filter/source/config/fragments/internalgraphicfilters/pcd_Import_Base4.xcu
index ba5f536b9a45..15d51918a09b 100644
--- a/filter/source/config/fragments/internalgraphicfilters/pcd_Import_Base4.xcu
+++ b/filter/source/config/fragments/internalgraphicfilters/pcd_Import_Base4.xcu
@@ -15,13 +15,14 @@
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
-->
- <node oor:name="pcd_Import_Base4" oor:op="replace" >
- <prop oor:name="Type"><value>pcd_Photo_CD_Base4</value></prop>
- <prop oor:name="FormatName"><value>icd</value></prop>
- <prop oor:name="RealFilterName"><value>draw_PCD_Photo_CD_Base4</value></prop>
- <prop oor:name="UIComponent"/>
- <prop oor:name="UIName">
- <value xml:lang="en-US">PCD - Kodak Photo CD (384x256)</value>
- </prop>
- <prop oor:name="Flags"><value>IMPORT</value></prop>
- </node>
+
+<node oor:name="pcd_Import_Base4" oor:op="replace" >
+ <prop oor:name="Type"><value>pcd_Photo_CD_Base4</value></prop>
+ <prop oor:name="FormatName"><value>SVPCD</value></prop>
+ <prop oor:name="RealFilterName"><value>draw_PCD_Photo_CD_Base4</value></prop>
+ <prop oor:name="UIComponent"/>
+ <prop oor:name="UIName">
+ <value xml:lang="en-US">PCD - Kodak Photo CD (384x256)</value>
+ </prop>
+ <prop oor:name="Flags"><value>IMPORT</value></prop>
+</node>
diff --git a/filter/source/graphicfilter/ipcd/ipcd.cxx b/filter/source/graphicfilter/ipcd/ipcd.cxx
deleted file mode 100644
index b2b585606286..000000000000
--- a/filter/source/graphicfilter/ipcd/ipcd.cxx
+++ /dev/null
@@ -1,363 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-
-#include <vcl/graph.hxx>
-#include <vcl/BitmapTools.hxx>
-#include <vcl/FilterConfigItem.hxx>
-#include <tools/stream.hxx>
-
-//============================ PCDReader ==================================
-
-namespace {
-
-// these resolutions are contained in a PCD file:
-enum PCDResolution {
- PCDRES_BASE16, // 192 x 128
- PCDRES_BASE4, // 384 x 256
- PCDRES_BASE, // 768 x 512
- // the following ones are compressed
- // and CANNOT be read by us
- PCDRES_4BASE, // 1536 x 1024
- PCDRES_16BASE // 3072 x 3072
-};
-
-class PCDReader {
-
-private:
-
- bool bStatus;
-
- SvStream &m_rPCD;
- std::unique_ptr<vcl::bitmap::RawBitmap> mpBitmap;
-
- sal_uInt8 nOrientation; // orientation of the picture within the PCD file:
- // 0 - spire point up
- // 1 - spire points to the right
- // 2 - spire points down
- // 3 - spire points to the left
-
- PCDResolution eResolution; // which resolution we want
-
- sal_uInt32 nWidth; // width of the PCD picture
- sal_uInt32 nHeight; // height of the PCD picture
- sal_uInt32 nImagePos; // position of the picture within the PCD file
-
- // temporary lLue-Green-Red-Bitmap
- sal_uInt32 nBMPWidth;
- sal_uInt32 nBMPHeight;
-
- void CheckPCDImagePacFile();
- // checks whether it's a Photo-CD file with 'Image Pac'
-
- void ReadOrientation();
- // reads the orientation and sets nOrientation
-
- void ReadImage();
-
-public:
-
- explicit PCDReader(SvStream &rStream)
- : bStatus(false)
- , m_rPCD(rStream)
- , nOrientation(0)
- , eResolution(PCDRES_BASE16)
- , nWidth(0)
- , nHeight(0)
- , nImagePos(0)
- , nBMPWidth(0)
- , nBMPHeight(0)
- {
- }
-
- bool ReadPCD( Graphic & rGraphic, FilterConfigItem* pConfigItem );
-};
-
-}
-
-//=================== Methods of PCDReader ==============================
-
-bool PCDReader::ReadPCD( Graphic & rGraphic, FilterConfigItem* pConfigItem )
-{
- bStatus = true;
-
- // is it a PCD file with a picture? ( sets bStatus == sal_False, if that's not the case):
- CheckPCDImagePacFile();
-
- // read orientation of the picture:
- ReadOrientation();
-
- // which resolution do we want?:
- eResolution = PCDRES_BASE;
- if ( pConfigItem )
- {
- sal_Int32 nResolution = pConfigItem->ReadInt32( "Resolution", 2 );
- if ( nResolution == 1 )
- eResolution = PCDRES_BASE4;
- else if ( nResolution == 0 )
- eResolution = PCDRES_BASE16;
- }
- // determine size and position (position within the PCD file) of the picture:
- switch (eResolution)
- {
- case PCDRES_BASE16 :
- nWidth = 192;
- nHeight = 128;
- nImagePos = 8192;
- break;
-
- case PCDRES_BASE4 :
- nWidth = 384;
- nHeight = 256;
- nImagePos = 47104;
- break;
-
- case PCDRES_BASE :
- nWidth = 768;
- nHeight = 512;
- nImagePos = 196608;
- break;
-
- default:
- bStatus = false;
- }
- if ( bStatus )
- {
- if ( ( nOrientation & 0x01 ) == 0 )
- {
- nBMPWidth = nWidth;
- nBMPHeight = nHeight;
- }
- else
- {
- nBMPWidth = nHeight;
- nBMPHeight = nWidth;
- }
- mpBitmap.reset(new vcl::bitmap::RawBitmap( Size( nBMPWidth, nBMPHeight ), 24 ));
-
- ReadImage();
-
- rGraphic = vcl::bitmap::CreateFromData(std::move(*mpBitmap));
- }
- return bStatus;
-}
-
-
-void PCDReader::CheckPCDImagePacFile()
-{
- char Buf[ 8 ];
-
- m_rPCD.Seek( 2048 );
- m_rPCD.ReadBytes(Buf, 7);
- Buf[ 7 ] = 0;
- if (OString(Buf) != "PCD_IPI")
- bStatus = false;
-}
-
-
-void PCDReader::ReadOrientation()
-{
- if ( !bStatus )
- return;
- m_rPCD.Seek( 194635 );
- m_rPCD.ReadUChar( nOrientation );
- nOrientation &= 0x03;
-}
-
-
-void PCDReader::ReadImage()
-{
- sal_uInt32 nx,ny,nW2,nH2,nYPair,ndy,nXPair;
- tools::Long nL,nCb,nCr,nRed,nGreen,nBlue;
- sal_uInt8 * pt;
- sal_uInt8 * pL0; // luminance for each pixel of the 1st row of the current pair of rows
- sal_uInt8 * pL1; // luminance for each pixel of the 2nd row of the current pair of rows
- sal_uInt8 * pCb; // blue chrominance for each 2x2 pixel of the current pair of rows
- sal_uInt8 * pCr; // red chrominance for each 2x2 pixel of the current pair of rows
- sal_uInt8 * pL0N, * pL1N, * pCbN, * pCrN; // like above, but for the next pair of rows
-
- if ( !bStatus )
- return;
-
- nW2=nWidth>>1;
- nH2=nHeight>>1;
-
- pL0 =static_cast<sal_uInt8*>(std::malloc( nWidth ));
- pL1 =static_cast<sal_uInt8*>(std::malloc( nWidth ));
- pCb =static_cast<sal_uInt8*>(std::malloc( nW2+1 ));
- pCr =static_cast<sal_uInt8*>(std::malloc( nW2+1 ));
- pL0N=static_cast<sal_uInt8*>(std::malloc( nWidth ));
- pL1N=static_cast<sal_uInt8*>(std::malloc( nWidth ));
- pCbN=static_cast<sal_uInt8*>(std::malloc( nW2+1 ));
- pCrN=static_cast<sal_uInt8*>(std::malloc( nW2+1 ));
-
- if ( pL0 == nullptr || pL1 == nullptr || pCb == nullptr || pCr == nullptr ||
- pL0N == nullptr || pL1N == nullptr || pCbN == nullptr || pCrN == nullptr)
- {
- std::free(static_cast<void*>(pL0) );
- std::free(static_cast<void*>(pL1) );
- std::free(static_cast<void*>(pCb) );
- std::free(static_cast<void*>(pCr) );
- std::free(static_cast<void*>(pL0N));
- std::free(static_cast<void*>(pL1N));
- std::free(static_cast<void*>(pCbN));
- std::free(static_cast<void*>(pCrN));
- bStatus = false;
- return;
- }
-
- m_rPCD.Seek( nImagePos );
-
- // next pair of rows := first pair of rows:
- m_rPCD.ReadBytes( pL0N, nWidth );
- m_rPCD.ReadBytes( pL1N, nWidth );
- m_rPCD.ReadBytes( pCbN, nW2 );
- m_rPCD.ReadBytes( pCrN, nW2 );
- pCbN[ nW2 ] = pCbN[ nW2 - 1 ];
- pCrN[ nW2 ] = pCrN[ nW2 - 1 ];
-
- for ( nYPair = 0; nYPair < nH2; nYPair++ )
- {
- // current pair of rows := next pair of rows:
- pt=pL0; pL0=pL0N; pL0N=pt;
- pt=pL1; pL1=pL1N; pL1N=pt;
- pt=pCb; pCb=pCbN; pCbN=pt;
- pt=pCr; pCr=pCrN; pCrN=pt;
-
- // get the next pair of rows:
- if ( nYPair < nH2 - 1 )
- {
- m_rPCD.ReadBytes( pL0N, nWidth );
- m_rPCD.ReadBytes( pL1N, nWidth );
- m_rPCD.ReadBytes( pCbN, nW2 );
- m_rPCD.ReadBytes( pCrN, nW2 );
- pCbN[nW2]=pCbN[ nW2 - 1 ];
- pCrN[nW2]=pCrN[ nW2 - 1 ];
- }
- else
- {
- for ( nXPair = 0; nXPair < nW2; nXPair++ )
- {
- pCbN[ nXPair ] = pCb[ nXPair ];
- pCrN[ nXPair ] = pCr[ nXPair ];
- }
- }
-
- // loop through both rows of the pair of rows:
- for ( ndy = 0; ndy < 2; ndy++ )
- {
- ny = ( nYPair << 1 ) + ndy;
-
- // loop through X:
- for ( nx = 0; nx < nWidth; nx++ )
- {
- // get/calculate nL,nCb,nCr for the pixel nx,ny:
- nXPair = nx >> 1;
- if ( ndy == 0 )
- {
- nL = static_cast<tools::Long>(pL0[ nx ]);
- if (( nx & 1 ) == 0 )
- {
- nCb = static_cast<tools::Long>(pCb[ nXPair ]);
- nCr = static_cast<tools::Long>(pCr[ nXPair ]);
- }
- else
- {
- nCb = ( static_cast<tools::Long>(pCb[ nXPair ]) + static_cast<tools::Long>(pCb[ nXPair + 1 ]) ) >> 1;
- nCr = ( static_cast<tools::Long>(pCr[ nXPair ]) + static_cast<tools::Long>(pCr[ nXPair + 1 ]) ) >> 1;
- }
- }
- else {
- nL = pL1[ nx ];
- if ( ( nx & 1 ) == 0 )
- {
- nCb = ( static_cast<tools::Long>(pCb[ nXPair ]) + static_cast<tools::Long>(pCbN[ nXPair ]) ) >> 1;
- nCr = ( static_cast<tools::Long>(pCr[ nXPair ]) + static_cast<tools::Long>(pCrN[ nXPair ]) ) >> 1;
- }
- else
- {
- nCb = ( static_cast<tools::Long>(pCb[ nXPair ]) + static_cast<tools::Long>(pCb[ nXPair + 1 ]) +
- static_cast<tools::Long>(pCbN[ nXPair ]) + static_cast<tools::Long>(pCbN[ nXPair + 1 ]) ) >> 2;
- nCr = ( static_cast<tools::Long>(pCr[ nXPair ]) + static_cast<tools::Long>(pCr[ nXPair + 1]) +
- static_cast<tools::Long>(pCrN[ nXPair ]) + static_cast<tools::Long>(pCrN[ nXPair + 1 ]) ) >> 2;
- }
- }
- // conversion of nL,nCb,nCr in nRed,nGreen,nBlue:
- nL *= 89024;
- nCb -= 156;
- nCr -= 137;
- nRed = ( nL + nCr * 119374 + 0x8000 ) >> 16;
- if ( nRed < 0 )
- nRed = 0;
- if ( nRed > 255)
- nRed = 255;
- nGreen = ( nL - nCb * 28198 - nCr * 60761 + 0x8000 ) >> 16;
- if ( nGreen < 0 )
- nGreen = 0;
- if ( nGreen > 255 )
- nGreen = 255;
- nBlue = ( nL + nCb * 145352 + 0x8000 ) >> 16;
- if ( nBlue < 0 )
- nBlue = 0;
- if ( nBlue > 255 )
- nBlue = 255;
-
- // register color value in pBMPMap:
- if ( nOrientation < 2 )
- {
- if ( nOrientation == 0 )
- mpBitmap->SetPixel( ny, nx, Color( static_cast<sal_uInt8>(nRed), static_cast<sal_uInt8>(nGreen), static_cast<sal_uInt8>(nBlue) ) );
- else
- mpBitmap->SetPixel( nWidth - 1 - nx, ny, Color( static_cast<sal_uInt8>(nRed), static_cast<sal_uInt8>(nGreen), static_cast<sal_uInt8>(nBlue) ) );
- }
- else
- {
- if ( nOrientation == 2 )
- mpBitmap->SetPixel( nHeight - 1 - ny, ( nWidth - 1 - nx ), Color( static_cast<sal_uInt8>(nRed), static_cast<sal_uInt8>(nGreen), static_cast<sal_uInt8>(nBlue) ) );
- else
- mpBitmap->SetPixel( nx, ( nHeight - 1 - ny ), Color( static_cast<sal_uInt8>(nRed), static_cast<sal_uInt8>(nGreen), static_cast<sal_uInt8>(nBlue) ) );
- }
- }
- }
-
- if ( m_rPCD.GetError() )
- bStatus = false;
- if ( !bStatus )
- break;
- }
- std::free(static_cast<void*>(pL0) );
- std::free(static_cast<void*>(pL1) );
- std::free(static_cast<void*>(pCb) );
- std::free(static_cast<void*>(pCr) );
- std::free(static_cast<void*>(pL0N));
- std::free(static_cast<void*>(pL1N));
- std::free(static_cast<void*>(pCbN));
- std::free(static_cast<void*>(pCrN));
-}
-
-//================== GraphicImport - the exported Function ================
-
-extern "C" SAL_DLLPUBLIC_EXPORT bool
-icdGraphicImport( SvStream & rStream, Graphic & rGraphic, FilterConfigItem* pConfigItem )
-{
- PCDReader aPCDReader(rStream);
- return aPCDReader.ReadPCD(rGraphic, pConfigItem);
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */