diff options
author | Jens-Heiner Rechtien <hr@openoffice.org> | 2007-06-27 11:39:54 +0000 |
---|---|---|
committer | Jens-Heiner Rechtien <hr@openoffice.org> | 2007-06-27 11:39:54 +0000 |
commit | 1a205d851c41139961ae59008e39fc89ffc54462 (patch) | |
tree | 6841fbeae8c5c900a345df0ae6904de90c5594bb /basebmp | |
parent | b7858a4d3921329f0030d46ae6821eb3cc5accca (diff) |
INTEGRATION: CWS basebmp01 (1.5.20); FILE MERGED
2007/05/22 09:59:17 thb 1.5.20.1: #147378# Added support for foreign formats (via GenericColorImageAccessor); fixed typos in CompositeIterator and StridedArrayIterator; fixed comparisons for (Packed)PixelIterator and StridedArrayIterator (which got negative strides wrong); avoiding unnecessary copying in scale_image() now; cleaned up bitmapdevice.cxx from cruft/ad hoc debug code; made unit tests run again
Diffstat (limited to 'basebmp')
-rw-r--r-- | basebmp/inc/basebmp/colormisc.hxx | 39 |
1 files changed, 34 insertions, 5 deletions
diff --git a/basebmp/inc/basebmp/colormisc.hxx b/basebmp/inc/basebmp/colormisc.hxx index 5a6eeadb3750..1f3f02c6fbf0 100644 --- a/basebmp/inc/basebmp/colormisc.hxx +++ b/basebmp/inc/basebmp/colormisc.hxx @@ -4,9 +4,9 @@ * * $RCSfile: colormisc.hxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: thb $ $Date: 2006-07-21 20:57:05 $ + * last change: $Author: hr $ $Date: 2007-06-27 12:39:54 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -76,7 +76,7 @@ template<bool polarity> struct outputMaskFunctorSelector< Color, sal_uInt8, pola typedef ColorBitmaskOutputMaskFunctor<polarity> type; }; -template< bool polarity > struct ColorBlendFunctor +template< bool polarity > struct ColorBlendFunctor8 : public TernaryFunctorBase<sal_uInt8,Color,Color,Color> { Color operator()( sal_uInt8 alpha, @@ -98,6 +98,29 @@ template< bool polarity > struct ColorBlendFunctor } }; +template< bool polarity > struct ColorBlendFunctor32 + : public TernaryFunctorBase<Color,Color,Color,Color> +{ + Color operator()( Color input, + Color v1, + Color v2 ) const + { + sal_uInt8 alpha = input.getGreyscale(); + alpha = polarity ? alpha : 255 - alpha; + + 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); + } +}; + //----------------------------------------------------------------------------- template<> struct ColorTraits< Color > @@ -129,10 +152,16 @@ template<> struct ColorTraits< Color > } }; -/// Only defined for 8 bit alpha, currently +/// The version for plain 8 bit alpha template<bool polarity> struct ColorTraits< Color >::blend_functor< sal_uInt8, polarity > { - typedef ColorBlendFunctor<polarity> type; + typedef ColorBlendFunctor8<polarity> type; +}; + +/// The version taking grey value of a Color +template<bool polarity> struct ColorTraits< Color >::blend_functor< Color, polarity > +{ + typedef ColorBlendFunctor32<polarity> type; }; } // namespace basebmp |