summaryrefslogtreecommitdiff
path: root/filter
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2021-02-14 23:20:28 +0900
committerTomaž Vajngerl <quikee@gmail.com>2021-02-17 04:02:13 +0100
commit1093c21ed9736368ecfb8f5c7935db31256671f0 (patch)
treefe315c5464ee54d79f8c8b5253a62337832f2313 /filter
parente916e8c1816a17408cba52787035ffd9fbae5789 (diff)
Move RAS and PCX reader from filter module into VCL
Change-Id: Id846abf257b598489a59ebf9b62b19840a950322 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111015 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'filter')
-rw-r--r--filter/CppunitTest_filter_pcx_test.mk38
-rw-r--r--filter/CppunitTest_filter_ras_test.mk38
-rw-r--r--filter/Library_gie.mk2
-rw-r--r--filter/Module_filter.mk2
-rw-r--r--filter/qa/cppunit/data/pcx/fail/.gitignore0
-rw-r--r--filter/qa/cppunit/data/pcx/fail/CVE-2007-3741-1.pcxbin41066 -> 0 bytes
-rw-r--r--filter/qa/cppunit/data/pcx/fail/CVE-2007-3741-2.pcxbin41136 -> 0 bytes
-rw-r--r--filter/qa/cppunit/data/pcx/fail/CVE-2007-3741-3.pcxbin41107 -> 0 bytes
-rw-r--r--filter/qa/cppunit/data/pcx/fail/CVE-2008-1097-1.pcxbin91531 -> 0 bytes
-rw-r--r--filter/qa/cppunit/data/pcx/fail/hang-1.pcxbin897 -> 0 bytes
-rw-r--r--filter/qa/cppunit/data/pcx/indeterminate/.gitignore1
-rw-r--r--filter/qa/cppunit/data/pcx/pass/.gitignore0
-rw-r--r--filter/qa/cppunit/data/pcx/pass/rhbz469075-1.pcxbin58596 -> 0 bytes
-rw-r--r--filter/qa/cppunit/data/ras/fail/.gitignore0
-rw-r--r--filter/qa/cppunit/data/ras/fail/CVE-2007-2356-1.rasbin4000 -> 0 bytes
-rw-r--r--filter/qa/cppunit/data/ras/fail/CVE-2008-1097-1.rasbin92752 -> 0 bytes
-rw-r--r--filter/qa/cppunit/data/ras/fail/crash-1.rasbin913 -> 0 bytes
-rw-r--r--filter/qa/cppunit/data/ras/fail/hang-1.rasbin40 -> 0 bytes
-rw-r--r--filter/qa/cppunit/data/ras/indeterminate/.gitignore1
-rw-r--r--filter/qa/cppunit/data/ras/pass/.gitignore0
-rw-r--r--filter/qa/cppunit/data/ras/pass/marbles.rasbin4262290 -> 0 bytes
-rw-r--r--filter/qa/cppunit/filters-pcx-test.cxx67
-rw-r--r--filter/qa/cppunit/filters-ras-test.cxx67
-rw-r--r--filter/source/config/fragments/internalgraphicfilters/pcx_Import.xcu21
-rw-r--r--filter/source/config/fragments/internalgraphicfilters/ras_Import.xcu21
-rw-r--r--filter/source/graphicfilter/ipcx/ipcx.cxx411
-rw-r--r--filter/source/graphicfilter/iras/iras.cxx414
27 files changed, 22 insertions, 1061 deletions
diff --git a/filter/CppunitTest_filter_pcx_test.mk b/filter/CppunitTest_filter_pcx_test.mk
deleted file mode 100644
index 12334d75ad42..000000000000
--- a/filter/CppunitTest_filter_pcx_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_pcx_test))
-
-$(eval $(call gb_CppunitTest_use_external,filter_pcx_test,boost_headers))
-
-$(eval $(call gb_CppunitTest_add_exception_objects,filter_pcx_test, \
- filter/qa/cppunit/filters-pcx-test \
-))
-
-$(eval $(call gb_CppunitTest_use_libraries,filter_pcx_test, \
- gie \
- sal \
- test \
- tl \
- unotest \
- vcl \
-))
-
-$(eval $(call gb_CppunitTest_use_sdk_api,filter_pcx_test))
-
-$(eval $(call gb_CppunitTest_use_ure,filter_pcx_test))
-$(eval $(call gb_CppunitTest_use_vcl,filter_pcx_test))
-
-$(eval $(call gb_CppunitTest_use_components,filter_pcx_test,\
- configmgr/source/configmgr \
-))
-
-$(eval $(call gb_CppunitTest_use_configuration,filter_pcx_test))
-
-# vim: set noet sw=4 ts=4:
diff --git a/filter/CppunitTest_filter_ras_test.mk b/filter/CppunitTest_filter_ras_test.mk
deleted file mode 100644
index 50f6852a7b2b..000000000000
--- a/filter/CppunitTest_filter_ras_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_ras_test))
-
-$(eval $(call gb_CppunitTest_use_external,filter_ras_test,boost_headers))
-
-$(eval $(call gb_CppunitTest_add_exception_objects,filter_ras_test, \
- filter/qa/cppunit/filters-ras-test \
-))
-
-$(eval $(call gb_CppunitTest_use_libraries,filter_ras_test, \
- gie \
- sal \
- test \
- tl \
- unotest \
- vcl \
-))
-
-$(eval $(call gb_CppunitTest_use_sdk_api,filter_ras_test))
-
-$(eval $(call gb_CppunitTest_use_ure,filter_ras_test))
-$(eval $(call gb_CppunitTest_use_vcl,filter_ras_test))
-
-$(eval $(call gb_CppunitTest_use_components,filter_ras_test,\
- configmgr/source/configmgr \
-))
-
-$(eval $(call gb_CppunitTest_use_configuration,filter_ras_test))
-
-# vim: set noet sw=4 ts=4:
diff --git a/filter/Library_gie.mk b/filter/Library_gie.mk
index 73120a524ac3..54a1e1fb00db 100644
--- a/filter/Library_gie.mk
+++ b/filter/Library_gie.mk
@@ -52,8 +52,6 @@ $(eval $(call gb_Library_add_exception_objects,gie,\
filter/source/graphicfilter/egif/egif \
filter/source/graphicfilter/eps/eps \
filter/source/graphicfilter/egif/giflzwc \
- filter/source/graphicfilter/ipcx/ipcx \
- filter/source/graphicfilter/iras/iras \
filter/source/graphicfilter/ieps/ieps \
filter/source/graphicfilter/ipsd/ipsd \
filter/source/graphicfilter/ipbm/ipbm \
diff --git a/filter/Module_filter.mk b/filter/Module_filter.mk
index 36ba307c12fb..548e6f27c690 100644
--- a/filter/Module_filter.mk
+++ b/filter/Module_filter.mk
@@ -58,10 +58,8 @@ $(eval $(call gb_Module_add_check_targets,filter,\
CppunitTest_filter_dxf_test \
CppunitTest_filter_eps_test \
CppunitTest_filter_pcd_test \
- CppunitTest_filter_pcx_test \
CppunitTest_filter_ppm_test \
CppunitTest_filter_psd_test \
- CppunitTest_filter_ras_test \
CppunitTest_filter_svg \
))
endif
diff --git a/filter/qa/cppunit/data/pcx/fail/.gitignore b/filter/qa/cppunit/data/pcx/fail/.gitignore
deleted file mode 100644
index e69de29bb2d1..000000000000
--- a/filter/qa/cppunit/data/pcx/fail/.gitignore
+++ /dev/null
diff --git a/filter/qa/cppunit/data/pcx/fail/CVE-2007-3741-1.pcx b/filter/qa/cppunit/data/pcx/fail/CVE-2007-3741-1.pcx
deleted file mode 100644
index 915f38aec2e3..000000000000
--- a/filter/qa/cppunit/data/pcx/fail/CVE-2007-3741-1.pcx
+++ /dev/null
Binary files differ
diff --git a/filter/qa/cppunit/data/pcx/fail/CVE-2007-3741-2.pcx b/filter/qa/cppunit/data/pcx/fail/CVE-2007-3741-2.pcx
deleted file mode 100644
index 9c8a751a486d..000000000000
--- a/filter/qa/cppunit/data/pcx/fail/CVE-2007-3741-2.pcx
+++ /dev/null
Binary files differ
diff --git a/filter/qa/cppunit/data/pcx/fail/CVE-2007-3741-3.pcx b/filter/qa/cppunit/data/pcx/fail/CVE-2007-3741-3.pcx
deleted file mode 100644
index 41175653a4ca..000000000000
--- a/filter/qa/cppunit/data/pcx/fail/CVE-2007-3741-3.pcx
+++ /dev/null
Binary files differ
diff --git a/filter/qa/cppunit/data/pcx/fail/CVE-2008-1097-1.pcx b/filter/qa/cppunit/data/pcx/fail/CVE-2008-1097-1.pcx
deleted file mode 100644
index c55c64ed9a8a..000000000000
--- a/filter/qa/cppunit/data/pcx/fail/CVE-2008-1097-1.pcx
+++ /dev/null
Binary files differ
diff --git a/filter/qa/cppunit/data/pcx/fail/hang-1.pcx b/filter/qa/cppunit/data/pcx/fail/hang-1.pcx
deleted file mode 100644
index 73798ea56160..000000000000
--- a/filter/qa/cppunit/data/pcx/fail/hang-1.pcx
+++ /dev/null
Binary files differ
diff --git a/filter/qa/cppunit/data/pcx/indeterminate/.gitignore b/filter/qa/cppunit/data/pcx/indeterminate/.gitignore
deleted file mode 100644
index f73b09798145..000000000000
--- a/filter/qa/cppunit/data/pcx/indeterminate/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-*.pcx-*
diff --git a/filter/qa/cppunit/data/pcx/pass/.gitignore b/filter/qa/cppunit/data/pcx/pass/.gitignore
deleted file mode 100644
index e69de29bb2d1..000000000000
--- a/filter/qa/cppunit/data/pcx/pass/.gitignore
+++ /dev/null
diff --git a/filter/qa/cppunit/data/pcx/pass/rhbz469075-1.pcx b/filter/qa/cppunit/data/pcx/pass/rhbz469075-1.pcx
deleted file mode 100644
index d928c08908ba..000000000000
--- a/filter/qa/cppunit/data/pcx/pass/rhbz469075-1.pcx
+++ /dev/null
Binary files differ
diff --git a/filter/qa/cppunit/data/ras/fail/.gitignore b/filter/qa/cppunit/data/ras/fail/.gitignore
deleted file mode 100644
index e69de29bb2d1..000000000000
--- a/filter/qa/cppunit/data/ras/fail/.gitignore
+++ /dev/null
diff --git a/filter/qa/cppunit/data/ras/fail/CVE-2007-2356-1.ras b/filter/qa/cppunit/data/ras/fail/CVE-2007-2356-1.ras
deleted file mode 100644
index c00c27016b57..000000000000
--- a/filter/qa/cppunit/data/ras/fail/CVE-2007-2356-1.ras
+++ /dev/null
Binary files differ
diff --git a/filter/qa/cppunit/data/ras/fail/CVE-2008-1097-1.ras b/filter/qa/cppunit/data/ras/fail/CVE-2008-1097-1.ras
deleted file mode 100644
index effd654ac5e4..000000000000
--- a/filter/qa/cppunit/data/ras/fail/CVE-2008-1097-1.ras
+++ /dev/null
Binary files differ
diff --git a/filter/qa/cppunit/data/ras/fail/crash-1.ras b/filter/qa/cppunit/data/ras/fail/crash-1.ras
deleted file mode 100644
index d1abbaefcbae..000000000000
--- a/filter/qa/cppunit/data/ras/fail/crash-1.ras
+++ /dev/null
Binary files differ
diff --git a/filter/qa/cppunit/data/ras/fail/hang-1.ras b/filter/qa/cppunit/data/ras/fail/hang-1.ras
deleted file mode 100644
index 44dec67607b4..000000000000
--- a/filter/qa/cppunit/data/ras/fail/hang-1.ras
+++ /dev/null
Binary files differ
diff --git a/filter/qa/cppunit/data/ras/indeterminate/.gitignore b/filter/qa/cppunit/data/ras/indeterminate/.gitignore
deleted file mode 100644
index 60147ad08a9d..000000000000
--- a/filter/qa/cppunit/data/ras/indeterminate/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-*.ras-*
diff --git a/filter/qa/cppunit/data/ras/pass/.gitignore b/filter/qa/cppunit/data/ras/pass/.gitignore
deleted file mode 100644
index e69de29bb2d1..000000000000
--- a/filter/qa/cppunit/data/ras/pass/.gitignore
+++ /dev/null
diff --git a/filter/qa/cppunit/data/ras/pass/marbles.ras b/filter/qa/cppunit/data/ras/pass/marbles.ras
deleted file mode 100644
index 9b3fb0d853b6..000000000000
--- a/filter/qa/cppunit/data/ras/pass/marbles.ras
+++ /dev/null
Binary files differ
diff --git a/filter/qa/cppunit/filters-pcx-test.cxx b/filter/qa/cppunit/filters-pcx-test.cxx
deleted file mode 100644
index 3a28e24626fa..000000000000
--- a/filter/qa/cppunit/filters-pcx-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
- ipxGraphicImport(SvStream & rStream, Graphic & rGraphic,
- FilterConfigItem*);
-}
-
-using namespace ::com::sun::star;
-
-/* Implementation of Filters test */
-
-class PcxFilterTest
- : public test::FiltersTest
- , public test::BootstrapFixture
-{
-public:
- PcxFilterTest() : 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(PcxFilterTest);
- CPPUNIT_TEST(testCVEs);
- CPPUNIT_TEST_SUITE_END();
-};
-
-bool PcxFilterTest::load(const OUString &,
- const OUString &rURL, const OUString &,
- SfxFilterFlags, SotClipboardFormatId, unsigned int)
-{
- SvFileStream aFileStream(rURL, StreamMode::READ);
- Graphic aGraphic;
- return ipxGraphicImport(aFileStream, aGraphic, nullptr);
-}
-
-void PcxFilterTest::testCVEs()
-{
- testDir(OUString(),
- m_directories.getURLFromSrc(u"/filter/qa/cppunit/data/pcx/"));
-}
-
-CPPUNIT_TEST_SUITE_REGISTRATION(PcxFilterTest);
-
-CPPUNIT_PLUGIN_IMPLEMENT();
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/filter/qa/cppunit/filters-ras-test.cxx b/filter/qa/cppunit/filters-ras-test.cxx
deleted file mode 100644
index 2f3b678e4e0a..000000000000
--- a/filter/qa/cppunit/filters-ras-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
- iraGraphicImport(SvStream & rStream, Graphic & rGraphic,
- FilterConfigItem*);
-}
-
-using namespace ::com::sun::star;
-
-/* Implementation of Filters test */
-
-class RasFilterTest
- : public test::FiltersTest
- , public test::BootstrapFixture
-{
-public:
- RasFilterTest() : 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(RasFilterTest);
- CPPUNIT_TEST(testCVEs);
- CPPUNIT_TEST_SUITE_END();
-};
-
-bool RasFilterTest::load(const OUString &,
- const OUString &rURL, const OUString &,
- SfxFilterFlags, SotClipboardFormatId, unsigned int)
-{
- SvFileStream aFileStream(rURL, StreamMode::READ);
- Graphic aGraphic;
- return iraGraphicImport(aFileStream, aGraphic, nullptr);
-}
-
-void RasFilterTest::testCVEs()
-{
- testDir(OUString(),
- m_directories.getURLFromSrc(u"/filter/qa/cppunit/data/ras/"));
-}
-
-CPPUNIT_TEST_SUITE_REGISTRATION(RasFilterTest);
-
-CPPUNIT_PLUGIN_IMPLEMENT();
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/filter/source/config/fragments/internalgraphicfilters/pcx_Import.xcu b/filter/source/config/fragments/internalgraphicfilters/pcx_Import.xcu
index 4f8eb67340e4..da49344d4e60 100644
--- a/filter/source/config/fragments/internalgraphicfilters/pcx_Import.xcu
+++ b/filter/source/config/fragments/internalgraphicfilters/pcx_Import.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="pcx_Import" oor:op="replace" >
- <prop oor:name="Type"><value>pcx_Zsoft_Paintbrush</value></prop>
- <prop oor:name="FormatName"><value>ipx</value></prop>
- <prop oor:name="RealFilterName"><value>PCX - Zsoft Paintbrush</value></prop>
- <prop oor:name="UIComponent"/>
- <prop oor:name="UIName">
- <value xml:lang="en-US">PCX - Zsoft Paintbrush</value>
- </prop>
- <prop oor:name="Flags"><value>IMPORT</value></prop>
- </node>
+
+<node oor:name="pcx_Import" oor:op="replace" >
+ <prop oor:name="Type"><value>pcx_Zsoft_Paintbrush</value></prop>
+ <prop oor:name="FormatName"><value>SVPCX</value></prop>
+ <prop oor:name="RealFilterName"><value>PCX - Zsoft Paintbrush</value></prop>
+ <prop oor:name="UIComponent"/>
+ <prop oor:name="UIName">
+ <value xml:lang="en-US">PCX - Zsoft Paintbrush</value>
+ </prop>
+ <prop oor:name="Flags"><value>IMPORT</value></prop>
+</node>
diff --git a/filter/source/config/fragments/internalgraphicfilters/ras_Import.xcu b/filter/source/config/fragments/internalgraphicfilters/ras_Import.xcu
index 95108022b03a..7e9a3b2bbc07 100644
--- a/filter/source/config/fragments/internalgraphicfilters/ras_Import.xcu
+++ b/filter/source/config/fragments/internalgraphicfilters/ras_Import.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="ras_Import" oor:op="replace" >
- <prop oor:name="Type"><value>ras_Sun_Rasterfile</value></prop>
- <prop oor:name="FormatName"><value>ira</value></prop>
- <prop oor:name="RealFilterName"><value>RAS - Sun Rasterfile</value></prop>
- <prop oor:name="UIComponent"/>
- <prop oor:name="UIName">
- <value xml:lang="en-US">RAS - Sun Raster Image</value>
- </prop>
- <prop oor:name="Flags"><value>IMPORT</value></prop>
- </node>
+
+<node oor:name="ras_Import" oor:op="replace" >
+ <prop oor:name="Type"><value>ras_Sun_Rasterfile</value></prop>
+ <prop oor:name="FormatName"><value>SVRAS</value></prop>
+ <prop oor:name="RealFilterName"><value>RAS - Sun Rasterfile</value></prop>
+ <prop oor:name="UIComponent"/>
+ <prop oor:name="UIName">
+ <value xml:lang="en-US">RAS - Sun Raster Image</value>
+ </prop>
+ <prop oor:name="Flags"><value>IMPORT</value></prop>
+</node>
diff --git a/filter/source/graphicfilter/ipcx/ipcx.cxx b/filter/source/graphicfilter/ipcx/ipcx.cxx
deleted file mode 100644
index 67cbc947fefc..000000000000
--- a/filter/source/graphicfilter/ipcx/ipcx.cxx
+++ /dev/null
@@ -1,411 +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 <memory>
-#include <vcl/graph.hxx>
-#include <vcl/BitmapTools.hxx>
-#include <tools/stream.hxx>
-
-class FilterConfigItem;
-
-//============================ PCXReader ==================================
-
-namespace {
-
-class PCXReader {
-
-private:
-
- SvStream& m_rPCX; // the PCX file to read
-
- std::unique_ptr<vcl::bitmap::RawBitmap> mpBitmap;
- std::vector<Color> mvPalette;
- sal_uInt8 nVersion; // PCX-Version
- sal_uInt8 nEncoding; // compression type
- sal_uInt16 nBitsPerPlanePix; // bits per plane per pixel
- sal_uInt16 nPlanes; // no of planes
- sal_uInt16 nBytesPerPlaneLin; // bytes per plane line
-
- sal_uInt32 nWidth, nHeight; // dimension in pixel
- sal_uInt16 nResX, nResY; // resolution in pixel per inch or 0,0
- sal_uInt16 nDestBitsPerPixel; // bits per pixel in destination bitmap 1,4,8 or 24
- std::unique_ptr<sal_uInt8[]>
- pPalette;
- bool bStatus; // from now on do not read status from stream ( SJ )
-
-
- void ImplReadBody();
- void ImplReadPalette( unsigned int nCol );
- void ImplReadHeader();
-
-public:
- explicit PCXReader(SvStream &rStream);
- bool ReadPCX(Graphic & rGraphic );
- // Reads a PCX file from the stream and fills the GDIMetaFile
-};
-
-}
-
-//=================== methods of PCXReader ==============================
-
-PCXReader::PCXReader(SvStream &rStream)
- : m_rPCX(rStream)
- , nVersion(0)
- , nEncoding(0)
- , nBitsPerPlanePix(0)
- , nPlanes(0)
- , nBytesPerPlaneLin(0)
- , nWidth(0)
- , nHeight(0)
- , nResX(0)
- , nResY(0)
- , nDestBitsPerPixel(0)
- , pPalette(new sal_uInt8[ 768 ])
- , bStatus(false)
-{
-}
-
-bool PCXReader::ReadPCX(Graphic & rGraphic)
-{
- if ( m_rPCX.GetError() )
- return false;
-
- m_rPCX.SetEndian(SvStreamEndian::LITTLE);
-
- // read header:
-
- bStatus = true;
-
- ImplReadHeader();
-
- // sanity check there is enough data before trying allocation
- if (bStatus && nBytesPerPlaneLin > m_rPCX.remainingSize() / nPlanes)
- {
- bStatus = false;
- }
-
- if (bStatus)
- {
- sal_uInt32 nResult;
- bStatus = !o3tl::checked_multiply(nWidth, nHeight, nResult) && nResult <= SAL_MAX_INT32/2/3;
- }
-
- // Write BMP header and conditionally (maybe invalid for now) color palette:
- if (bStatus)
- {
- mpBitmap.reset( new vcl::bitmap::RawBitmap( Size( nWidth, nHeight ), 24 ) );
-
- if ( nDestBitsPerPixel <= 8 )
- {
- sal_uInt16 nColors = 1 << nDestBitsPerPixel;
- sal_uInt8* pPal = pPalette.get();
- mvPalette.resize( nColors );
- for ( sal_uInt16 i = 0; i < nColors; i++, pPal += 3 )
- {
- mvPalette[i] = Color( pPal[ 0 ], pPal[ 1 ], pPal[ 2 ] );
- }
- }
-
- // read bitmap data
- ImplReadBody();
-
- // If an extended color palette exists at the end of the file, then read it and
- // and write again in palette:
- if ( nDestBitsPerPixel == 8 && bStatus )
- {
- sal_uInt8* pPal = pPalette.get();
- m_rPCX.SeekRel(1);
- ImplReadPalette(256);
- mvPalette.resize( 256 );
- for ( sal_uInt16 i = 0; i < 256; i++, pPal += 3 )
- {
- mvPalette[i] = Color( pPal[ 0 ], pPal[ 1 ], pPal[ 2 ] );
- }
- }
-
- if ( bStatus )
- {
- rGraphic = vcl::bitmap::CreateFromData(std::move(*mpBitmap));
- return true;
- }
- }
- return false;
-}
-
-void PCXReader::ImplReadHeader()
-{
- sal_uInt8 nbyte(0);
- m_rPCX.ReadUChar( nbyte ).ReadUChar( nVersion ).ReadUChar( nEncoding );
- if ( nbyte!=0x0a || (nVersion != 0 && nVersion != 2 && nVersion != 3 && nVersion != 5) || nEncoding > 1 )
- {
- bStatus = false;
- return;
- }
-
- nbyte = 0;
- m_rPCX.ReadUChar( nbyte ); nBitsPerPlanePix = static_cast<sal_uInt16>(nbyte);
- sal_uInt16 nMinX(0),nMinY(0),nMaxX(0),nMaxY(0);
- m_rPCX.ReadUInt16( nMinX ).ReadUInt16( nMinY ).ReadUInt16( nMaxX ).ReadUInt16( nMaxY );
-
- if ((nMinX > nMaxX) || (nMinY > nMaxY))
- {
- bStatus = false;
- return;
- }
-
- nWidth = nMaxX-nMinX+1;
- nHeight = nMaxY-nMinY+1;
-
- m_rPCX.ReadUInt16( nResX );
- m_rPCX.ReadUInt16( nResY );
- if ( nResX >= nWidth || nResY >= nHeight || ( nResX != nResY ) )
- nResX = nResY = 0;
-
- ImplReadPalette( 16 );
-
- m_rPCX.SeekRel( 1 );
- nbyte = 0;
- m_rPCX.ReadUChar( nbyte ); nPlanes = static_cast<sal_uInt16>(nbyte);
- sal_uInt16 nushort(0);
- m_rPCX.ReadUInt16( nushort ); nBytesPerPlaneLin = nushort;
- sal_uInt16 nPaletteInfo;
- m_rPCX.ReadUInt16( nPaletteInfo );
-
- m_rPCX.SeekRel( 58 );
-
- nDestBitsPerPixel = nBitsPerPlanePix * nPlanes;
- if (nDestBitsPerPixel == 2 || nDestBitsPerPixel == 3) nDestBitsPerPixel = 4;
-
- if ( ( nDestBitsPerPixel != 1 && nDestBitsPerPixel != 4 && nDestBitsPerPixel != 8 && nDestBitsPerPixel != 24 )
- || nPlanes > 4 || nBytesPerPlaneLin < ( ( nWidth * nBitsPerPlanePix+7 ) >> 3 ) )
- {
- bStatus = false;
- return;
- }
-
- // If the bitmap has only 2 colors, the palette is most often invalid and it is always(?)
- // a black and white image:
- if ( nPlanes == 1 && nBitsPerPlanePix == 1 )
- {
- pPalette[ 0 ] = pPalette[ 1 ] = pPalette[ 2 ] = 0x00;
- pPalette[ 3 ] = pPalette[ 4 ] = pPalette[ 5 ] = 0xff;
- }
-}
-
-void PCXReader::ImplReadBody()
-{
- std::unique_ptr<sal_uInt8[]> pPlane[ 4 ];
- sal_uInt8 * pDest;
- sal_uInt32 i, ny, nLastPercent = 0, nPercent;
- sal_uInt16 nCount, nx, np;
- sal_uInt8 nDat = 0, nCol = 0;
-
- for( np = 0; np < nPlanes; np++ )
- pPlane[ np ].reset(new sal_uInt8[ nBytesPerPlaneLin ]);
-
- nCount = 0;
- for ( ny = 0; ny < nHeight; ny++ )
- {
- if (!m_rPCX.good())
- {
- bStatus = false;
- break;
- }
- nPercent = ny * 60 / nHeight + 10;
- if ( ny == 0 || nLastPercent + 4 <= nPercent )
- {
- nLastPercent = nPercent;
- }
- for ( np = 0; np < nPlanes; np++)
- {
- if ( nEncoding == 0)
- m_rPCX.ReadBytes( static_cast<void *>(pPlane[ np ].get()), nBytesPerPlaneLin );
- else
- {
- pDest = pPlane[ np ].get();
- nx = nBytesPerPlaneLin;
- while ( nCount > 0 && nx > 0)
- {
- *(pDest++) = nDat;
- nx--;
- nCount--;
- }
- while (nx > 0 && m_rPCX.good())
- {
- m_rPCX.ReadUChar( nDat );
- if ( ( nDat & 0xc0 ) == 0xc0 )
- {
- nCount =static_cast<sal_uInt64>(nDat) & 0x003f;
- m_rPCX.ReadUChar( nDat );
- if ( nCount < nx )
- {
- nx -= nCount;
- while ( nCount > 0)
- {
- *(pDest++) = nDat;
- nCount--;
- }
- }
- else
- {
- nCount -= nx;
- do
- {
- *(pDest++) = nDat;
- nx--;
- }
- while ( nx > 0 );
- break;
- }
- }
- else
- {
- *(pDest++) = nDat;
- nx--;
- }
- }
- }
- }
- sal_uInt8 *pSource1 = pPlane[ 0 ].get();
- sal_uInt8 *pSource2 = pPlane[ 1 ].get();
- sal_uInt8 *pSource3 = pPlane[ 2 ].get();
- sal_uInt8 *pSource4 = pPlane[ 3 ].get();
- switch ( nBitsPerPlanePix + ( nPlanes << 8 ) )
- {
- // 2 colors
- case 0x101 :
- for ( i = 0; i < nWidth; i++ )
- {
- sal_uInt32 nShift = ( i & 7 ) ^ 7;
- if ( nShift == 0 )
- mpBitmap->SetPixel( ny, i, mvPalette[*(pSource1++) & 1] );
- else
- mpBitmap->SetPixel( ny, i, mvPalette[(*pSource1 >> nShift ) & 1] );
- }
- break;
- // 4 colors
- case 0x102 :
- for ( i = 0; i < nWidth; i++ )
- {
- switch( i & 3 )
- {
- case 0 :
- nCol = *pSource1 >> 6;
- break;
- case 1 :
- nCol = ( *pSource1 >> 4 ) & 0x03 ;
- break;
- case 2 :
- nCol = ( *pSource1 >> 2 ) & 0x03;
- break;
- case 3 :
- nCol = ( *pSource1++ ) & 0x03;
- break;
- }
- mpBitmap->SetPixel( ny, i, mvPalette[nCol] );
- }
- break;
- // 256 colors
- case 0x108 :
- for ( i = 0; i < nWidth; i++ )
- {
- mpBitmap->SetPixel( ny, i, mvPalette[*pSource1++] );
- }
- break;
- // 8 colors
- case 0x301 :
- for ( i = 0; i < nWidth; i++ )
- {
- sal_uInt32 nShift = ( i & 7 ) ^ 7;
- if ( nShift == 0 )
- {
- nCol = ( *pSource1++ & 1) + ( ( *pSource2++ << 1 ) & 2 ) + ( ( *pSource3++ << 2 ) & 4 );
- mpBitmap->SetPixel( ny, i, mvPalette[nCol] );
- }
- else
- {
- nCol = sal::static_int_cast< sal_uInt8 >(
- ( ( *pSource1 >> nShift ) & 1) + ( ( ( *pSource2 >> nShift ) << 1 ) & 2 ) +
- ( ( ( *pSource3 >> nShift ) << 2 ) & 4 ));
- mpBitmap->SetPixel( ny, i, mvPalette[nCol] );
- }
- }
- break;
- // 16 colors
- case 0x401 :
- for ( i = 0; i < nWidth; i++ )
- {
- sal_uInt32 nShift = ( i & 7 ) ^ 7;
- if ( nShift == 0 )
- {
- nCol = ( *pSource1++ & 1) + ( ( *pSource2++ << 1 ) & 2 ) + ( ( *pSource3++ << 2 ) & 4 ) +
- ( ( *pSource4++ << 3 ) & 8 );
- mpBitmap->SetPixel( ny, i, mvPalette[nCol] );
- }
- else
- {
- nCol = sal::static_int_cast< sal_uInt8 >(
- ( ( *pSource1 >> nShift ) & 1) + ( ( ( *pSource2 >> nShift ) << 1 ) & 2 ) +
- ( ( ( *pSource3 >> nShift ) << 2 ) & 4 ) + ( ( ( *pSource4 >> nShift ) << 3 ) & 8 ));
- mpBitmap->SetPixel( ny, i, mvPalette[nCol] );
- }
- }
- break;
- // 16m colors
- case 0x308 :
- for ( i = 0; i < nWidth; i++ )
- {
- mpBitmap->SetPixel( ny, i, Color( *pSource1++, *pSource2++, *pSource3++ ) );
-
- }
- break;
- default :
- bStatus = false;
- break;
- }
- }
-}
-
-void PCXReader::ImplReadPalette( unsigned int nCol )
-{
- sal_uInt8 r, g, b;
- sal_uInt8* pPtr = pPalette.get();
- for ( unsigned int i = 0; i < nCol; i++ )
- {
- m_rPCX.ReadUChar( r ).ReadUChar( g ).ReadUChar( b );
- *pPtr++ = r;
- *pPtr++ = g;
- *pPtr++ = b;
- }
-}
-
-//================== GraphicImport - the exported function ================
-
-extern "C" SAL_DLLPUBLIC_EXPORT bool
-ipxGraphicImport( SvStream & rStream, Graphic & rGraphic, FilterConfigItem* )
-{
- PCXReader aPCXReader(rStream);
- bool bRetValue = aPCXReader.ReadPCX(rGraphic);
- if ( !bRetValue )
- rStream.SetError( SVSTREAM_FILEFORMAT_ERROR );
- return bRetValue;
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/filter/source/graphicfilter/iras/iras.cxx b/filter/source/graphicfilter/iras/iras.cxx
deleted file mode 100644
index 5205d6253e22..000000000000
--- a/filter/source/graphicfilter/iras/iras.cxx
+++ /dev/null
@@ -1,414 +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 <sal/log.hxx>
-#include <tools/stream.hxx>
-
-class FilterConfigItem;
-
-#define RAS_TYPE_OLD 0x00000000 // supported formats by this filter
-#define RAS_TYPE_STANDARD 0x00000001
-#define RAS_TYPE_BYTE_ENCODED 0x00000002
-#define RAS_TYPE_RGB_FORMAT 0x00000003
-
-#define RAS_COLOR_NO_MAP 0x00000000
-#define RAS_COLOR_RGB_MAP 0x00000001
-#define RAS_COLOR_RAW_MAP 0x00000002
-
-#define SUNRASTER_MAGICNUMBER 0x59a66a95
-
-//============================ RASReader ==================================
-
-namespace {
-
-class RASReader {
-
-private:
-
- SvStream& m_rRAS; // the RAS file to be read in
-
- bool mbStatus;
- sal_Int32 mnWidth, mnHeight; // image dimensions in pixels
- sal_uInt16 mnDstBitsPerPix;
- sal_uInt16 mnDstColors;
- sal_Int32 mnDepth, mnImageDatSize, mnType;
- sal_Int32 mnColorMapType, mnColorMapSize;
- sal_uInt8 mnRepCount, mnRepVal; // RLE Decoding
-
- bool ImplReadBody(vcl::bitmap::RawBitmap&, std::vector<Color> const & rvPalette);
- bool ImplReadHeader();
- sal_uInt8 ImplGetByte();
-
-public:
- explicit RASReader(SvStream &rRAS);
- bool ReadRAS(Graphic & rGraphic);
-};
-
-}
-
-//=================== Methods of RASReader ==============================
-
-RASReader::RASReader(SvStream &rRAS)
- : m_rRAS(rRAS)
- , mbStatus(true)
- , mnWidth(0)
- , mnHeight(0)
- , mnDstBitsPerPix(0)
- , mnDstColors(0)
- , mnDepth(0)
- , mnImageDatSize(0)
- , mnType(0)
- , mnColorMapType(0)
- , mnColorMapSize(0)
- , mnRepCount(0)
- , mnRepVal(0)
-{
-}
-
-bool RASReader::ReadRAS(Graphic & rGraphic)
-{
- sal_uInt32 nMagicNumber;
-
- if ( m_rRAS.GetError() )
- return false;
-
- m_rRAS.SetEndian( SvStreamEndian::BIG );
- m_rRAS.ReadUInt32( nMagicNumber );
- if ( nMagicNumber != SUNRASTER_MAGICNUMBER )
- return false;
-
- // Kopf einlesen:
-
- mbStatus = ImplReadHeader();
- if ( !mbStatus )
- return false;
-
- std::vector<Color> aPalette;
- bool bOk = true;
-
- if ( mnDstBitsPerPix <= 8 ) // pallets pictures
- {
- bool bPalette(false);
-
- if ( mnColorMapType == RAS_COLOR_RAW_MAP ) // RAW color map is skipped
- {
- sal_uInt64 nCurPos = m_rRAS.Tell();
- bOk = checkSeek(m_rRAS, nCurPos + mnColorMapSize);
- }
- else if ( mnColorMapType == RAS_COLOR_RGB_MAP ) // we can read out the RGB
- {
- mnDstColors = static_cast<sal_uInt16>( mnColorMapSize / 3 );
-
- if ( ( 1 << mnDstBitsPerPix ) < mnDstColors )
- return false;
-
- if ( ( mnDstColors >= 2 ) && ( ( mnColorMapSize % 3 ) == 0 ) )
- {
- aPalette.resize(mnDstColors);
- sal_uInt16 i;
- sal_uInt8 nRed[256], nGreen[256], nBlue[256];
- for ( i = 0; i < mnDstColors; i++ ) m_rRAS.ReadUChar( nRed[ i ] );
- for ( i = 0; i < mnDstColors; i++ ) m_rRAS.ReadUChar( nGreen[ i ] );
- for ( i = 0; i < mnDstColors; i++ ) m_rRAS.ReadUChar( nBlue[ i ] );
- for ( i = 0; i < mnDstColors; i++ )
- {
- aPalette[i] = Color(nRed[ i ], nGreen[ i ], nBlue[ i ]);
- }
- bPalette = true;
- }
- else
- return false;
-
- }
- else if ( mnColorMapType != RAS_COLOR_NO_MAP ) // everything else is not standard
- return false;
-
- if (!bPalette)
- {
- mnDstColors = 1 << mnDstBitsPerPix;
- aPalette.resize(mnDstColors);
- for ( sal_uInt16 i = 0; i < mnDstColors; i++ )
- {
- sal_uInt8 nCount = 255 - ( 255 * i / ( mnDstColors - 1 ) );
- aPalette[i] = Color(nCount, nCount, nCount);
- }
- }
- }
- else
- {
- if ( mnColorMapType != RAS_COLOR_NO_MAP ) // when graphic has more than 256 colors and a color map we skip
- { // the colormap
- sal_uInt64 nCurPos = m_rRAS.Tell();
- bOk = checkSeek(m_rRAS, nCurPos + mnColorMapSize);
- }
- }
-
- if (!bOk)
- return false;
-
- //The RLE packets are typically three bytes in size:
- //The first byte is a Flag Value indicating the type of RLE packet.
- //The second byte is the Run Count.
- //The third byte is the Run Value.
- //
- //for the sake of simplicity we'll assume that RAS_TYPE_BYTE_ENCODED can
- //describe data 255 times larger than the data stored
- size_t nMaxCompression = mnType != RAS_TYPE_BYTE_ENCODED ? 1 : 255;
- sal_Int32 nBitSize;
- if (o3tl::checked_multiply<sal_Int32>(mnWidth, mnHeight, nBitSize) || o3tl::checked_multiply<sal_Int32>(nBitSize, mnDepth, nBitSize))
- return false;
- if (m_rRAS.remainingSize() * nMaxCompression < static_cast<sal_uInt32>(nBitSize) / 8)
- return false;
-
- vcl::bitmap::RawBitmap aBmp(Size(mnWidth, mnHeight), 24);
-
- // read in the bitmap data
- mbStatus = ImplReadBody(aBmp, aPalette);
-
- if ( mbStatus )
- rGraphic = vcl::bitmap::CreateFromData(std::move(aBmp));
-
- return mbStatus;
-}
-
-bool RASReader::ImplReadHeader()
-{
- m_rRAS.ReadInt32(mnWidth).ReadInt32(mnHeight).ReadInt32(mnDepth).ReadInt32(mnImageDatSize).ReadInt32(mnType).ReadInt32(mnColorMapType).ReadInt32(mnColorMapSize);
-
- if (!m_rRAS.good() || mnWidth <= 0 || mnHeight <= 0 || mnImageDatSize <= 0)
- mbStatus = false;
-
- switch ( mnDepth )
- {
- case 24 :
- case 8 :
- case 1 :
- mnDstBitsPerPix = static_cast<sal_uInt16>(mnDepth);
- break;
- case 32 :
- mnDstBitsPerPix = 24;
- break;
-
- default :
- mbStatus = false;
- }
-
- switch ( mnType )
- {
- case RAS_TYPE_OLD :
- case RAS_TYPE_STANDARD :
- case RAS_TYPE_RGB_FORMAT :
- case RAS_TYPE_BYTE_ENCODED : // this type will be supported later
- break;
-
- default:
- mbStatus = false;
- }
- return mbStatus;
-}
-
-namespace
-{
- const Color& SanitizePaletteIndex(std::vector<Color> const & rvPalette, sal_uInt8 nIndex)
- {
- if (nIndex >= rvPalette.size())
- {
- auto nSanitizedIndex = nIndex % rvPalette.size();
- SAL_WARN_IF(nIndex != nSanitizedIndex, "filter.ras", "invalid colormap index: "
- << static_cast<unsigned int>(nIndex) << ", colormap len is: "
- << rvPalette.size());
- nIndex = nSanitizedIndex;
- }
- return rvPalette[nIndex];
- }
-}
-
-bool RASReader::ImplReadBody(vcl::bitmap::RawBitmap& rBitmap, std::vector<Color> const & rvPalette)
-{
- sal_Int32 x, y;
- sal_uInt8 nRed, nGreen, nBlue;
- switch ( mnDstBitsPerPix )
- {
- case 1 :
- {
- sal_uInt8 nDat = 0;
- for (y = 0; y < mnHeight && mbStatus; ++y)
- {
- for (x = 0; x < mnWidth && mbStatus; ++x)
- {
- if (!(x & 7))
- {
- nDat = ImplGetByte();
- if (!m_rRAS.good())
- mbStatus = false;
- }
- rBitmap.SetPixel(y, x, SanitizePaletteIndex(rvPalette,
- sal::static_int_cast< sal_uInt8 >(
- nDat >> ( ( x & 7 ) ^ 7 ))));
- }
- if (!( ( x - 1 ) & 0x8 ) )
- {
- ImplGetByte(); // WORD ALIGNMENT ???
- if (!m_rRAS.good())
- mbStatus = false;
- }
- }
- break;
- }
-
- case 8 :
- for (y = 0; y < mnHeight && mbStatus; ++y)
- {
- for (x = 0; x < mnWidth && mbStatus; ++x)
- {
- sal_uInt8 nDat = ImplGetByte();
- rBitmap.SetPixel(y, x, SanitizePaletteIndex(rvPalette, nDat));
- if (!m_rRAS.good())
- mbStatus = false;
- }
- if ( x & 1 )
- {
- ImplGetByte(); // WORD ALIGNMENT ???
- if (!m_rRAS.good())
- mbStatus = false;
- }
- }
- break;
-
- case 24 :
- switch ( mnDepth )
- {
-
- case 24 :
- for (y = 0; y < mnHeight && mbStatus; ++y)
- {
- for (x = 0; x < mnWidth && mbStatus; ++x)
- {
- if ( mnType == RAS_TYPE_RGB_FORMAT )
- {
- nRed = ImplGetByte();
- nGreen = ImplGetByte();
- nBlue = ImplGetByte();
- }
- else
- {
- nBlue = ImplGetByte();
- nGreen = ImplGetByte();
- nRed = ImplGetByte();
- }
- rBitmap.SetPixel(y, x, Color(nRed, nGreen, nBlue));
- if (!m_rRAS.good())
- mbStatus = false;
- }
- if ( x & 1 )
- {
- ImplGetByte(); // WORD ALIGNMENT ???
- if (!m_rRAS.good())
- mbStatus = false;
- }
- }
- break;
-
- case 32 :
- for (y = 0; y < mnHeight && mbStatus; ++y)
- {
- for (x = 0; x < mnWidth && mbStatus; ++x)
- {
- ImplGetByte(); // pad byte > nil
- if ( mnType == RAS_TYPE_RGB_FORMAT )
- {
- nRed = ImplGetByte();
- nGreen = ImplGetByte();
- nBlue = ImplGetByte();
- }
- else
- {
- nBlue = ImplGetByte();
- nGreen = ImplGetByte();
- nRed = ImplGetByte();
- }
- rBitmap.SetPixel(y, x, Color(nRed, nGreen, nBlue));
- if (!m_rRAS.good())
- mbStatus = false;
- }
- }
- break;
- }
- break;
-
- default:
- mbStatus = false;
- break;
- }
- return mbStatus;
-}
-
-sal_uInt8 RASReader::ImplGetByte()
-{
- sal_uInt8 nRetVal;
- if ( mnType != RAS_TYPE_BYTE_ENCODED )
- {
- m_rRAS.ReadUChar( nRetVal );
- return nRetVal;
- }
- else
- {
- if ( mnRepCount )
- {
- mnRepCount--;
- return mnRepVal;
- }
- else
- {
- m_rRAS.ReadUChar( nRetVal );
- if ( nRetVal != 0x80 )
- return nRetVal;
- m_rRAS.ReadUChar( nRetVal );
- if ( nRetVal == 0 )
- return 0x80;
- mnRepCount = nRetVal ;
- m_rRAS.ReadUChar( mnRepVal );
- return mnRepVal;
- }
- }
-}
-
-//================== GraphicImport - the exported function ================
-
-extern "C" SAL_DLLPUBLIC_EXPORT bool
-iraGraphicImport( SvStream & rStream, Graphic & rGraphic, FilterConfigItem* )
-{
- bool bRet = false;
-
- try
- {
- RASReader aRASReader(rStream);
- bRet = aRASReader.ReadRAS(rGraphic );
- }
- catch (...)
- {
- }
-
- return bRet;
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */