summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--basebmp/inc/basebmp/color.hxx92
-rw-r--r--basebmp/inc/basebmp/colormisc.hxx122
-rw-r--r--basebmp/source/bitmapdevice.cxx5
3 files changed, 130 insertions, 89 deletions
diff --git a/basebmp/inc/basebmp/color.hxx b/basebmp/inc/basebmp/color.hxx
index 6984780e7587..e41bc250b9a7 100644
--- a/basebmp/inc/basebmp/color.hxx
+++ b/basebmp/inc/basebmp/color.hxx
@@ -4,9 +4,9 @@
*
* $RCSfile: color.hxx,v $
*
- * $Revision: 1.9 $
+ * $Revision: 1.10 $
*
- * last change: $Author: thb $ $Date: 2006-06-28 16:50:19 $
+ * last change: $Author: thb $ $Date: 2006-06-30 13:36:14 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
@@ -39,8 +39,6 @@
#ifndef _SAL_TYPES_H_
#include <sal/types.h>
#endif
-#include <basebmp/accessoradapters.hxx>
-#include <vigra/mathutil.hxx>
#include <math.h>
namespace basebmp
@@ -78,9 +76,9 @@ public:
Color operator^( Color col ) const { return Color(col.getRed()^getRed(),
col.getGreen()^getGreen(),
col.getBlue()^getBlue()); }
- Color operator-( Color col ) const { return Color(vigra::abs((int)getRed()-col.getRed()),
- vigra::abs((int)getGreen()-col.getGreen()),
- vigra::abs((int)getBlue()-col.getBlue())); }
+ Color operator-( Color col ) const { return Color(abs((int)getRed()-col.getRed()),
+ abs((int)getGreen()-col.getGreen()),
+ abs((int)getBlue()-col.getBlue())); }
Color operator+( Color col ) const { return Color(getRed()+col.getRed(),
getGreen()+col.getGreen(),
getBlue()+col.getBlue()); }
@@ -102,86 +100,6 @@ public:
+ getBlue()*getBlue()); }
};
-struct ColorBitmaskOutputMaskFunctor
-{
- Color operator()( Color v1, sal_uInt8 m, Color v2 ) const
- {
-#if 0 //#####
- return Color(v1.toInt32()*(sal_uInt8)(1-m) + v2.toInt32()*m);
-#else //#####
- static const int nAlphaDiv = 255; // 256 would be much faster and good enough...
- int nR = v1.getRed();
- int nS = v2.getRed();
- nR = nS + (((nR - nS) * m) / nAlphaDiv);
-
- int nG = v1.getGreen();
- nS = v2.getGreen();
- nG = nS + (((nG - nS) * m) / nAlphaDiv);
-
- int nB = v1.getBlue();
- nS = v2.getBlue();
- nB = nS + (((nB - nS) * m) / nAlphaDiv);
-
- return Color( nR, nG, nB );
-#endif //#####
- }
-};
-
-/// Specialized output mask functor for Color value type
-template<> struct outputMaskFunctorSelector< Color, sal_uInt8, FastMask >
-{
- typedef ColorBitmaskOutputMaskFunctor type;
-};
-
-struct ColorBlendFunctor
-{
- Color operator()( sal_uInt8 alpha,
- Color v1,
- Color v2 ) const
- {
- const sal_uInt8 invAlpha(0xFF-alpha);
- return Color(((sal_uInt32)invAlpha*v1.getRed() + alpha*v2.getRed())/0xFF,
- ((sal_uInt32)invAlpha*v1.getGreen() + alpha*v2.getGreen())/0xFF,
- ((sal_uInt32)invAlpha*v1.getBlue() + alpha*v2.getBlue())/0xFF);
- }
-};
-
-/// Specialized metafunction to select blend functor for Color value types
-template<> struct blendFunctorSelector<Color, sal_uInt8>
-{
- typedef ColorBlendFunctor type;
-};
-
-} // namespace basebmp
-
-namespace vigra
-{
-
-template<>
-struct NumericTraits<basebmp::Color>
-{
- typedef basebmp::Color Type;
- typedef basebmp::Color Promote;
- typedef basebmp::Color RealPromote;
- typedef std::complex<basebmp::Color> ComplexPromote;
- typedef sal_uInt8 ValueType;
-
- typedef VigraTrueType isIntegral;
- typedef VigraFalseType isScalar;
- typedef VigraTrueType isSigned;
- typedef VigraTrueType isOrdered;
- typedef VigraFalseType isComplex;
-
- static Type zero() { return Type(); }
- static Type one() { return Type(0x01010101); }
- static Type nonZero() { return Type(0x01010101); }
-
- static Promote toPromote(const Type& v) { return v; }
- static RealPromote toRealPromote(const Type& v) { return v; }
- static Type fromPromote(const Promote& v) { return v; }
- static Type fromRealPromote(const RealPromote& v) { return v; }
-};
-
} // namespace vigra
#endif /* INCLUDED_BASEBMP_COLOR_HXX */
diff --git a/basebmp/inc/basebmp/colormisc.hxx b/basebmp/inc/basebmp/colormisc.hxx
new file mode 100644
index 000000000000..62ad4a971e41
--- /dev/null
+++ b/basebmp/inc/basebmp/colormisc.hxx
@@ -0,0 +1,122 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: colormisc.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: thb $ $Date: 2006-06-30 13:36:14 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2005 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ ************************************************************************/
+
+#ifndef INCLUDED_BASEBMP_COLORMISC_HXX
+#define INCLUDED_BASEBMP_COLORMISC_HXX
+
+#include <basebmp/color.hxx>
+#include <basebmp/accessoradapters.hxx>
+#include <vigra/mathutil.hxx>
+
+// Contents of this header moved out of color.hxx, as it is not useful
+// for the general public (drags in vigra and other template
+// functionality, that shouldn't be necessary for the ordinary client
+// of BitmapDevice etc.)
+
+namespace basebmp
+{
+
+struct ColorBitmaskOutputMaskFunctor
+{
+ Color operator()( Color v1, sal_uInt8 m, Color v2 ) const
+ {
+ return Color(v1.toInt32()*(sal_uInt8)(1-m) + v2.toInt32()*m);
+ }
+};
+
+/// Specialized output mask functor for Color value type
+template<> struct outputMaskFunctorSelector< Color, sal_uInt8, FastMask >
+{
+ typedef ColorBitmaskOutputMaskFunctor type;
+};
+
+struct ColorBlendFunctor
+{
+ Color operator()( sal_uInt8 alpha,
+ Color v1,
+ Color v2 ) const
+ {
+ const sal_uInt8 v1_red( v1.getRed() );
+ const sal_uInt8 v1_green( v1.getGreen() );
+ const sal_uInt8 v1_blue( v1.getBlue() );
+
+ // using '>> 8' instead of '/ 0x100' is ill-advised (shifted
+ // value might be negative). Better rely on decent optimizer
+ // here...
+ return Color(((((sal_Int32)v2.getRed() - v1_red)*alpha) / 0x100) + v1_red,
+ ((((sal_Int32)v2.getGreen() - v1_green)*alpha) / 0x100) + v1_green,
+ ((((sal_Int32)v2.getBlue() - v1_blue)*alpha) / 0x100) + v1_blue);
+ }
+};
+
+/// Specialized metafunction to select blend functor for Color value types
+template<> struct blendFunctorSelector<Color, sal_uInt8>
+{
+ typedef ColorBlendFunctor type;
+};
+
+} // namespace basebmp
+
+namespace vigra
+{
+
+template<>
+struct NumericTraits<basebmp::Color>
+{
+ typedef basebmp::Color Type;
+ typedef basebmp::Color Promote;
+ typedef basebmp::Color RealPromote;
+ typedef std::complex<basebmp::Color> ComplexPromote;
+ typedef sal_uInt8 ValueType;
+
+ typedef VigraTrueType isIntegral;
+ typedef VigraFalseType isScalar;
+ typedef VigraTrueType isSigned;
+ typedef VigraTrueType isOrdered;
+ typedef VigraFalseType isComplex;
+
+ static Type zero() { return Type(); }
+ static Type one() { return Type(0x01010101); }
+ static Type nonZero() { return Type(0x01010101); }
+
+ static Promote toPromote(const Type& v) { return v; }
+ static RealPromote toRealPromote(const Type& v) { return v; }
+ static Type fromPromote(const Promote& v) { return v; }
+ static Type fromRealPromote(const RealPromote& v) { return v; }
+};
+
+} // namespace vigra
+
+#endif /* INCLUDED_BASEBMP_COLORMISC_HXX */
diff --git a/basebmp/source/bitmapdevice.cxx b/basebmp/source/bitmapdevice.cxx
index 51ffc092f4d2..1f8e164d1377 100644
--- a/basebmp/source/bitmapdevice.cxx
+++ b/basebmp/source/bitmapdevice.cxx
@@ -4,9 +4,9 @@
*
* $RCSfile: bitmapdevice.cxx,v $
*
- * $Revision: 1.14 $
+ * $Revision: 1.15 $
*
- * last change: $Author: thb $ $Date: 2006-06-30 11:05:21 $
+ * last change: $Author: thb $ $Date: 2006-06-30 13:36:14 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
@@ -38,6 +38,7 @@
#include "basebmp/pixeliterator.hxx"
#include "basebmp/paletteimageaccessor.hxx"
#include "basebmp/color.hxx"
+#include "basebmp/colormisc.hxx"
#include "basebmp/accessor.hxx"
#include "basebmp/accessoradapters.hxx"
#include "basebmp/scanlineformats.hxx"