summaryrefslogtreecommitdiff
path: root/basebmp
diff options
context:
space:
mode:
Diffstat (limited to 'basebmp')
-rw-r--r--basebmp/inc/basebmp/accessoradapters.hxx128
-rw-r--r--basebmp/inc/basebmp/accessorfunctors.hxx163
-rw-r--r--basebmp/inc/basebmp/accessortraits.hxx69
-rw-r--r--basebmp/inc/basebmp/color.hxx5
-rw-r--r--basebmp/inc/basebmp/colorblendaccessoradapter.hxx8
-rw-r--r--basebmp/inc/basebmp/packedpixeliterator.hxx10
-rw-r--r--basebmp/source/bitmapdevice.cxx178
-rw-r--r--basebmp/test/basictest.cxx10
-rw-r--r--basebmp/test/bmpmasktest.cxx195
-rw-r--r--basebmp/test/makefile.mk5
10 files changed, 669 insertions, 102 deletions
diff --git a/basebmp/inc/basebmp/accessoradapters.hxx b/basebmp/inc/basebmp/accessoradapters.hxx
index b87b7d18f794..0d0599a43760 100644
--- a/basebmp/inc/basebmp/accessoradapters.hxx
+++ b/basebmp/inc/basebmp/accessoradapters.hxx
@@ -4,9 +4,9 @@
*
* $RCSfile: accessoradapters.hxx,v $
*
- * $Revision: 1.10 $
+ * $Revision: 1.11 $
*
- * last change: $Author: thb $ $Date: 2006-07-11 15:33:04 $
+ * last change: $Author: thb $ $Date: 2006-07-12 15:09:43 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
@@ -319,7 +319,7 @@ public:
maFunctor()
{}
- template< class A1, class A2 >
+ template< class A1, class A2 > explicit
TernarySetterFunctionAccessorAdapter(
TernarySetterFunctionAccessorAdapter< A1,
A2,
@@ -403,6 +403,128 @@ public:
};
+//-----------------------------------------------------------------------------
+
+/** Access two distinct images simultaneously
+
+ Passed iterator must fulfill the CompositeIterator concept
+ (i.e. wrap the two image's iterators into one
+ CompositeIterator). The getter and setter methods expect and
+ return a pair of values, with types equal to the two accessors
+ value types
+
+ @tpl WrappedAccessor1
+ Wrapped type must provide the usual get and set accessor methods,
+ with the usual signatures (see StandardAccessor for a conforming
+ example). Furthermore, the type must provide a nested typedef
+ value_type.
+
+ @tpl WrappedAccessor2
+ Wrapped type must provide the usual get and set accessor methods,
+ with the usual signatures (see StandardAccessor for a conforming
+ example). Furthermore, the type must provide a nested typedef
+ value_type.
+ */
+template< class WrappedAccessor1,
+ class WrappedAccessor2 > class JoinImageAccessorAdapter
+{
+#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
+// making all members public, if no member template friends
+private:
+ template<class A1, class A2> friend class JoinImageAccessorAdapter;
+#endif
+
+ WrappedAccessor1 ma1stAccessor;
+ WrappedAccessor2 ma2ndAccessor;
+
+public:
+ // TODO(F3): Need numeric traits and a few free functions to
+ // actually calculate with a pair (semantic: apply every operation
+ // individually to the contained types)
+ typedef std::pair<typename WrappedAccessor1::value_type,
+ typename WrappedAccessor2::value_type> value_type;
+
+ JoinImageAccessorAdapter() :
+ ma1stAccessor(),
+ ma2ndAccessor()
+ {}
+
+ template< class T > explicit JoinImageAccessorAdapter( T accessor ) :
+ ma1stAccessor( accessor ),
+ ma2ndAccessor()
+ {}
+
+ template< class A1, class A2 > explicit
+ JoinImageAccessorAdapter(
+ JoinImageAccessorAdapter< A1,
+ A2 > const& rSrc ) :
+ ma1stAccessor( rSrc.ma1stAccessor ),
+ ma2ndAccessor( rSrc.ma2ndAccessor )
+ {}
+
+ template< class T1, class T2 >
+ JoinImageAccessorAdapter( T1 accessor1,
+ T2 accessor2 ) :
+ ma1stAccessor( accessor1 ),
+ ma2ndAccessor( accessor2 )
+ {}
+
+ // -------------------------------------------------------
+
+ WrappedAccessor1 const& get1stWrappedAccessor() const { return ma1stAccessor; }
+ WrappedAccessor1& get1stWrappedAccessor() { return ma1stAccessor; }
+
+ WrappedAccessor2 const& get2ndWrappedAccessor() const { return ma2ndAccessor; }
+ WrappedAccessor2& get2ndWrappedAccessor() { return ma2ndAccessor; }
+
+ // -------------------------------------------------------
+
+ template< class Iterator >
+ value_type operator()(Iterator const& i) const
+ {
+ return std::make_pair(ma1stAccessor(i.first()),
+ ma2ndAccessor(i.second()));
+ }
+
+ template< class Iterator, class Difference >
+ value_type operator()(Iterator const& i, Difference const& diff) const
+ {
+ return std::make_pair(ma1stAccessor(i.first(),diff),
+ ma2ndAccessor(i.second(),diff));
+ }
+
+ // -------------------------------------------------------
+
+ template< typename V, class Iterator >
+ void set(V const& value, Iterator const& i) const
+ {
+ ma1stAccessor.set(
+ vigra::detail::RequiresExplicitCast<typename WrappedAccessor1::value_type>::cast(
+ value.first),
+ i.first() );
+ ma2ndAccessor.set(
+ vigra::detail::RequiresExplicitCast<typename WrappedAccessor2::value_type>::cast(
+ value.second),
+ i.second() );
+ }
+
+ template< typename V, class Iterator, class Difference >
+ void set(V const& value, Iterator const& i, Difference const& diff) const
+ {
+ ma1stAccessor.set(
+ vigra::detail::RequiresExplicitCast<typename WrappedAccessor1::value_type>::cast(
+ value.first),
+ i.first(),
+ diff );
+ ma2ndAccessor.set(
+ vigra::detail::RequiresExplicitCast<typename WrappedAccessor2::value_type>::cast(
+ value.second),
+ i.second(),
+ diff );
+ }
+
+};
+
} // namespace basebmp
#endif /* INCLUDED_BASEBMP_ACCESSORADAPTERS_HXX */
diff --git a/basebmp/inc/basebmp/accessorfunctors.hxx b/basebmp/inc/basebmp/accessorfunctors.hxx
new file mode 100644
index 000000000000..1d4645fba865
--- /dev/null
+++ b/basebmp/inc/basebmp/accessorfunctors.hxx
@@ -0,0 +1,163 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: accessorfunctors.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: thb $ $Date: 2006-07-12 15:09:44 $
+ *
+ * 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_ACCESSORFUNCTORS_HXX
+#define INCLUDED_BASEBMP_ACCESSORFUNCTORS_HXX
+
+#include <osl/diagnose.h>
+#include <basebmp/metafunctions.hxx>
+
+#include <functional>
+
+namespace basebmp
+{
+
+// Some common accessor functors
+// ------------------------------------------------------------
+
+
+/// combine two values via XOR
+template< typename T > struct XorFunctor : public std::binary_function<T,T,T>
+{
+ T operator()( T v1, T v2 ) const { return v1 ^ v2; }
+};
+
+//-----------------------------------------------------------------------------
+
+/// Base class for an adaptable ternary functor
+template< typename A1, typename A2, typename A3, typename R > struct TernaryFunctorBase
+{
+ typedef A1 first_argument_type;
+ typedef A2 second_argument_type;
+ typedef A3 third_argument_type;
+ typedef R result_type;
+};
+
+/// Base class, passing on the arg types
+template< typename T, typename M > struct MaskFunctorBase :
+ public TernaryFunctorBase<T,M,T,T> {};
+
+
+/// Let a mask flag decide between two values
+template< typename T, typename M > struct GenericOutputMaskFunctor : MaskFunctorBase<T,M>
+{
+ /// Ternary mask operation - selects v1 for !m == true, v2 otherwise
+ T operator()( T v1, M m, T v2 ) const
+ {
+ return !m ? v1 : v2;
+ }
+};
+
+/** Let a mask bit decide between two values (specialization for
+ integer mask types)
+ */
+template< typename T, typename M > struct IntegerOutputMaskFunctor : MaskFunctorBase<T,M>
+{
+ /** Mask v with state of m
+
+ @return v2, if m != 0, v1 otherwise.
+ */
+ T operator()( T v1, M m, T v2 ) const
+ {
+ typedef typename make_unsigned<T>::type unsigned_T;
+
+ // mask will be 0, iff m == 0, and 1 otherwise
+ const T mask( unsigned_cast<T>(m | -m) >> (sizeof(unsigned_T)*8 - 1) );
+ return v1*(M)(1-mask) + v2*mask;
+ }
+};
+
+/** Let a mask bit decide between two values (specialization for
+ binary-valued mask types)
+ */
+template< typename T, typename M > struct FastIntegerOutputMaskFunctor : MaskFunctorBase<T,M>
+{
+ /// Specialization, only valid if mask can only attain 0 or 1
+ T operator()( T v1, M m, T v2 ) const
+ {
+ OSL_ASSERT(m<=1);
+
+ return v1*(M)(1-m) + v2*m;
+ }
+};
+
+//-----------------------------------------------------------------------------
+
+/** Split a pair value from a JoinImageAccessorAdapter into its
+ individual values, and pass it on to a ternary functor
+
+ This wrapper is an adaptable binary functor, and can thus be used
+ with a BinarySetterFunctionAccessorAdapter. Useful e.g. for
+ out-of-image alpha channel, or a masked image.
+
+ @tpl Functor
+ An adaptable ternary functor (as can e.g. be passed to the
+ TernarySetterFunctionAccessorAdapter)
+ */
+template< typename Functor > class BinaryFunctorSplittingWrapper :
+ public std::binary_function<typename Functor::first_argument_type,
+ std::pair<typename Functor::third_argument_type,
+ typename Functor::second_argument_type>,
+ typename Functor::result_type>
+{
+#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
+// making all members public, if no member template friends
+private:
+ template<class A> friend class BinaryFunctorSplittingWrapper;
+#endif
+ Functor maFunctor;
+
+public:
+ BinaryFunctorSplittingWrapper() : maFunctor() {}
+
+ template< class A > explicit
+ BinaryFunctorSplittingWrapper(
+ BinaryFunctorSplittingWrapper<A> const& src ) : maFunctor(src.maFunctor) {}
+
+ template< class F > explicit
+ BinaryFunctorSplittingWrapper( F const& func ) : maFunctor(func) {}
+
+ typename Functor::result_type operator()(
+ typename Functor::first_argument_type v1,
+ std::pair< typename Functor::third_argument_type,
+ typename Functor::second_argument_type > const& v2 ) const
+ {
+ return maFunctor( v1, v2.second, v2.first );
+ }
+};
+
+} // namespace basebmp
+
+#endif /* INCLUDED_BASEBMP_ACCESSORFUNCTORS_HXX */
diff --git a/basebmp/inc/basebmp/accessortraits.hxx b/basebmp/inc/basebmp/accessortraits.hxx
index 8478718376f2..bb30cc310148 100644
--- a/basebmp/inc/basebmp/accessortraits.hxx
+++ b/basebmp/inc/basebmp/accessortraits.hxx
@@ -4,9 +4,9 @@
*
* $RCSfile: accessortraits.hxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: thb $ $Date: 2006-07-11 11:38:54 $
+ * last change: $Author: thb $ $Date: 2006-07-12 15:09:44 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
@@ -36,7 +36,7 @@
#ifndef INCLUDED_BASEBMP_ACCESSORTRAITS_HXX
#define INCLUDED_BASEBMP_ACCESSORTRAITS_HXX
-#include <osl/diagnose.h>
+#include <basebmp/accessorfunctors.hxx>
#include <basebmp/accessoradapters.hxx>
#include <basebmp/metafunctions.hxx>
@@ -45,69 +45,6 @@
namespace basebmp
{
-// Some common accessor functors
-// ------------------------------------------------------------
-
-
-//-----------------------------------------------------------------------------
-
-// XOR
-template< typename T > struct XorFunctor : public std::binary_function<T,T,T>
-{
- T operator()( T v1, T v2 ) const { return v1 ^ v2; }
-};
-
-//-----------------------------------------------------------------------------
-
-// Mask
-template< typename T, typename M > struct MaskFunctorBase
-{
- typedef T first_argument_type;
- typedef M second_argument_type;
- typedef T third_argument_type;
- typedef T result_type;
-};
-
-
-// Mask
-template< typename T, typename M > struct GenericOutputMaskFunctor : MaskFunctorBase<T,M>
-{
- /// Ternary mask operation - selects v1 for m == 0, v2 otherwise
- T operator()( T v1, M m, T v2 ) const
- {
- return m == 0 ? v1 : v2;
- }
-};
-
-template< typename T, typename M > struct IntegerOutputMaskFunctor : MaskFunctorBase<T,M>
-{
- /** Mask v with state of m
-
- @return v2, if m != 0, v1 otherwise.
- */
- T operator()( T v1, M m, T v2 ) const
- {
- typedef typename make_unsigned<T>::type unsigned_T;
-
- // mask will be 0, iff m == 0, and 1 otherwise
- const T mask( unsigned_cast<T>(m | -m) >> (sizeof(unsigned_T)*8 - 1) );
- return v1*(M)(1-mask) + v2*mask;
- }
-};
-
-template< typename T, typename M > struct FastIntegerOutputMaskFunctor : MaskFunctorBase<T,M>
-{
- /// Specialization, only valid if mask can only attain 0 or 1
- T operator()( T v1, M m, T v2 ) const
- {
- OSL_ASSERT(m<=1);
-
- return v1*(M)(1-m) + v2*m;
- }
-};
-
-//-----------------------------------------------------------------------------
-
struct FastMask;
struct NoFastMask;
diff --git a/basebmp/inc/basebmp/color.hxx b/basebmp/inc/basebmp/color.hxx
index d4df6839d4af..72b3325f78ed 100644
--- a/basebmp/inc/basebmp/color.hxx
+++ b/basebmp/inc/basebmp/color.hxx
@@ -4,9 +4,9 @@
*
* $RCSfile: color.hxx,v $
*
- * $Revision: 1.12 $
+ * $Revision: 1.13 $
*
- * last change: $Author: thb $ $Date: 2006-07-11 11:38:54 $
+ * last change: $Author: thb $ $Date: 2006-07-12 15:09:44 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
@@ -75,6 +75,7 @@ public:
sal_uInt32 toInt32() const { return mnColor; }
+ bool operator!() const { return mnColor == 0; }
Color operator&( sal_uInt32 nMask ) const { return Color(mnColor & nMask); }
Color operator^( Color col ) const { return Color(col.getRed()^getRed(),
col.getGreen()^getGreen(),
diff --git a/basebmp/inc/basebmp/colorblendaccessoradapter.hxx b/basebmp/inc/basebmp/colorblendaccessoradapter.hxx
index 168ee9b2c21a..d86f9efc2876 100644
--- a/basebmp/inc/basebmp/colorblendaccessoradapter.hxx
+++ b/basebmp/inc/basebmp/colorblendaccessoradapter.hxx
@@ -4,9 +4,9 @@
*
* $RCSfile: colorblendaccessoradapter.hxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: thb $ $Date: 2006-07-06 10:02:07 $
+ * last change: $Author: thb $ $Date: 2006-07-12 15:09:44 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
@@ -48,8 +48,8 @@ namespace basebmp
The getter functors return a constant value (usually the zero of
the value type, this preserves the original destination content
- when blitting through a mask) - there really isn't no sensible
- default behaviour for these methods.
+ when blitting through a mask) - there really isn't no other
+ sensible default behaviour for these methods.
*/
template< class WrappedAccessor,
typename AlphaType > class ConstantColorBlendSetterAccessorAdapter
diff --git a/basebmp/inc/basebmp/packedpixeliterator.hxx b/basebmp/inc/basebmp/packedpixeliterator.hxx
index 3d3a0f2f3784..9f6cb1ccfd38 100644
--- a/basebmp/inc/basebmp/packedpixeliterator.hxx
+++ b/basebmp/inc/basebmp/packedpixeliterator.hxx
@@ -4,9 +4,9 @@
*
* $RCSfile: packedpixeliterator.hxx,v $
*
- * $Revision: 1.6 $
+ * $Revision: 1.7 $
*
- * last change: $Author: thb $ $Date: 2006-07-06 10:00:40 $
+ * last change: $Author: thb $ $Date: 2006-07-12 15:09:44 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
@@ -49,7 +49,11 @@ namespace basebmp
{
/// Get bitmask for data at given intra-word position, for given bit depth
-template< typename value_type, int bits_per_pixel, bool MsbFirst, typename difference_type > inline value_type get_mask( difference_type d )
+template< typename value_type,
+ int bits_per_pixel,
+ bool MsbFirst,
+ typename difference_type >
+inline value_type get_mask( difference_type d )
{
BOOST_STATIC_ASSERT(bits_per_pixel > 0);
BOOST_STATIC_ASSERT(sizeof(value_type)*8 % bits_per_pixel == 0);
diff --git a/basebmp/source/bitmapdevice.cxx b/basebmp/source/bitmapdevice.cxx
index cf79e9da68c5..8d293b06d74e 100644
--- a/basebmp/source/bitmapdevice.cxx
+++ b/basebmp/source/bitmapdevice.cxx
@@ -4,9 +4,9 @@
*
* $RCSfile: bitmapdevice.cxx,v $
*
- * $Revision: 1.18 $
+ * $Revision: 1.19 $
*
- * last change: $Author: thb $ $Date: 2006-07-11 15:33:05 $
+ * last change: $Author: thb $ $Date: 2006-07-12 15:09:44 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
@@ -142,6 +142,33 @@ namespace
+ /** Create the type for an accessor that takes the (mask,bitmap)
+ input value generated from a JoinImageAccessorAdapter, and
+ pipe that through a mask functor.
+
+ @tpl DestAccessor
+ Destination bitmap accessor
+
+ @tpl JoinedAccessor
+ Input accessor, is expected to generate a std::pair as the
+ value type
+
+ @tpl MaskFunctorMode
+ Either FastMask or NoFastMask, depending on whether the mask
+ is guaranteed to contain only 0s and 1s.
+ */
+ template< class DestAccessor,
+ class JoinedAccessor,
+ typename MaskFunctorMode > struct masked_input_splitting_accessor
+ {
+ typedef BinarySetterFunctionAccessorAdapter<
+ DestAccessor,
+ BinaryFunctorSplittingWrapper<
+ typename outputMaskFunctorSelector<
+ typename JoinedAccessor::value_type::first_type,
+ typename JoinedAccessor::value_type::second_type,
+ MaskFunctorMode >::type > > type;
+ };
// Polygon scanline conversion
@@ -266,6 +293,8 @@ namespace
typedef AccessorTraits< dest_accessor_type > accessor_traits;
typedef CompositeIterator2D< dest_iterator_type,
mask_iterator_type > composite_iterator_type;
+ typedef CompositeIterator2D< vigra::Diff2D,
+ vigra::Diff2D > generic_composite_iterator_type;
typedef BitmapRenderer<mask_iterator_type,
mask_rawaccessor_type,
@@ -332,6 +361,13 @@ namespace
// -------------------------------------------------------
+ typedef JoinImageAccessorAdapter< dest_accessor_type,
+ mask_rawaccessor_type > joined_image_accessor_type;
+ typedef JoinImageAccessorAdapter< GenericImageAccessor,
+ GenericImageAccessor > joined_generic_image_accessor_type;
+
+ // -------------------------------------------------------
+
dest_iterator_type maBegin;
typename accessor_traits::color_lookup maColorLookup;
to_uint32_functor maToUInt32Converter;
@@ -874,23 +910,105 @@ namespace
}
}
+ template< typename Iterator, typename Acc >
+ void implDrawMaskedBitmap(const BitmapDeviceSharedPtr& rSrcBitmap,
+ const BitmapDeviceSharedPtr& rMask,
+ const basegfx::B2IRange& rSrcRect,
+ const basegfx::B2IRange& rDstRect,
+ const Iterator& begin,
+ const Acc& acc)
+ {
+ boost::shared_ptr<BitmapRenderer> pSrcBmp( getCompatibleBitmap(rSrcBitmap) );
+ boost::shared_ptr<mask_bitmap_type> pMask( getCompatibleClipMask(rMask) );
+ OSL_ASSERT( pMask && pSrcBmp );
+
+ // since resizeImageNoInterpolation() internally copyies
+ // to a temporary buffer, also works with *this == rSrcBitmap
+ vigra::resizeImageNoInterpolation(
+ srcIterRange(composite_iterator_type(
+ pSrcBmp->maBegin,
+ pMask->maBegin),
+ joined_image_accessor_type(
+ pSrcBmp->maAccessor,
+ pMask->maRawAccessor),
+ rSrcRect),
+ destIterRange(begin,
+ typename masked_input_splitting_accessor<
+ Acc,
+ joined_image_accessor_type,
+ FastMask >::type(acc),
+ rDstRect));
+ }
+
+ // xxx TODO
+ template< typename Iterator, typename Acc >
+ void implDrawMaskedBitmapGeneric(const BitmapDeviceSharedPtr& rSrcBitmap,
+ const BitmapDeviceSharedPtr& rMask,
+ const basegfx::B2IRange& rSrcRect,
+ const basegfx::B2IRange& rDstRect,
+ const Iterator& begin,
+ const Acc& acc)
+ {
+ GenericImageAccessor aSrcAcc( rSrcBitmap );
+ GenericImageAccessor aMaskAcc( rMask );
+
+ const vigra::Diff2D aTopLeft(rSrcRect.getMinX(),
+ rSrcRect.getMinY());
+ const vigra::Diff2D aBottomRight(rSrcRect.getMaxX(),
+ rSrcRect.getMaxY());
+ // since resizeImageNoInterpolation() internally copyies
+ // to a temporary buffer, also works with *this == rSrcBitmap
+ vigra::resizeImageNoInterpolation(
+ vigra::make_triple(
+ generic_composite_iterator_type(
+ aTopLeft,aTopLeft),
+ generic_composite_iterator_type(
+ aBottomRight,aBottomRight),
+ joined_generic_image_accessor_type(
+ aSrcAcc,
+ aMaskAcc)),
+ destIterRange(begin,
+ typename masked_input_splitting_accessor<
+ Acc,
+ joined_generic_image_accessor_type,
+ NoFastMask >::type(acc),
+ rDstRect));
+ }
+
virtual void drawMaskedBitmap_i(const BitmapDeviceSharedPtr& rSrcBitmap,
const BitmapDeviceSharedPtr& rMask,
const basegfx::B2IRange& rSrcRect,
const basegfx::B2IRange& rDstRect,
DrawMode drawMode )
{
- // TODO(F3): This is a hack, at best. The mask must be the
- // size of the source bitmap, and accordingly
- // translated. Let alone interpolated.
- if( drawMode == DrawMode_XOR )
- implDrawBitmap(rSrcBitmap, rSrcRect, rDstRect,
- getMaskedIter(rMask),
- maRawMaskedXorAccessor);
+ // xxx TODO
+ if( isCompatibleClipMask(rMask) &&
+ isCompatibleBitmap(rSrcBitmap) )
+ {
+ if( drawMode == DrawMode_XOR )
+ implDrawMaskedBitmap(rSrcBitmap, rMask,
+ rSrcRect, rDstRect,
+ maBegin,
+ maXorAccessor);
+ else
+ implDrawMaskedBitmap(rSrcBitmap, rMask,
+ rSrcRect, rDstRect,
+ maBegin,
+ maAccessor);
+ }
else
- implDrawBitmap(rSrcBitmap, rSrcRect, rDstRect,
- getMaskedIter(rMask),
- maRawMaskedAccessor);
+ {
+ if( drawMode == DrawMode_XOR )
+ implDrawMaskedBitmapGeneric(rSrcBitmap, rMask,
+ rSrcRect, rDstRect,
+ maBegin,
+ maXorAccessor);
+ else
+ implDrawMaskedBitmapGeneric(rSrcBitmap, rMask,
+ rSrcRect, rDstRect,
+ maBegin,
+ maAccessor);
+ }
}
virtual void drawMaskedBitmap_i(const BitmapDeviceSharedPtr& rSrcBitmap,
@@ -900,14 +1018,34 @@ namespace
DrawMode drawMode,
const BitmapDeviceSharedPtr& rClip )
{
- // TODO(F3): Clipped drawMaskedBitmap_i() not yet implemented
- (void)rClip;
- drawMaskedBitmap_i( rSrcBitmap,
- rMask,
- rSrcRect,
- rDstRect,
- drawMode );
- OSL_ENSURE( false, "Method not yet implemented, falling back to unclipped version!" );
+ // xxx TODO
+ if( isCompatibleClipMask(rClip) &&
+ isCompatibleBitmap(rSrcBitmap) )
+ {
+ if( drawMode == DrawMode_XOR )
+ implDrawMaskedBitmap(rSrcBitmap, rMask,
+ rSrcRect, rDstRect,
+ getMaskedIter(rClip),
+ maMaskedXorAccessor);
+ else
+ implDrawMaskedBitmap(rSrcBitmap, rMask,
+ rSrcRect, rDstRect,
+ getMaskedIter(rClip),
+ maMaskedAccessor);
+ }
+ else
+ {
+ if( drawMode == DrawMode_XOR )
+ implDrawMaskedBitmapGeneric(rSrcBitmap, rMask,
+ rSrcRect, rDstRect,
+ getMaskedIter(rClip),
+ maMaskedXorAccessor);
+ else
+ implDrawMaskedBitmapGeneric(rSrcBitmap, rMask,
+ rSrcRect, rDstRect,
+ getMaskedIter(rClip),
+ maMaskedAccessor);
+ }
}
};
} // namespace
diff --git a/basebmp/test/basictest.cxx b/basebmp/test/basictest.cxx
index baffe6718ad2..46776ce061ee 100644
--- a/basebmp/test/basictest.cxx
+++ b/basebmp/test/basictest.cxx
@@ -4,9 +4,9 @@
*
* $RCSfile: basictest.cxx,v $
*
- * $Revision: 1.8 $
+ * $Revision: 1.9 $
*
- * last change: $Author: thb $ $Date: 2006-07-11 11:38:56 $
+ * last change: $Author: thb $ $Date: 2006-07-12 15:09:45 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
@@ -114,6 +114,12 @@ public:
pDevice->getScanlineFormat() == Format::ONE_BIT_MSB_PAL );
CPPUNIT_ASSERT_MESSAGE("Scanline len",
pDevice->getScanlineStride() == (aSize2.getY() + 7)/8 );
+ CPPUNIT_ASSERT_MESSAGE("Palette existence",
+ pDevice->getPalette() );
+ CPPUNIT_ASSERT_MESSAGE("Palette entry 0 is black",
+ (*pDevice->getPalette())[0] == Color(0) );
+ CPPUNIT_ASSERT_MESSAGE("Palette entry 1 is white",
+ (*pDevice->getPalette())[1] == Color(0xFFFFFFFF) );
}
void testPixelFuncs()
diff --git a/basebmp/test/bmpmasktest.cxx b/basebmp/test/bmpmasktest.cxx
new file mode 100644
index 000000000000..a42bb4f82d8e
--- /dev/null
+++ b/basebmp/test/bmpmasktest.cxx
@@ -0,0 +1,195 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: bmpmasktest.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: thb $ $Date: 2006-07-12 15:09:45 $
+ *
+ * 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
+ *
+ ************************************************************************/
+
+// autogenerated file with codegen.pl
+
+#include <cppunit/simpleheader.hxx>
+
+#include <basegfx/vector/b2isize.hxx>
+#include <basegfx/range/b2irange.hxx>
+#include <basegfx/point/b2ipoint.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <basegfx/polygon/b2dpolypolygon.hxx>
+#include <basegfx/polygon/b2dpolypolygontools.hxx>
+
+#include <basebmp/color.hxx>
+#include <basebmp/scanlineformats.hxx>
+#include <basebmp/bitmapdevice.hxx>
+#include <basebmp/debug.hxx>
+#include "tools.hxx"
+
+#include <iostream>
+#include <fstream>
+
+using namespace ::basebmp;
+
+namespace
+{
+/*
+ std::ofstream output("32bpp_test.dump");
+ debugDump( rDevice, output );
+ std::ofstream output2("32bpp_bmp.dump");
+ debugDump( rBmp, output2 );
+*/
+
+class BmpMaskTest : public CppUnit::TestFixture
+{
+private:
+ BitmapDeviceSharedPtr mpDevice1bpp;
+ BitmapDeviceSharedPtr mpMaskBmp1bpp;
+ BitmapDeviceSharedPtr mpBmp1bpp;
+ BitmapDeviceSharedPtr mpDevice32bpp;
+ BitmapDeviceSharedPtr mpBmp32bpp;
+
+ void implTestBmpBasics(const BitmapDeviceSharedPtr& rDevice,
+ const BitmapDeviceSharedPtr& rBmp)
+ {
+ rDevice->clear(Color(0));
+ const Color aCol(0xFFFFFFFF);
+
+ const basegfx::B2IRange aSourceRect(0,0,10,10);
+ const basegfx::B2IRange aDestAll(0,0,10,10);
+
+ rDevice->drawMaskedBitmap(
+ rBmp,
+ mpMaskBmp1bpp,
+ aSourceRect,
+ aDestAll,
+ DrawMode_PAINT );
+ CPPUNIT_ASSERT_MESSAGE("number of rendered pixel is not 30",
+ countPixel( rDevice, aCol ) == 30);
+ }
+
+ void implTestBmpScaledClip(const BitmapDeviceSharedPtr& rDevice,
+ const BitmapDeviceSharedPtr& rBmp)
+ {
+ rDevice->clear(Color(0));
+ const Color aCol(0xFFFFFFFF);
+
+ const basegfx::B2IRange aSourceRect(0,0,10,10);
+ const basegfx::B2IRange aDestLeftTop(0,0,6,6);
+
+ rDevice->drawMaskedBitmap(
+ rBmp,
+ mpMaskBmp1bpp,
+ aSourceRect,
+ aDestLeftTop,
+ DrawMode_PAINT );
+ CPPUNIT_ASSERT_MESSAGE("number of rendered pixel is not 12",
+ countPixel( rDevice, aCol ) == 12);
+ }
+
+public:
+ void setUp()
+ {
+ const basegfx::B2ISize aSize(10,10);
+ mpDevice1bpp = createBitmapDevice( aSize,
+ true,
+ Format::ONE_BIT_MSB_PAL );
+ mpDevice32bpp = createBitmapDevice( aSize,
+ true,
+ Format::THIRTYTWO_BIT_TC_MASK );
+
+ mpMaskBmp1bpp = createBitmapDevice( aSize,
+ true,
+ Format::ONE_BIT_MSB_GREY );
+
+ mpBmp1bpp = createBitmapDevice( aSize,
+ true,
+ Format::ONE_BIT_MSB_PAL );
+ mpBmp32bpp = createBitmapDevice( aSize,
+ true,
+ Format::THIRTYTWO_BIT_TC_MASK );
+
+ ::rtl::OUString aSvg = ::rtl::OUString::createFromAscii(
+ "m 0 0h5v10h5v-5h-10z" );
+
+ basegfx::B2DPolyPolygon aPoly;
+ basegfx::tools::importFromSvgD( aPoly, aSvg );
+ const Color aCol(0xFFFFFFFF);
+ mpBmp1bpp->fillPolyPolygon(
+ aPoly,
+ aCol,
+ DrawMode_PAINT );
+ mpBmp32bpp->fillPolyPolygon(
+ aPoly,
+ aCol,
+ DrawMode_PAINT );
+
+ aSvg = ::rtl::OUString::createFromAscii(
+ "m 0 0 h6 v10 h-6z" );
+
+ aPoly.clear();
+ basegfx::tools::importFromSvgD( aPoly, aSvg );
+ mpMaskBmp1bpp->fillPolyPolygon(
+ aPoly,
+ aCol,
+ DrawMode_PAINT );
+ }
+
+ void testBmpBasics()
+ {
+ implTestBmpBasics( mpDevice1bpp, mpBmp1bpp );
+ implTestBmpBasics( mpDevice32bpp, mpBmp32bpp );
+ }
+
+ void testBmpClip()
+ {
+ implTestBmpScaledClip( mpDevice1bpp, mpBmp1bpp );
+ implTestBmpScaledClip( mpDevice32bpp, mpBmp32bpp );
+ }
+
+ // Change the following lines only, if you add, remove or rename
+ // member functions of the current class,
+ // because these macros are need by auto register mechanism.
+
+ CPPUNIT_TEST_SUITE(BmpMaskTest);
+ CPPUNIT_TEST(testBmpBasics);
+ CPPUNIT_TEST(testBmpClip);
+ CPPUNIT_TEST_SUITE_END();
+};
+
+// -----------------------------------------------------------------------------
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(BmpMaskTest, "BmpMaskTest");
+}
+
+
+// -----------------------------------------------------------------------------
+
+// this macro creates an empty function, which will called by the RegisterAllFunctions()
+// to let the user the possibility to also register some functions by hand.
+//NOADDITIONAL;
+
diff --git a/basebmp/test/makefile.mk b/basebmp/test/makefile.mk
index a87f0ded20ba..dc8f27a859a9 100644
--- a/basebmp/test/makefile.mk
+++ b/basebmp/test/makefile.mk
@@ -4,9 +4,9 @@
#
# $RCSfile: makefile.mk,v $
#
-# $Revision: 1.4 $
+# $Revision: 1.5 $
#
-# last change: $Author: thb $ $Date: 2006-06-08 00:01:48 $
+# last change: $Author: thb $ $Date: 2006-07-12 15:09:45 $
#
# The Contents of this file are made available subject to
# the terms of GNU Lesser General Public License Version 2.1.
@@ -66,6 +66,7 @@ CFLAGS += -fno-inline
SHL1OBJS= \
$(SLO)$/basictest.obj \
$(SLO)$/bmptest.obj \
+ $(SLO)$/bmpmasktest.obj \
$(SLO)$/cliptest.obj \
$(SLO)$/filltest.obj \
$(SLO)$/linetest.obj \