summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRüdiger Timm <rt@openoffice.org>2008-12-09 13:22:21 +0000
committerRüdiger Timm <rt@openoffice.org>2008-12-09 13:22:21 +0000
commit08dd93a4b70962aed0d2b1923b1a73d1d33e0bf3 (patch)
tree71741e6246bc9e4115770a4872a2f01906461feb
parent3a91fde276caa644d90f02da0e102dd4915fc460 (diff)
CWS-TOOLING: integrate CWS canvas06
2008-11-14 18:59:03 +0100 thb r263697 : Reverted fAlpha setup to previous state, as this was bogus as well - code path is apparently not taken for test, but anyway 2008-11-13 21:32:45 +0100 thb r263663 : WaE fix (and a bad bug as well - int color would have overflown) 2008-11-13 16:51:37 +0100 pl r263654 : remove warnings 2008-11-13 09:46:28 +0100 thb r263623 : #i95317# Fixed typo (thx WaE for finding) 2008-11-12 21:25:19 +0100 thb r263617 : #i96047# call update() on hidden sprite shape as well, to force actual hiding 2008-11-12 21:23:31 +0100 thb r263616 : #i95209# Merge from CWS thb11 - revives canvasbitmap unit tests, fixes nasty corner case in x11 salbmp (for 16bpp) 2008-11-12 21:21:46 +0100 thb r263615 : #i95197# Shuffled code to make valgrind quiet during bmp loading 2008-11-12 21:18:06 +0100 thb r263614 : #i93382# Make --disable-moz build work 2008-11-12 21:16:55 +0100 thb r263613 : #i95317# Fixed mis-named traits methods for min and max numbers 2008-11-12 20:59:01 +0100 thb r263612 : #i95317#, #i92902#: migrate CWS canvas06 to SVN.
-rw-r--r--basegfx/inc/basegfx/range/basicrange.hxx18
-rw-r--r--canvas/source/cairo/cairo_canvashelper.cxx388
-rwxr-xr-xcanvas/source/directx/dx_bitmapcanvashelper.cxx2
-rw-r--r--canvas/source/tools/canvastools.cxx75
-rw-r--r--canvas/source/vcl/canvashelper.cxx49
-rw-r--r--vcl/inc/vcl/canvasbitmap.hxx4
-rw-r--r--vcl/source/gdi/bitmap2.cxx18
-rw-r--r--vcl/source/gdi/cvtsvm.cxx13
-rw-r--r--vcl/source/gdi/impgraph.cxx2
-rw-r--r--vcl/source/helper/canvasbitmap.cxx219
-rw-r--r--vcl/source/helper/canvastools.cxx97
-rw-r--r--vcl/test/canvasbitmaptest.cxx224
-rwxr-xr-xvcl/test/dndtest.cxx26
-rw-r--r--vcl/test/makefile.mk9
-rw-r--r--vcl/unx/source/gdi/salbmp.cxx12
15 files changed, 969 insertions, 187 deletions
diff --git a/basegfx/inc/basegfx/range/basicrange.hxx b/basegfx/inc/basegfx/range/basicrange.hxx
index e3ac22b7f2c1..a7c402c905c8 100644
--- a/basegfx/inc/basegfx/range/basicrange.hxx
+++ b/basegfx/inc/basegfx/range/basicrange.hxx
@@ -49,8 +49,8 @@ namespace basegfx
typedef Traits TraitsType;
BasicRange() :
- mnMinimum(Traits::initMin()),
- mnMaximum(Traits::initMax())
+ mnMinimum(Traits::maxVal()),
+ mnMaximum(Traits::minVal())
{
}
@@ -68,13 +68,13 @@ namespace basegfx
void reset()
{
- mnMinimum = Traits::initMin();
- mnMaximum = Traits::initMax();
+ mnMinimum = Traits::maxVal();
+ mnMaximum = Traits::minVal();
}
bool isEmpty() const
{
- return Traits::initMin() == mnMinimum;
+ return Traits::maxVal() == mnMinimum;
}
T getMinimum() const { return mnMinimum; }
@@ -271,8 +271,8 @@ namespace basegfx
// some pre-fabricated traits
struct DoubleTraits
{
- static double initMin() { return DBL_MAX; };
- static double initMax() { return DBL_MIN; };
+ static double minVal() { return DBL_MIN; };
+ static double maxVal() { return DBL_MAX; };
static double neutral() { return 0.0; };
typedef double DifferenceType;
@@ -280,8 +280,8 @@ namespace basegfx
struct Int32Traits
{
- static sal_Int32 initMin() { return 0x7FFFFFFFL; };
- static sal_Int32 initMax() { return 0x80000000UL; };
+ static sal_Int32 minVal() { return SAL_MIN_INT32; };
+ static sal_Int32 maxVal() { return SAL_MAX_INT32; };
static sal_Int32 neutral() { return 0L; };
typedef sal_Int64 DifferenceType;
diff --git a/canvas/source/cairo/cairo_canvashelper.cxx b/canvas/source/cairo/cairo_canvashelper.cxx
index d7483fbf4b20..f1c54e9b4ab7 100644
--- a/canvas/source/cairo/cairo_canvashelper.cxx
+++ b/canvas/source/cairo/cairo_canvashelper.cxx
@@ -36,12 +36,19 @@
#include <rtl/logfile.hxx>
#include <rtl/math.hxx>
+#include <rtl/instance.hxx>
+#include <com/sun/star/util/Endianness.hpp>
#include <com/sun/star/rendering/TexturingMode.hpp>
#include <com/sun/star/rendering/CompositeOperation.hpp>
#include <com/sun/star/rendering/RepaintResult.hpp>
#include <com/sun/star/rendering/PathCapType.hpp>
#include <com/sun/star/rendering/PathJoinType.hpp>
+#include <com/sun/star/rendering/XIntegerBitmapColorSpace.hpp>
+#include <com/sun/star/rendering/IntegerBitmapLayout.hpp>
+#include <com/sun/star/rendering/ColorSpaceType.hpp>
+#include <com/sun/star/rendering/ColorComponentTag.hpp>
+#include <com/sun/star/rendering/RenderingIntent.hpp>
#include <basegfx/matrix/b2dhommatrix.hxx>
#include <basegfx/point/b2dpoint.hxx>
@@ -51,6 +58,7 @@
#include <basegfx/tools/canvastools.hxx>
#include <comphelper/sequence.hxx>
+#include <cppuhelper/compbase1.hxx>
#include <canvas/canvastools.hxx>
#include <canvas/parametricpolypolygon.hxx>
@@ -856,6 +864,10 @@ namespace cairocanvas
cairo_matrix_init_identity( &aIdentityMatrix );
cairo_set_matrix( pCairo, &aIdentityMatrix );
+ cairo_set_fill_rule( pCairo,
+ eFillrule == rendering::FillRule_EVEN_ODD ?
+ CAIRO_FILL_RULE_EVEN_ODD : CAIRO_FILL_RULE_WINDING );
+
for( sal_uInt32 nPolygonIndex = 0; nPolygonIndex < aPolyPolygon.count(); nPolygonIndex++ ) {
::basegfx::B2DPolygon aPolygon( aPolyPolygon.getB2DPolygon( nPolygonIndex ) );
const sal_uInt32 nPointCount( aPolygon.count() );
@@ -1408,12 +1420,386 @@ namespace cairocanvas
return uno::Reference< rendering::XBitmapPalette >();
}
+ namespace
+ {
+ class CairoColorSpace : public cppu::WeakImplHelper1< com::sun::star::rendering::XIntegerBitmapColorSpace >
+ {
+ private:
+ uno::Sequence< sal_Int8 > maComponentTags;
+ uno::Sequence< sal_Int32 > maBitCounts;
+
+ virtual ::sal_Int8 SAL_CALL getType( ) throw (uno::RuntimeException)
+ {
+ return rendering::ColorSpaceType::RGB;
+ }
+ virtual uno::Sequence< ::sal_Int8 > SAL_CALL getComponentTags( ) throw (uno::RuntimeException)
+ {
+ return maComponentTags;
+ }
+ virtual ::sal_Int8 SAL_CALL getRenderingIntent( ) throw (uno::RuntimeException)
+ {
+ return rendering::RenderingIntent::PERCEPTUAL;
+ }
+ virtual uno::Sequence< beans::PropertyValue > SAL_CALL getProperties( ) throw (uno::RuntimeException)
+ {
+ return uno::Sequence< beans::PropertyValue >();
+ }
+ virtual uno::Sequence< double > SAL_CALL convertColorSpace( const uno::Sequence< double >& deviceColor,
+ const uno::Reference< rendering::XColorSpace >& targetColorSpace ) throw (lang::IllegalArgumentException,
+ uno::RuntimeException)
+ {
+ // TODO(P3): if we know anything about target
+ // colorspace, this can be greatly sped up
+ uno::Sequence<rendering::ARGBColor> aIntermediate(
+ convertToARGB(deviceColor));
+ return targetColorSpace->convertFromARGB(aIntermediate);
+ }
+ virtual uno::Sequence< rendering::RGBColor > SAL_CALL convertToRGB( const uno::Sequence< double >& deviceColor ) throw (lang::IllegalArgumentException, uno::RuntimeException)
+ {
+ const double* pIn( deviceColor.getConstArray() );
+ const sal_Size nLen( deviceColor.getLength() );
+ ENSURE_ARG_OR_THROW2(nLen%4==0,
+ "number of channels no multiple of 4",
+ static_cast<rendering::XColorSpace*>(this), 0);
+
+ uno::Sequence< rendering::RGBColor > aRes(nLen/4);
+ rendering::RGBColor* pOut( aRes.getArray() );
+ for( sal_Size i=0; i<nLen; i+=4 )
+ {
+ const double fAlpha(pIn[3]);
+ if( fAlpha == 0.0 )
+ *pOut++ = rendering::RGBColor(0.0, 0.0, 0.0);
+ else
+ *pOut++ = rendering::RGBColor(pIn[2]/fAlpha,pIn[1]/fAlpha,pIn[0]/fAlpha);
+ pIn += 4;
+ }
+ return aRes;
+ }
+ virtual uno::Sequence< rendering::ARGBColor > SAL_CALL convertToARGB( const uno::Sequence< double >& deviceColor ) throw (lang::IllegalArgumentException, uno::RuntimeException)
+ {
+ const double* pIn( deviceColor.getConstArray() );
+ const sal_Size nLen( deviceColor.getLength() );
+ ENSURE_ARG_OR_THROW2(nLen%4==0,
+ "number of channels no multiple of 4",
+ static_cast<rendering::XColorSpace*>(this), 0);
+
+ uno::Sequence< rendering::ARGBColor > aRes(nLen/4);
+ rendering::ARGBColor* pOut( aRes.getArray() );
+ for( sal_Size i=0; i<nLen; i+=4 )
+ {
+ const double fAlpha(pIn[3]);
+ if( fAlpha == 0.0 )
+ *pOut++ = rendering::ARGBColor(0.0, 0.0, 0.0, 0.0);
+ else
+ *pOut++ = rendering::ARGBColor(fAlpha,pIn[2]/fAlpha,pIn[1]/fAlpha,pIn[0]/fAlpha);
+ pIn += 4;
+ }
+ return aRes;
+ }
+ virtual uno::Sequence< rendering::ARGBColor > SAL_CALL convertToPARGB( const uno::Sequence< double >& deviceColor ) throw (lang::IllegalArgumentException, uno::RuntimeException)
+ {
+ const double* pIn( deviceColor.getConstArray() );
+ const sal_Size nLen( deviceColor.getLength() );
+ ENSURE_ARG_OR_THROW2(nLen%4==0,
+ "number of channels no multiple of 4",
+ static_cast<rendering::XColorSpace*>(this), 0);
+
+ uno::Sequence< rendering::ARGBColor > aRes(nLen/4);
+ rendering::ARGBColor* pOut( aRes.getArray() );
+ for( sal_Size i=0; i<nLen; i+=4 )
+ {
+ *pOut++ = rendering::ARGBColor(pIn[3],pIn[2],pIn[1],pIn[1]);
+ pIn += 4;
+ }
+ return aRes;
+ }
+ virtual uno::Sequence< double > SAL_CALL convertFromRGB( const uno::Sequence< rendering::RGBColor >& rgbColor ) throw (lang::IllegalArgumentException, uno::RuntimeException)
+ {
+ const rendering::RGBColor* pIn( rgbColor.getConstArray() );
+ const sal_Size nLen( rgbColor.getLength() );
+
+ uno::Sequence< double > aRes(nLen*4);
+ double* pColors=aRes.getArray();
+ for( sal_Size i=0; i<nLen; ++i )
+ {
+ *pColors++ = pIn->Blue;
+ *pColors++ = pIn->Green;
+ *pColors++ = pIn->Red;
+ *pColors++ = 1.0;
+ ++pIn;
+ }
+ return aRes;
+ }
+ virtual uno::Sequence< double > SAL_CALL convertFromARGB( const uno::Sequence< rendering::ARGBColor >& rgbColor ) throw (lang::IllegalArgumentException, uno::RuntimeException)
+ {
+ const rendering::ARGBColor* pIn( rgbColor.getConstArray() );
+ const sal_Size nLen( rgbColor.getLength() );
+
+ uno::Sequence< double > aRes(nLen*4);
+ double* pColors=aRes.getArray();
+ for( sal_Size i=0; i<nLen; ++i )
+ {
+ *pColors++ = pIn->Alpha*pIn->Blue;
+ *pColors++ = pIn->Alpha*pIn->Green;
+ *pColors++ = pIn->Alpha*pIn->Red;
+ *pColors++ = pIn->Alpha;
+ ++pIn;
+ }
+ return aRes;
+ }
+ virtual uno::Sequence< double > SAL_CALL convertFromPARGB( const uno::Sequence< rendering::ARGBColor >& rgbColor ) throw (lang::IllegalArgumentException, uno::RuntimeException)
+ {
+ const rendering::ARGBColor* pIn( rgbColor.getConstArray() );
+ const sal_Size nLen( rgbColor.getLength() );
+
+ uno::Sequence< double > aRes(nLen*4);
+ double* pColors=aRes.getArray();
+ for( sal_Size i=0; i<nLen; ++i )
+ {
+ *pColors++ = pIn->Blue;
+ *pColors++ = pIn->Green;
+ *pColors++ = pIn->Red;
+ *pColors++ = pIn->Alpha;
+ ++pIn;
+ }
+ return aRes;
+ }
+
+ // XIntegerBitmapColorSpace
+ virtual ::sal_Int32 SAL_CALL getBitsPerPixel( ) throw (uno::RuntimeException)
+ {
+ return 32;
+ }
+ virtual uno::Sequence< ::sal_Int32 > SAL_CALL getComponentBitCounts( ) throw (uno::RuntimeException)
+ {
+ return maBitCounts;
+ }
+ virtual ::sal_Int8 SAL_CALL getEndianness( ) throw (uno::RuntimeException)
+ {
+ return util::Endianness::LITTLE;
+ }
+ virtual uno::Sequence<double> SAL_CALL convertFromIntegerColorSpace( const uno::Sequence< ::sal_Int8 >& deviceColor,
+ const uno::Reference< rendering::XColorSpace >& targetColorSpace ) throw (lang::IllegalArgumentException,
+ uno::RuntimeException)
+ {
+ if( dynamic_cast<CairoColorSpace*>(targetColorSpace.get()) )
+ {
+ const sal_Int8* pIn( deviceColor.getConstArray() );
+ const sal_Size nLen( deviceColor.getLength() );
+ ENSURE_ARG_OR_THROW2(nLen%4==0,
+ "number of channels no multiple of 4",
+ static_cast<rendering::XColorSpace*>(this), 0);
+
+ uno::Sequence<double> aRes(nLen);
+ double* pOut( aRes.getArray() );
+ for( sal_Size i=0; i<nLen; i+=4 )
+ {
+ *pOut++ = vcl::unotools::toDoubleColor(*pIn++);
+ *pOut++ = vcl::unotools::toDoubleColor(*pIn++);
+ *pOut++ = vcl::unotools::toDoubleColor(*pIn++);
+ *pOut++ = vcl::unotools::toDoubleColor(*pIn++);
+ }
+ return aRes;
+ }
+ else
+ {
+ // TODO(P3): if we know anything about target
+ // colorspace, this can be greatly sped up
+ uno::Sequence<rendering::ARGBColor> aIntermediate(
+ convertIntegerToARGB(deviceColor));
+ return targetColorSpace->convertFromARGB(aIntermediate);
+ }
+ }
+ virtual uno::Sequence< ::sal_Int8 > SAL_CALL convertToIntegerColorSpace( const uno::Sequence< ::sal_Int8 >& deviceColor,
+ const uno::Reference< rendering::XIntegerBitmapColorSpace >& targetColorSpace ) throw (lang::IllegalArgumentException,
+ uno::RuntimeException)
+ {
+ if( dynamic_cast<CairoColorSpace*>(targetColorSpace.get()) )
+ {
+ // it's us, so simply pass-through the data
+ return deviceColor;
+ }
+ else
+ {
+ // TODO(P3): if we know anything about target
+ // colorspace, this can be greatly sped up
+ uno::Sequence<rendering::ARGBColor> aIntermediate(
+ convertIntegerToARGB(deviceColor));
+ return targetColorSpace->convertIntegerFromARGB(aIntermediate);
+ }
+ }
+ virtual uno::Sequence< rendering::RGBColor > SAL_CALL convertIntegerToRGB( const uno::Sequence< ::sal_Int8 >& deviceColor ) throw (lang::IllegalArgumentException, uno::RuntimeException)
+ {
+ const sal_Int8* pIn( deviceColor.getConstArray() );
+ const sal_Size nLen( deviceColor.getLength() );
+ ENSURE_ARG_OR_THROW2(nLen%4==0,
+ "number of channels no multiple of 4",
+ static_cast<rendering::XColorSpace*>(this), 0);
+
+ uno::Sequence< rendering::RGBColor > aRes(nLen/4);
+ rendering::RGBColor* pOut( aRes.getArray() );
+ for( sal_Size i=0; i<nLen; i+=4 )
+ {
+ const sal_Int8 nAlpha(pIn[3]);
+ if( nAlpha )
+ *pOut++ = rendering::RGBColor(
+ vcl::unotools::toDoubleColor(pIn[2]/nAlpha),
+ vcl::unotools::toDoubleColor(pIn[1]/nAlpha),
+ vcl::unotools::toDoubleColor(pIn[0]/nAlpha));
+ else
+ *pOut++ = rendering::RGBColor(0,0,0);
+ pIn += 4;
+ }
+ return aRes;
+ }
+
+ virtual uno::Sequence< rendering::ARGBColor > SAL_CALL convertIntegerToARGB( const uno::Sequence< ::sal_Int8 >& deviceColor ) throw (lang::IllegalArgumentException, uno::RuntimeException)
+ {
+ const sal_Int8* pIn( deviceColor.getConstArray() );
+ const sal_Size nLen( deviceColor.getLength() );
+ ENSURE_ARG_OR_THROW2(nLen%4==0,
+ "number of channels no multiple of 4",
+ static_cast<rendering::XColorSpace*>(this), 0);
+
+ uno::Sequence< rendering::ARGBColor > aRes(nLen/4);
+ rendering::ARGBColor* pOut( aRes.getArray() );
+ for( sal_Size i=0; i<nLen; i+=4 )
+ {
+ const sal_Int8 nAlpha(pIn[3]);
+ if( nAlpha )
+ *pOut++ = rendering::ARGBColor(
+ vcl::unotools::toDoubleColor(nAlpha),
+ vcl::unotools::toDoubleColor(pIn[2]/nAlpha),
+ vcl::unotools::toDoubleColor(pIn[1]/nAlpha),
+ vcl::unotools::toDoubleColor(pIn[0]/nAlpha));
+ else
+ *pOut++ = rendering::ARGBColor(0,0,0,0);
+ pIn += 4;
+ }
+ return aRes;
+ }
+ virtual uno::Sequence< rendering::ARGBColor > SAL_CALL convertIntegerToPARGB( const uno::Sequence< ::sal_Int8 >& deviceColor ) throw (lang::IllegalArgumentException, uno::RuntimeException)
+ {
+ const sal_Int8* pIn( deviceColor.getConstArray() );
+ const sal_Size nLen( deviceColor.getLength() );
+ ENSURE_ARG_OR_THROW2(nLen%4==0,
+ "number of channels no multiple of 4",
+ static_cast<rendering::XColorSpace*>(this), 0);
+
+ uno::Sequence< rendering::ARGBColor > aRes(nLen/4);
+ rendering::ARGBColor* pOut( aRes.getArray() );
+ for( sal_Size i=0; i<nLen; i+=4 )
+ {
+ *pOut++ = rendering::ARGBColor(
+ vcl::unotools::toDoubleColor(pIn[3]),
+ vcl::unotools::toDoubleColor(pIn[2]),
+ vcl::unotools::toDoubleColor(pIn[1]),
+ vcl::unotools::toDoubleColor(pIn[0]));
+ pIn += 4;
+ }
+ return aRes;
+ }
+
+ virtual uno::Sequence< ::sal_Int8 > SAL_CALL convertIntegerFromRGB( const uno::Sequence< rendering::RGBColor >& rgbColor ) throw (lang::IllegalArgumentException, uno::RuntimeException)
+ {
+ const rendering::RGBColor* pIn( rgbColor.getConstArray() );
+ const sal_Size nLen( rgbColor.getLength() );
+
+ uno::Sequence< sal_Int8 > aRes(nLen*4);
+ sal_Int8* pColors=aRes.getArray();
+ for( sal_Size i=0; i<nLen; ++i )
+ {
+ *pColors++ = vcl::unotools::toByteColor(pIn->Blue);
+ *pColors++ = vcl::unotools::toByteColor(pIn->Green);
+ *pColors++ = vcl::unotools::toByteColor(pIn->Red);
+ *pColors++ = 255;
+ ++pIn;
+ }
+ return aRes;
+ }
+
+ virtual uno::Sequence< ::sal_Int8 > SAL_CALL convertIntegerFromARGB( const uno::Sequence< rendering::ARGBColor >& rgbColor ) throw (lang::IllegalArgumentException, uno::RuntimeException)
+ {
+ const rendering::ARGBColor* pIn( rgbColor.getConstArray() );
+ const sal_Size nLen( rgbColor.getLength() );
+
+ uno::Sequence< sal_Int8 > aRes(nLen*4);
+ sal_Int8* pColors=aRes.getArray();
+ for( sal_Size i=0; i<nLen; ++i )
+ {
+ const double fAlpha(pIn->Alpha);
+ *pColors++ = vcl::unotools::toByteColor(fAlpha*pIn->Blue);
+ *pColors++ = vcl::unotools::toByteColor(fAlpha*pIn->Green);
+ *pColors++ = vcl::unotools::toByteColor(fAlpha*pIn->Red);
+ *pColors++ = vcl::unotools::toByteColor(fAlpha);
+ ++pIn;
+ }
+ return aRes;
+ }
+ virtual uno::Sequence< ::sal_Int8 > SAL_CALL convertIntegerFromPARGB( const uno::Sequence< rendering::ARGBColor >& rgbColor ) throw (lang::IllegalArgumentException, uno::RuntimeException)
+ {
+ const rendering::ARGBColor* pIn( rgbColor.getConstArray() );
+ const sal_Size nLen( rgbColor.getLength() );
+
+ uno::Sequence< sal_Int8 > aRes(nLen*4);
+ sal_Int8* pColors=aRes.getArray();
+ for( sal_Size i=0; i<nLen; ++i )
+ {
+ *pColors++ = vcl::unotools::toByteColor(pIn->Blue);
+ *pColors++ = vcl::unotools::toByteColor(pIn->Green);
+ *pColors++ = vcl::unotools::toByteColor(pIn->Red);
+ *pColors++ = vcl::unotools::toByteColor(pIn->Alpha);
+ ++pIn;
+ }
+ return aRes;
+ }
+
+ public:
+ CairoColorSpace() :
+ maComponentTags(4),
+ maBitCounts(4)
+ {
+ sal_Int8* pTags = maComponentTags.getArray();
+ sal_Int32* pBitCounts = maBitCounts.getArray();
+ pTags[0] = rendering::ColorComponentTag::RGB_BLUE;
+ pTags[1] = rendering::ColorComponentTag::RGB_GREEN;
+ pTags[2] = rendering::ColorComponentTag::RGB_RED;
+ pTags[3] = rendering::ColorComponentTag::PREMULTIPLIED_ALPHA;
+
+ pBitCounts[0] =
+ pBitCounts[1] =
+ pBitCounts[2] =
+ pBitCounts[3] = 8;
+ }
+ };
+
+ struct CairoColorSpaceHolder : public rtl::StaticWithInit<uno::Reference<rendering::XIntegerBitmapColorSpace>,
+ CairoColorSpaceHolder>
+ {
+ uno::Reference<rendering::XIntegerBitmapColorSpace> operator()()
+ {
+ return new CairoColorSpace();
+ }
+ };
+ }
+
rendering::IntegerBitmapLayout CanvasHelper::getMemoryLayout()
{
if( !mpCairo )
return rendering::IntegerBitmapLayout(); // we're disposed
- return ::canvas::tools::getStdMemoryLayout(getSize());
+ const geometry::IntegerSize2D aSize(getSize());
+ rendering::IntegerBitmapLayout aLayout;
+
+ aLayout.ScanLines = aSize.Height;
+ aLayout.ScanLineBytes = aSize.Width*4;
+ aLayout.ScanLineStride = aLayout.ScanLineBytes;
+ aLayout.PlaneStride = 0;
+ aLayout.ColorSpace = CairoColorSpaceHolder::get();
+ aLayout.Palette.clear();
+ aLayout.IsMsbFirst = sal_False;
+
+ return aLayout;
}
void CanvasHelper::flush() const
diff --git a/canvas/source/directx/dx_bitmapcanvashelper.cxx b/canvas/source/directx/dx_bitmapcanvashelper.cxx
index 83a85762cf35..467b91dec1d7 100755
--- a/canvas/source/directx/dx_bitmapcanvashelper.cxx
+++ b/canvas/source/directx/dx_bitmapcanvashelper.cxx
@@ -180,6 +180,7 @@ namespace dxcanvas
if( !mpTarget )
return uno::Sequence< sal_Int8 >();
+ bitmapLayout = getMemoryLayout();
return mpTarget->getData(bitmapLayout,rect);
}
@@ -224,6 +225,7 @@ namespace dxcanvas
if( !mpTarget )
return uno::Sequence< sal_Int8 >();
+ bitmapLayout = getMemoryLayout();
return mpTarget->getPixel(bitmapLayout,pos);
}
diff --git a/canvas/source/tools/canvastools.cxx b/canvas/source/tools/canvastools.cxx
index 81dbd0498df6..23d6124e4cb8 100644
--- a/canvas/source/tools/canvastools.cxx
+++ b/canvas/source/tools/canvastools.cxx
@@ -333,6 +333,23 @@ namespace canvas
}
return aRes;
}
+ virtual uno::Sequence< rendering::ARGBColor > SAL_CALL convertToPARGB( const uno::Sequence< double >& deviceColor ) throw (lang::IllegalArgumentException, uno::RuntimeException)
+ {
+ const double* pIn( deviceColor.getConstArray() );
+ const sal_Size nLen( deviceColor.getLength() );
+ ENSURE_ARG_OR_THROW2(nLen%4==0,
+ "number of channels no multiple of 4",
+ static_cast<rendering::XColorSpace*>(this), 0);
+
+ uno::Sequence< rendering::ARGBColor > aRes(nLen/4);
+ rendering::ARGBColor* pOut( aRes.getArray() );
+ for( sal_Size i=0; i<nLen; i+=4 )
+ {
+ *pOut++ = rendering::ARGBColor(pIn[3],pIn[3]*pIn[0],pIn[3]*pIn[1],pIn[3]*pIn[2]);
+ pIn += 4;
+ }
+ return aRes;
+ }
virtual uno::Sequence< double > SAL_CALL convertFromRGB( const uno::Sequence< rendering::RGBColor >& rgbColor ) throw (lang::IllegalArgumentException, uno::RuntimeException)
{
const rendering::RGBColor* pIn( rgbColor.getConstArray() );
@@ -367,6 +384,23 @@ namespace canvas
}
return aRes;
}
+ virtual uno::Sequence< double > SAL_CALL convertFromPARGB( const uno::Sequence< rendering::ARGBColor >& rgbColor ) throw (lang::IllegalArgumentException, uno::RuntimeException)
+ {
+ const rendering::ARGBColor* pIn( rgbColor.getConstArray() );
+ const sal_Size nLen( rgbColor.getLength() );
+
+ uno::Sequence< double > aRes(nLen*4);
+ double* pColors=aRes.getArray();
+ for( sal_Size i=0; i<nLen; ++i )
+ {
+ *pColors++ = pIn->Red/pIn->Alpha;
+ *pColors++ = pIn->Green/pIn->Alpha;
+ *pColors++ = pIn->Blue/pIn->Alpha;
+ *pColors++ = pIn->Alpha;
+ ++pIn;
+ }
+ return aRes;
+ }
// XIntegerBitmapColorSpace
virtual ::sal_Int32 SAL_CALL getBitsPerPixel( ) throw (uno::RuntimeException)
@@ -474,6 +508,29 @@ namespace canvas
return aRes;
}
+ virtual uno::Sequence< rendering::ARGBColor > SAL_CALL convertIntegerToPARGB( const uno::Sequence< ::sal_Int8 >& deviceColor ) throw (lang::IllegalArgumentException, uno::RuntimeException)
+ {
+ const sal_Int8* pIn( deviceColor.getConstArray() );
+ const sal_Size nLen( deviceColor.getLength() );
+ ENSURE_ARG_OR_THROW2(nLen%4==0,
+ "number of channels no multiple of 4",
+ static_cast<rendering::XColorSpace*>(this), 0);
+
+ uno::Sequence< rendering::ARGBColor > aRes(nLen/4);
+ rendering::ARGBColor* pOut( aRes.getArray() );
+ for( sal_Size i=0; i<nLen; i+=4 )
+ {
+ const sal_Int8 nAlpha( 255-pIn[3] );
+ *pOut++ = rendering::ARGBColor(
+ vcl::unotools::toDoubleColor(nAlpha),
+ vcl::unotools::toDoubleColor(nAlpha*pIn[0]),
+ vcl::unotools::toDoubleColor(nAlpha*pIn[1]),
+ vcl::unotools::toDoubleColor(nAlpha*pIn[2]));
+ pIn += 4;
+ }
+ return aRes;
+ }
+
virtual uno::Sequence< ::sal_Int8 > SAL_CALL convertIntegerFromRGB( const uno::Sequence< rendering::RGBColor >& rgbColor ) throw (lang::IllegalArgumentException, uno::RuntimeException)
{
const rendering::RGBColor* pIn( rgbColor.getConstArray() );
@@ -510,6 +567,24 @@ namespace canvas
return aRes;
}
+ virtual uno::Sequence< ::sal_Int8 > SAL_CALL convertIntegerFromPARGB( const uno::Sequence< rendering::ARGBColor >& rgbColor ) throw (lang::IllegalArgumentException, uno::RuntimeException)
+ {
+ const rendering::ARGBColor* pIn( rgbColor.getConstArray() );
+ const sal_Size nLen( rgbColor.getLength() );
+
+ uno::Sequence< sal_Int8 > aRes(nLen*4);
+ sal_Int8* pColors=aRes.getArray();
+ for( sal_Size i=0; i<nLen; ++i )
+ {
+ *pColors++ = vcl::unotools::toByteColor(pIn->Red/pIn->Alpha);
+ *pColors++ = vcl::unotools::toByteColor(pIn->Green/pIn->Alpha);
+ *pColors++ = vcl::unotools::toByteColor(pIn->Blue/pIn->Alpha);
+ *pColors++ = 255-vcl::unotools::toByteColor(pIn->Alpha);
+ ++pIn;
+ }
+ return aRes;
+ }
+
public:
StandardColorSpace() :
maComponentTags(4),
diff --git a/canvas/source/vcl/canvashelper.cxx b/canvas/source/vcl/canvashelper.cxx
index 8f634d99bf7f..20b489144d0e 100644
--- a/canvas/source/vcl/canvashelper.cxx
+++ b/canvas/source/vcl/canvashelper.cxx
@@ -147,6 +147,7 @@ namespace vclcanvas
void CanvasHelper::setBackgroundOutDev( const OutDevProviderSharedPtr& rOutDev )
{
mp2ndOutDev = rOutDev;
+ mp2ndOutDev->getOutDev().EnableMapMode( FALSE );
}
void CanvasHelper::clear()
@@ -155,6 +156,7 @@ namespace vclcanvas
if( mpOutDev )
{
OutputDevice& rOutDev( mpOutDev->getOutDev() );
+ tools::OutDevStateKeeper aStateKeeper( mpProtectedOutDev );
rOutDev.EnableMapMode( FALSE );
rOutDev.SetLineColor( COL_WHITE );
@@ -188,7 +190,6 @@ namespace vclcanvas
{
// nope, render
tools::OutDevStateKeeper aStateKeeper( mpProtectedOutDev );
-
setupOutDevState( viewState, renderState, LINE_COLOR );
const Point aOutPoint( tools::mapRealPoint2D( aPoint,
@@ -212,7 +213,6 @@ namespace vclcanvas
{
// nope, render
tools::OutDevStateKeeper aStateKeeper( mpProtectedOutDev );
-
setupOutDevState( viewState, renderState, LINE_COLOR );
const Point aStartPoint( tools::mapRealPoint2D( aStartRealPoint2D,
@@ -236,7 +236,6 @@ namespace vclcanvas
if( mpOutDev )
{
tools::OutDevStateKeeper aStateKeeper( mpProtectedOutDev );
-
setupOutDevState( viewState, renderState, LINE_COLOR );
const Point& rStartPoint( tools::mapRealPoint2D( geometry::RealPoint2D(aBezierSegment.Px,
@@ -279,7 +278,6 @@ namespace vclcanvas
if( mpOutDev )
{
tools::OutDevStateKeeper aStateKeeper( mpProtectedOutDev );
-
setupOutDevState( viewState, renderState, LINE_COLOR );
const ::basegfx::B2DPolyPolygon& rPolyPoly(
@@ -688,7 +686,6 @@ namespace vclcanvas
if( mpOutDev )
{
tools::OutDevStateKeeper aStateKeeper( mpProtectedOutDev );
-
setupOutDevState( viewState, renderState, IGNORE_COLOR );
::basegfx::B2DHomMatrix aMatrix;
@@ -916,11 +913,16 @@ namespace vclcanvas
if( !mpOutDev.get() || !mpDevice )
return uno::Reference< rendering::XBitmap >(); // we're disposed
+ OutputDevice& rOutDev( mpOutDev->getOutDev() );
+
+ tools::OutDevStateKeeper aStateKeeper( mpProtectedOutDev );
+ rOutDev.EnableMapMode( FALSE );
+
// TODO(F2): Support alpha vdev canvas here
const Point aEmptyPoint(0,0);
- const Size aBmpSize( mpOutDev->getOutDev().GetOutputSizePixel() );
+ const Size aBmpSize( rOutDev.GetOutputSizePixel() );
- Bitmap aBitmap( mpOutDev->getOutDev().GetBitmap(aEmptyPoint, aBmpSize) );
+ Bitmap aBitmap( rOutDev.GetBitmap(aEmptyPoint, aBmpSize) );
aBitmap.Scale( ::vcl::unotools::sizeFromRealSize2D(newSize),
beFast ? BMP_SCALE_FAST : BMP_SCALE_INTERPOLATE );
@@ -940,8 +942,13 @@ namespace vclcanvas
// TODO(F2): Support alpha canvas here
const Rectangle aRect( ::vcl::unotools::rectangleFromIntegerRectangle2D(rect) );
- Bitmap aBitmap( mpOutDev->getOutDev().GetBitmap(aRect.TopLeft(),
- aRect.GetSize()) );
+ OutputDevice& rOutDev( mpOutDev->getOutDev() );
+
+ tools::OutDevStateKeeper aStateKeeper( mpProtectedOutDev );
+ rOutDev.EnableMapMode( FALSE );
+
+ Bitmap aBitmap( rOutDev.GetBitmap(aRect.TopLeft(),
+ aRect.GetSize()) );
ScopedBitmapReadAccess pReadAccess( aBitmap.AcquireReadAccess(),
aBitmap );
@@ -990,6 +997,9 @@ namespace vclcanvas
OutputDevice& rOutDev( mpOutDev->getOutDev() );
+ tools::OutDevStateKeeper aStateKeeper( mpProtectedOutDev );
+ rOutDev.EnableMapMode( FALSE );
+
const Rectangle aRect( ::vcl::unotools::rectangleFromIntegerRectangle2D(rect) );
const USHORT nBitCount( ::std::min( (USHORT)24U,
(USHORT)rOutDev.GetBitCount() ) );
@@ -1099,10 +1109,7 @@ namespace vclcanvas
// destroyed beforehand
if( bCopyBack )
{
- tools::OutDevStateKeeper aStateKeeper( mpProtectedOutDev );
-
// TODO(F2): Support alpha canvas here
- rOutDev.EnableMapMode( FALSE );
rOutDev.DrawBitmap(aRect.TopLeft(), aBitmap);
}
}
@@ -1115,6 +1122,10 @@ namespace vclcanvas
return; // we're disposed
OutputDevice& rOutDev( mpOutDev->getOutDev() );
+
+ tools::OutDevStateKeeper aStateKeeper( mpProtectedOutDev );
+ rOutDev.EnableMapMode( FALSE );
+
const Size aBmpSize( rOutDev.GetOutputSizePixel() );
ENSURE_ARG_OR_THROW( pos.X >= 0 && pos.X < aBmpSize.Width(),
@@ -1131,10 +1142,6 @@ namespace vclcanvas
aRefLayout.IsMsbFirst != rLayout.IsMsbFirst,
"Mismatching memory layout" );
- tools::OutDevStateKeeper aStateKeeper( mpProtectedOutDev );
-
- rOutDev.EnableMapMode( FALSE );
-
// TODO(F2): Support alpha canvas here
rOutDev.DrawPixel( ::vcl::unotools::pointFromIntegerPoint2D( pos ),
::canvas::tools::stdIntSequenceToColor( color ));
@@ -1153,6 +1160,9 @@ namespace vclcanvas
OutputDevice& rOutDev( mpOutDev->getOutDev() );
+ tools::OutDevStateKeeper aStateKeeper( mpProtectedOutDev );
+ rOutDev.EnableMapMode( FALSE );
+
const Size aBmpSize( rOutDev.GetOutputSizePixel() );
ENSURE_ARG_OR_THROW( pos.X >= 0 && pos.X < aBmpSize.Width(),
@@ -1160,10 +1170,6 @@ namespace vclcanvas
ENSURE_ARG_OR_THROW( pos.Y >= 0 && pos.Y < aBmpSize.Height(),
"Y coordinate out of bounds" );
- tools::OutDevStateKeeper aStateKeeper( mpProtectedOutDev );
-
- rOutDev.EnableMapMode( FALSE );
-
// TODO(F2): Support alpha canvas here
return ::canvas::tools::colorToStdIntSequence(
rOutDev.GetPixel(
@@ -1194,6 +1200,8 @@ namespace vclcanvas
OutputDevice& rOutDev( mpOutDev->getOutDev() );
OutputDevice* p2ndOutDev = NULL;
+ rOutDev.EnableMapMode( FALSE );
+
if( mp2ndOutDev )
p2ndOutDev = &mp2ndOutDev->getOutDev();
@@ -1389,6 +1397,7 @@ namespace vclcanvas
return false; // disposed
else
{
+ tools::OutDevStateKeeper aStateKeeper( mpProtectedOutDev );
setupOutDevState( viewState, renderState, IGNORE_COLOR );
if( !rGrf->Draw( &mpOutDev->getOutDev(), rPt, rSz, &rAttr ) )
diff --git a/vcl/inc/vcl/canvasbitmap.hxx b/vcl/inc/vcl/canvasbitmap.hxx
index 0d3512874a5c..b96afd9084c0 100644
--- a/vcl/inc/vcl/canvasbitmap.hxx
+++ b/vcl/inc/vcl/canvasbitmap.hxx
@@ -99,8 +99,10 @@ namespace unotools
virtual ::com::sun::star::uno::Sequence< double > SAL_CALL convertColorSpace( const ::com::sun::star::uno::Sequence< double >& deviceColor, const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XColorSpace >& targetColorSpace ) throw (::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Sequence< ::com::sun::star::rendering::RGBColor > SAL_CALL convertToRGB( const ::com::sun::star::uno::Sequence< double >& deviceColor ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Sequence< ::com::sun::star::rendering::ARGBColor > SAL_CALL convertToARGB( const ::com::sun::star::uno::Sequence< double >& deviceColor ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::rendering::ARGBColor > SAL_CALL convertToPARGB( const ::com::sun::star::uno::Sequence< double >& deviceColor ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Sequence< double > SAL_CALL convertFromRGB( const ::com::sun::star::uno::Sequence< ::com::sun::star::rendering::RGBColor >& rgbColor ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Sequence< double > SAL_CALL convertFromARGB( const ::com::sun::star::uno::Sequence< ::com::sun::star::rendering::ARGBColor >& rgbColor ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< double > SAL_CALL convertFromPARGB( const ::com::sun::star::uno::Sequence< ::com::sun::star::rendering::ARGBColor >& rgbColor ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
virtual ::sal_Int32 SAL_CALL getBitsPerPixel( ) throw (::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Sequence< ::sal_Int32 > SAL_CALL getComponentBitCounts( ) throw (::com::sun::star::uno::RuntimeException);
virtual ::sal_Int8 SAL_CALL getEndianness( ) throw (::com::sun::star::uno::RuntimeException);
@@ -108,8 +110,10 @@ namespace unotools
virtual ::com::sun::star::uno::Sequence< ::sal_Int8 > SAL_CALL convertToIntegerColorSpace( const ::com::sun::star::uno::Sequence< ::sal_Int8 >& deviceColor, const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XIntegerBitmapColorSpace >& targetColorSpace ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Sequence< ::com::sun::star::rendering::RGBColor > SAL_CALL convertIntegerToRGB( const ::com::sun::star::uno::Sequence< ::sal_Int8 >& deviceColor ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Sequence< ::com::sun::star::rendering::ARGBColor > SAL_CALL convertIntegerToARGB( const ::com::sun::star::uno::Sequence< ::sal_Int8 >& deviceColor ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::rendering::ARGBColor > SAL_CALL convertIntegerToPARGB( const ::com::sun::star::uno::Sequence< ::sal_Int8 >& deviceColor ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Sequence< ::sal_Int8 > SAL_CALL convertIntegerFromRGB( const ::com::sun::star::uno::Sequence< ::com::sun::star::rendering::RGBColor >& rgbColor ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Sequence< ::sal_Int8 > SAL_CALL convertIntegerFromARGB( const ::com::sun::star::uno::Sequence< ::com::sun::star::rendering::ARGBColor >& rgbColor ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::sal_Int8 > SAL_CALL convertIntegerFromPARGB( const ::com::sun::star::uno::Sequence< ::com::sun::star::rendering::ARGBColor >& rgbColor ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
/** Create API wrapper for given BitmapEx
diff --git a/vcl/source/gdi/bitmap2.cxx b/vcl/source/gdi/bitmap2.cxx
index de9da1fb638f..39aa9da8c470 100644
--- a/vcl/source/gdi/bitmap2.cxx
+++ b/vcl/source/gdi/bitmap2.cxx
@@ -756,18 +756,18 @@ BOOL Bitmap::ImplWriteDIB( SvStream& rOStm, BitmapReadAccess& rAcc, BOOL bCompre
// MapMode is integer-based, and suffers from roundoffs,
// especially if maPrefSize is small. Trying to circumvent
// that by performing part of the math in floating point.
- const Size aScale10000(
+ const Size aScale100000(
OutputDevice::LogicToLogic( Size(100000L,
100000L),
- maPrefMapMode,
- MAP_100TH_MM ) );
- const double fScaleX((double)aScale10000.Width() * maPrefSize.Width());
- const double fScaleY((double)aScale10000.Height() * maPrefSize.Height());
- if( fabs(fScaleX) > 0.000000001 &&
- fabs(fScaleY) > 0.000000001 )
+ MAP_100TH_MM,
+ maPrefMapMode ) );
+ const double fBmpWidthM((double)maPrefSize.Width() / aScale100000.Width() );
+ const double fBmpHeightM((double)maPrefSize.Height() / aScale100000.Height() );
+ if( fabs(fBmpWidthM) > 0.000000001 &&
+ fabs(fBmpHeightM) > 0.000000001 )
{
- aHeader.nXPelsPerMeter = (UINT32)(rAcc.Width() / fScaleX + .5);
- aHeader.nYPelsPerMeter = (UINT32)(rAcc.Height() / fScaleY + .5);
+ aHeader.nXPelsPerMeter = (UINT32)(rAcc.Width() / fBmpWidthM + .5);
+ aHeader.nYPelsPerMeter = (UINT32)(rAcc.Height() / fBmpHeightM + .5);
}
}
diff --git a/vcl/source/gdi/cvtsvm.cxx b/vcl/source/gdi/cvtsvm.cxx
index fce0a042a12f..0f999573ef89 100644
--- a/vcl/source/gdi/cvtsvm.cxx
+++ b/vcl/source/gdi/cvtsvm.cxx
@@ -408,9 +408,7 @@ void SVMConverter::ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf )
rIStm.SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
char aCode[ 5 ];
- MapMode aMapMode;
Size aPrefSz;
- INT32 nActions;
INT16 nSize;
INT16 nVersion;
@@ -420,11 +418,11 @@ void SVMConverter::ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf )
rIStm >> nVersion; // Version
rIStm >> aPrefSz.Width(); // PrefSize.Width()
rIStm >> aPrefSz.Height(); // PrefSize.Height()
- ImplReadMapMode( rIStm, aMapMode ); // MapMode
- rIStm >> nActions; // Action count
// Header-Kennung und Versionsnummer pruefen
- if( ( memcmp( aCode, "SVGDI", sizeof( aCode ) ) != 0 ) || ( nVersion != 200 ) )
+ if( rIStm.GetError()
+ || ( memcmp( aCode, "SVGDI", sizeof( aCode ) ) != 0 )
+ || ( nVersion != 200 ) )
{
rIStm.SetError( SVSTREAM_FILEFORMAT_ERROR );
rIStm.SetNumberFormatInt( nOldFormat );
@@ -432,17 +430,22 @@ void SVMConverter::ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf )
}
else
{
+ MapMode aMapMode;
Polygon aActionPoly;
Rectangle aRect;
Point aPt, aPt1;
Size aSz;
Color aActionColor;
INT32 nTmp, nTmp1, nActionSize;
+ INT32 nActions;
INT16 nType;
sal_uInt32 nUnicodeCommentStreamPos = 0;
INT32 nUnicodeCommentActionNumber = 0;
+ ImplReadMapMode( rIStm, aMapMode ); // MapMode
+ rIStm >> nActions; // Action count
+
rMtf.SetPrefSize( aPrefSz );
rMtf.SetPrefMapMode( aMapMode );
diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx
index 8525d17ea041..6291c011fee1 100644
--- a/vcl/source/gdi/impgraph.cxx
+++ b/vcl/source/gdi/impgraph.cxx
@@ -1504,7 +1504,7 @@ SvStream& operator>>( SvStream& rIStm, ImpGraphic& rImpGraphic )
// read Id
rIStm >> nTmp;
- if( NATIVE_FORMAT_50 == nTmp )
+ if( !rIStm.GetError() && NATIVE_FORMAT_50 == nTmp )
{
Graphic aGraphic;
GfxLink aLink;
diff --git a/vcl/source/helper/canvasbitmap.cxx b/vcl/source/helper/canvasbitmap.cxx
index 7b450f6c0fa9..1e487b141d80 100644
--- a/vcl/source/helper/canvasbitmap.cxx
+++ b/vcl/source/helper/canvasbitmap.cxx
@@ -150,9 +150,6 @@ VclCanvasBitmap::VclCanvasBitmap( const BitmapEx& rBitmap ) :
m_aLayout.ScanLineStride = m_pBmpAcc->GetScanlineSize();
m_aLayout.PlaneStride = 0;
- if( !(m_pBmpAcc->GetScanlineFormat() & BMP_FORMAT_TOP_DOWN) )
- m_aLayout.ScanLineStride *= -1;
-
switch( m_pBmpAcc->GetScanlineFormat() )
{
case BMP_FORMAT_1BIT_MSB_PAL:
@@ -436,8 +433,6 @@ VclCanvasBitmap::VclCanvasBitmap( const BitmapEx& rBitmap ) :
const Size aSize = m_aBitmap.GetSizePixel();
m_aLayout.ScanLineBytes =
m_aLayout.ScanLineStride = (aSize.Width()*m_nBitsPerOutputPixel + 7)/8;
- if( !(m_pBmpAcc->GetScanlineFormat() & BMP_FORMAT_TOP_DOWN) )
- m_aLayout.ScanLineStride *= -1;
}
}
}
@@ -515,8 +510,12 @@ uno::Sequence< sal_Int8 > SAL_CALL VclCanvasBitmap::getData( rendering::IntegerB
bitmapLayout.ScanLineBytes =
bitmapLayout.ScanLineStride= aRequestedBytes.getWidth();
+ sal_Int32 nScanlineStride=bitmapLayout.ScanLineStride;
if( !(m_pBmpAcc->GetScanlineFormat() & BMP_FORMAT_TOP_DOWN) )
- bitmapLayout.ScanLineStride *= -1;
+ {
+ pOutBuf += bitmapLayout.ScanLineStride*(aRequestedBytes.getHeight()-1);
+ nScanlineStride *= -1;
+ }
if( !m_aBmpEx.IsTransparent() )
{
@@ -527,7 +526,7 @@ uno::Sequence< sal_Int8 > SAL_CALL VclCanvasBitmap::getData( rendering::IntegerB
{
Scanline pScan = m_pBmpAcc->GetScanline(y);
rtl_copyMemory(pOutBuf, pScan+aRequestedBytes.Left(), aRequestedBytes.getWidth());
- pOutBuf += bitmapLayout.ScanLineStride;
+ pOutBuf += nScanlineStride;
}
}
else
@@ -568,7 +567,7 @@ uno::Sequence< sal_Int8 > SAL_CALL VclCanvasBitmap::getData( rendering::IntegerB
}
}
- pOutBuf += bitmapLayout.ScanLineStride;
+ pOutBuf += nScanlineStride;
}
}
@@ -870,6 +869,59 @@ uno::Sequence<rendering::ARGBColor> SAL_CALL VclCanvasBitmap::convertToARGB( con
return aRes;
}
+uno::Sequence<rendering::ARGBColor> SAL_CALL VclCanvasBitmap::convertToPARGB( const uno::Sequence< double >& deviceColor ) throw (lang::IllegalArgumentException,uno::RuntimeException)
+{
+ vos::OGuard aGuard( Application::GetSolarMutex() );
+
+ const sal_Size nLen( deviceColor.getLength() );
+ const sal_Int32 nComponentsPerPixel(m_aComponentTags.getLength());
+ ENSURE_ARG_OR_THROW2(nLen%nComponentsPerPixel==0,
+ "number of channels no multiple of pixel element count",
+ static_cast<rendering::XBitmapPalette*>(this), 01);
+
+ uno::Sequence< rendering::ARGBColor > aRes(nLen/nComponentsPerPixel);
+ rendering::ARGBColor* pOut( aRes.getArray() );
+
+ if( m_bPalette )
+ {
+ OSL_ENSURE(m_nIndexIndex != -1,
+ "Invalid color channel indices");
+ ENSURE_OR_THROW(m_pBmpAcc,
+ "Unable to get BitmapAccess");
+
+ for( sal_Size i=0; i<nLen; i+=nComponentsPerPixel )
+ {
+ const BitmapColor aCol = m_pBmpAcc->GetPaletteColor(
+ sal::static_int_cast<USHORT>(deviceColor[i+m_nIndexIndex]));
+
+ // TODO(F3): Convert result to sRGB color space
+ const double nAlpha( m_nAlphaIndex != -1 ? 1.0 - deviceColor[i+m_nAlphaIndex] : 1.0 );
+ *pOut++ = rendering::ARGBColor(nAlpha,
+ nAlpha*toDoubleColor(aCol.GetRed()),
+ nAlpha*toDoubleColor(aCol.GetGreen()),
+ nAlpha*toDoubleColor(aCol.GetBlue()));
+ }
+ }
+ else
+ {
+ OSL_ENSURE(m_nRedIndex != -1 && m_nGreenIndex != -1 && m_nBlueIndex != -1,
+ "Invalid color channel indices");
+
+ for( sal_Size i=0; i<nLen; i+=nComponentsPerPixel )
+ {
+ // TODO(F3): Convert result to sRGB color space
+ const double nAlpha( m_nAlphaIndex != -1 ? 1.0 - deviceColor[i+m_nAlphaIndex] : 1.0 );
+ *pOut++ = rendering::ARGBColor(
+ nAlpha,
+ nAlpha*deviceColor[i+m_nRedIndex],
+ nAlpha*deviceColor[i+m_nGreenIndex],
+ nAlpha*deviceColor[i+m_nBlueIndex]);
+ }
+ }
+
+ return aRes;
+}
+
uno::Sequence< double > SAL_CALL VclCanvasBitmap::convertFromRGB( const uno::Sequence<rendering::RGBColor>& rgbColor ) throw (lang::IllegalArgumentException,uno::RuntimeException)
{
vos::OGuard aGuard( Application::GetSolarMutex() );
@@ -950,6 +1002,48 @@ uno::Sequence< double > SAL_CALL VclCanvasBitmap::convertFromARGB( const uno::Se
return aRes;
}
+uno::Sequence< double > SAL_CALL VclCanvasBitmap::convertFromPARGB( const uno::Sequence<rendering::ARGBColor>& rgbColor ) throw (lang::IllegalArgumentException,uno::RuntimeException)
+{
+ vos::OGuard aGuard( Application::GetSolarMutex() );
+
+ const sal_Size nLen( rgbColor.getLength() );
+ const sal_Int32 nComponentsPerPixel(m_aComponentTags.getLength());
+
+ uno::Sequence< double > aRes(nLen*nComponentsPerPixel);
+ double* pColors=aRes.getArray();
+
+ if( m_bPalette )
+ {
+ for( sal_Size i=0; i<nLen; ++i )
+ {
+ const double nAlpha( rgbColor[i].Alpha );
+ pColors[m_nIndexIndex] = m_pBmpAcc->GetBestPaletteIndex(
+ BitmapColor(toByteColor(rgbColor[i].Red / nAlpha),
+ toByteColor(rgbColor[i].Green / nAlpha),
+ toByteColor(rgbColor[i].Blue / nAlpha)));
+ if( m_nAlphaIndex != -1 )
+ pColors[m_nAlphaIndex] = nAlpha;
+
+ pColors += nComponentsPerPixel;
+ }
+ }
+ else
+ {
+ for( sal_Size i=0; i<nLen; ++i )
+ {
+ const double nAlpha( rgbColor[i].Alpha );
+ pColors[m_nRedIndex] = rgbColor[i].Red / nAlpha;
+ pColors[m_nGreenIndex] = rgbColor[i].Green / nAlpha;
+ pColors[m_nBlueIndex] = rgbColor[i].Blue / nAlpha;
+ if( m_nAlphaIndex != -1 )
+ pColors[m_nAlphaIndex] = nAlpha;
+
+ pColors += nComponentsPerPixel;
+ }
+ }
+ return aRes;
+}
+
sal_Int32 SAL_CALL VclCanvasBitmap::getBitsPerPixel( ) throw (uno::RuntimeException)
{
vos::OGuard aGuard( Application::GetSolarMutex() );
@@ -1163,6 +1257,65 @@ uno::Sequence<rendering::ARGBColor> SAL_CALL VclCanvasBitmap::convertIntegerToAR
return aRes;
}
+uno::Sequence<rendering::ARGBColor> SAL_CALL VclCanvasBitmap::convertIntegerToPARGB( const uno::Sequence< ::sal_Int8 >& deviceColor ) throw (lang::IllegalArgumentException,uno::RuntimeException)
+{
+ vos::OGuard aGuard( Application::GetSolarMutex() );
+
+ const BYTE* pIn( reinterpret_cast<const BYTE*>(deviceColor.getConstArray()) );
+ const sal_Size nLen( deviceColor.getLength() );
+ const sal_Int32 nNumColors((nLen*8 + m_nBitsPerOutputPixel-1)/m_nBitsPerOutputPixel);
+
+ uno::Sequence< rendering::ARGBColor > aRes(nNumColors);
+ rendering::ARGBColor* pOut( aRes.getArray() );
+
+ ENSURE_OR_THROW(m_pBmpAcc,
+ "Unable to get BitmapAccess");
+
+ if( m_aBmpEx.IsTransparent() )
+ {
+ const long nNonAlphaBytes( (m_nBitsPerInputPixel+7)/8 );
+ const sal_Int32 nBytesPerPixel((m_nBitsPerOutputPixel+7)/8);
+ const sal_uInt8 nAlphaFactor( m_aBmpEx.IsAlpha() ? 1 : 255 );
+ for( sal_Size i=0; i<nLen; i+=nBytesPerPixel )
+ {
+ // if palette, index is guaranteed to be 8 bit
+ const BitmapColor aCol =
+ m_bPalette ?
+ m_pBmpAcc->GetPaletteColor(*pIn) :
+ m_pBmpAcc->GetPixelFromData(pIn,0);
+
+ // TODO(F3): Convert result to sRGB color space
+ const double nAlpha( 1.0 - toDoubleColor(nAlphaFactor*pIn[nNonAlphaBytes]) );
+ *pOut++ = rendering::ARGBColor(nAlpha,
+ nAlpha*toDoubleColor(aCol.GetRed()),
+ nAlpha*toDoubleColor(aCol.GetGreen()),
+ nAlpha*toDoubleColor(aCol.GetBlue()));
+ pIn += nBytesPerPixel;
+ }
+ }
+ else
+ {
+ for( sal_Int32 i=0; i<nNumColors; ++i )
+ {
+ const BitmapColor aCol =
+ m_bPalette ?
+ m_pBmpAcc->GetPaletteColor(
+ sal::static_int_cast<USHORT>(
+ m_pBmpAcc->GetPixelFromData(
+ pIn, i ))) :
+ m_pBmpAcc->GetPixelFromData(pIn, i);
+
+ // TODO(F3): Convert result to sRGB color space
+ *pOut++ = rendering::ARGBColor(1.0,
+ toDoubleColor(aCol.GetRed()),
+ toDoubleColor(aCol.GetGreen()),
+ toDoubleColor(aCol.GetBlue()));
+ }
+ }
+
+ return aRes;
+}
+
uno::Sequence< ::sal_Int8 > SAL_CALL VclCanvasBitmap::convertIntegerFromRGB( const uno::Sequence<rendering::RGBColor>& rgbColor ) throw (lang::IllegalArgumentException,uno::RuntimeException)
{
vos::OGuard aGuard( Application::GetSolarMutex() );
@@ -1261,6 +1414,56 @@ uno::Sequence< ::sal_Int8 > SAL_CALL VclCanvasBitmap::convertIntegerFromARGB( co
return aRes;
}
+uno::Sequence< ::sal_Int8 > SAL_CALL VclCanvasBitmap::convertIntegerFromPARGB( const uno::Sequence<rendering::ARGBColor>& rgbColor ) throw (lang::IllegalArgumentException,uno::RuntimeException)
+{
+ vos::OGuard aGuard( Application::GetSolarMutex() );
+
+ const sal_Size nLen( rgbColor.getLength() );
+ const sal_Int32 nNumBytes((nLen*m_nBitsPerOutputPixel+7)/8);
+
+ uno::Sequence< sal_Int8 > aRes(nNumBytes);
+ BYTE* pColors=reinterpret_cast<BYTE*>(aRes.getArray());
+
+ if( m_aBmpEx.IsTransparent() )
+ {
+ const long nNonAlphaBytes( (m_nBitsPerInputPixel+7)/8 );
+ for( sal_Size i=0; i<nLen; ++i )
+ {
+ const double nAlpha( rgbColor[i].Alpha );
+ const BitmapColor aCol(toByteColor(rgbColor[i].Red / nAlpha),
+ toByteColor(rgbColor[i].Green / nAlpha),
+ toByteColor(rgbColor[i].Blue / nAlpha));
+ const BitmapColor aCol2 =
+ m_bPalette ?
+ BitmapColor(
+ sal::static_int_cast<BYTE>(m_pBmpAcc->GetBestPaletteIndex( aCol ))) :
+ aCol;
+
+ m_pBmpAcc->SetPixelOnData(pColors,0,aCol2);
+ pColors += nNonAlphaBytes;
+ *pColors++ = 255 - toByteColor(nAlpha);
+ }
+ }
+ else
+ {
+ for( sal_Size i=0; i<nLen; ++i )
+ {
+ const BitmapColor aCol(toByteColor(rgbColor[i].Red),
+ toByteColor(rgbColor[i].Green),
+ toByteColor(rgbColor[i].Blue));
+ const BitmapColor aCol2 =
+ m_bPalette ?
+ BitmapColor(
+ sal::static_int_cast<BYTE>(m_pBmpAcc->GetBestPaletteIndex( aCol ))) :
+ aCol;
+
+ m_pBmpAcc->SetPixelOnData(pColors,i,aCol2);
+ }
+ }
+
+ return aRes;
+}
+
BitmapEx VclCanvasBitmap::getBitmapEx() const
{
return m_aBmpEx;
diff --git a/vcl/source/helper/canvastools.cxx b/vcl/source/helper/canvastools.cxx
index 3a239d7c3b3c..ca2803fd6009 100644
--- a/vcl/source/helper/canvastools.cxx
+++ b/vcl/source/helper/canvastools.cxx
@@ -250,28 +250,61 @@ namespace vcl
{
// read ARGB color
aARGBColors = rLayout.ColorSpace->convertIntegerToARGB(aPixelData);
- for( sal_Int32 x=0; x<nWidth; ++x )
+
+ if( rWriteAcc->HasPalette() )
{
- const rendering::ARGBColor& rColor=aARGBColors[x];
- rWriteAcc->SetPixel( aRect.Y1, x,
- BitmapColor( toByteColor(rColor.Red),
- toByteColor(rColor.Green),
- toByteColor(rColor.Blue) ));
- rAlphaAcc->SetPixel( aRect.Y1, x,
- BitmapColor( 255 - toByteColor(rColor.Alpha) ));
+ for( sal_Int32 x=0; x<nWidth; ++x )
+ {
+ const rendering::ARGBColor& rColor=aARGBColors[x];
+ rWriteAcc->SetPixel( aRect.Y1, x,
+ rWriteAcc->GetBestPaletteIndex(
+ BitmapColor( toByteColor(rColor.Red),
+ toByteColor(rColor.Green),
+ toByteColor(rColor.Blue))) );
+ rAlphaAcc->SetPixel( aRect.Y1, x,
+ BitmapColor( 255 - toByteColor(rColor.Alpha) ));
+ }
+ }
+ else
+ {
+ for( sal_Int32 x=0; x<nWidth; ++x )
+ {
+ const rendering::ARGBColor& rColor=aARGBColors[x];
+ rWriteAcc->SetPixel( aRect.Y1, x,
+ BitmapColor( toByteColor(rColor.Red),
+ toByteColor(rColor.Green),
+ toByteColor(rColor.Blue) ));
+ rAlphaAcc->SetPixel( aRect.Y1, x,
+ BitmapColor( 255 - toByteColor(rColor.Alpha) ));
+ }
}
}
else
{
// read RGB color
aRGBColors = rLayout.ColorSpace->convertIntegerToRGB(aPixelData);
- for( sal_Int32 x=0; x<nWidth; ++x )
+ if( rWriteAcc->HasPalette() )
+ {
+ for( sal_Int32 x=0; x<nWidth; ++x )
+ {
+ const rendering::RGBColor& rColor=aRGBColors[x];
+ rWriteAcc->SetPixel( aRect.Y1, x,
+ rWriteAcc->GetBestPaletteIndex(
+ BitmapColor( toByteColor(rColor.Red),
+ toByteColor(rColor.Green),
+ toByteColor(rColor.Blue))) );
+ }
+ }
+ else
{
- const rendering::RGBColor& rColor=aRGBColors[x];
- rWriteAcc->SetPixel( aRect.Y1, x,
- BitmapColor( toByteColor(rColor.Red),
- toByteColor(rColor.Green),
- toByteColor(rColor.Blue) ));
+ for( sal_Int32 x=0; x<nWidth; ++x )
+ {
+ const rendering::RGBColor& rColor=aRGBColors[x];
+ rWriteAcc->SetPixel( aRect.Y1, x,
+ BitmapColor( toByteColor(rColor.Red),
+ toByteColor(rColor.Green),
+ toByteColor(rColor.Blue) ));
+ }
}
}
}
@@ -404,7 +437,7 @@ namespace vcl
{ // limit scoped access
ScopedBitmapWriteAccess pWriteAccess( aBitmap.AcquireWriteAccess(),
aBitmap );
- ScopedBitmapWriteAccess pAlphaWriteAccess( aAlpha.AcquireWriteAccess(),
+ ScopedBitmapWriteAccess pAlphaWriteAccess( nAlphaDepth ? aAlpha.AcquireWriteAccess() : NULL,
aAlpha );
ENSURE_OR_THROW(pWriteAccess.get() != NULL,
@@ -652,6 +685,23 @@ namespace vcl
}
return aRes;
}
+ virtual uno::Sequence< rendering::ARGBColor > SAL_CALL convertToPARGB( const uno::Sequence< double >& deviceColor ) throw (lang::IllegalArgumentException, uno::RuntimeException)
+ {
+ const double* pIn( deviceColor.getConstArray() );
+ const sal_Size nLen( deviceColor.getLength() );
+ ENSURE_ARG_OR_THROW2(nLen%4==0,
+ "number of channels no multiple of 4",
+ static_cast<rendering::XColorSpace*>(this), 0);
+
+ uno::Sequence< rendering::ARGBColor > aRes(nLen/4);
+ rendering::ARGBColor* pOut( aRes.getArray() );
+ for( sal_Size i=0; i<nLen; i+=4 )
+ {
+ *pOut++ = rendering::ARGBColor(pIn[3],pIn[3]*pIn[0],pIn[3]*pIn[1],pIn[3]*pIn[2]);
+ pIn += 4;
+ }
+ return aRes;
+ }
virtual uno::Sequence< double > SAL_CALL convertFromRGB( const uno::Sequence< rendering::RGBColor >& rgbColor ) throw (lang::IllegalArgumentException, uno::RuntimeException)
{
const rendering::RGBColor* pIn( rgbColor.getConstArray() );
@@ -686,6 +736,23 @@ namespace vcl
}
return aRes;
}
+ virtual uno::Sequence< double > SAL_CALL convertFromPARGB( const uno::Sequence< rendering::ARGBColor >& rgbColor ) throw (lang::IllegalArgumentException, uno::RuntimeException)
+ {
+ const rendering::ARGBColor* pIn( rgbColor.getConstArray() );
+ const sal_Size nLen( rgbColor.getLength() );
+
+ uno::Sequence< double > aRes(nLen*4);
+ double* pColors=aRes.getArray();
+ for( sal_Size i=0; i<nLen; ++i )
+ {
+ *pColors++ = pIn->Red/pIn->Alpha;
+ *pColors++ = pIn->Green/pIn->Alpha;
+ *pColors++ = pIn->Blue/pIn->Alpha;
+ *pColors++ = pIn->Alpha;
+ ++pIn;
+ }
+ return aRes;
+ }
public:
StandardColorSpace() : m_aComponentTags(4)
diff --git a/vcl/test/canvasbitmaptest.cxx b/vcl/test/canvasbitmaptest.cxx
index 18b677659774..ae0e79f0959f 100644
--- a/vcl/test/canvasbitmaptest.cxx
+++ b/vcl/test/canvasbitmaptest.cxx
@@ -32,6 +32,7 @@
#include "precompiled_vcl.hxx"
// bootstrap stuff
+#include <sal/main.h>
#include <rtl/bootstrap.hxx>
#include <rtl/ref.hxx>
#include <comphelper/processfactory.hxx>
@@ -54,20 +55,45 @@
#include <cppuhelper/compbase3.hxx>
#include <tools/diagnose_ex.h>
+#include <tools/extendapplicationenvironment.hxx>
#include "vcl/svapp.hxx"
#include "vcl/canvastools.hxx"
+#include "vcl/canvasbitmap.hxx"
#include "vcl/dialog.hxx"
#include "vcl/outdev.hxx"
#include "vcl/bmpacc.hxx"
#include "vcl/virdev.hxx"
#include "vcl/bitmapex.hxx"
-#include "canvasbitmap.hxx"
using namespace ::com::sun::star;
using namespace ::vcl::unotools;
+// -----------------------------------------------------------------------
+
+void Main();
+
+// -----------------------------------------------------------------------
+
+SAL_IMPLEMENT_MAIN()
+{
+ tools::extendApplicationEnvironment();
+
+ uno::Reference< lang::XMultiServiceFactory > xMS;
+ xMS = cppu::createRegistryServiceFactory(
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "applicat.rdb" ) ),
+ sal_True );
+
+ InitVCL( xMS );
+ ::Main();
+ DeInitVCL();
+
+ return 0;
+}
+
+// -----------------------------------------------------------------------
+
namespace com { namespace sun { namespace star { namespace rendering
{
@@ -258,28 +284,28 @@ void checkCanvasBitmap( const rtl::Reference<VclCanvasBitmap>& xBmp,
if( nOriginalDepth > 8 )
{
const uno::Sequence<sal_Int8> aComponentTags( xBmp->getComponentTags() );
- uno::Sequence<rendering::ARGBColor> aARGBColors(1);
- uno::Sequence<rendering::RGBColor> aRGBColors(1);
+ uno::Sequence<rendering::ARGBColor> aARGBColor(1);
+ uno::Sequence<rendering::RGBColor> aRGBColor(1);
uno::Sequence<sal_Int8> aPixel3, aPixel4;
const Color aCol(COL_GREEN);
- aARGBColors[0].Red = vcl::unotools::toDoubleColor(aCol.GetRed());
- aARGBColors[0].Green = vcl::unotools::toDoubleColor(aCol.GetGreen());
- aARGBColors[0].Blue = vcl::unotools::toDoubleColor(aCol.GetBlue());
- aARGBColors[0].Alpha = 1.0;
+ aARGBColor[0].Red = vcl::unotools::toDoubleColor(aCol.GetRed());
+ aARGBColor[0].Green = vcl::unotools::toDoubleColor(aCol.GetGreen());
+ aARGBColor[0].Blue = vcl::unotools::toDoubleColor(aCol.GetBlue());
+ aARGBColor[0].Alpha = 1.0;
- aRGBColors[0].Red = vcl::unotools::toDoubleColor(aCol.GetRed());
- aRGBColors[0].Green = vcl::unotools::toDoubleColor(aCol.GetGreen());
- aRGBColors[0].Blue = vcl::unotools::toDoubleColor(aCol.GetBlue());
+ aRGBColor[0].Red = vcl::unotools::toDoubleColor(aCol.GetRed());
+ aRGBColor[0].Green = vcl::unotools::toDoubleColor(aCol.GetGreen());
+ aRGBColor[0].Blue = vcl::unotools::toDoubleColor(aCol.GetBlue());
- aPixel3 = xBmp->convertIntegerFromARGB( aARGBColors );
+ aPixel3 = xBmp->convertIntegerFromARGB( aARGBColor );
aPixel4 = xBmp->getPixel( aLayout, geometry::IntegerPoint2D(5,0) );
test( aPixel3 == aPixel4,
"Green pixel from bitmap matches with manually converted green pixel" );
if( !aContainedBmpEx.IsTransparent() )
{
- aPixel3 = xBmp->convertIntegerFromRGB( aRGBColors );
+ aPixel3 = xBmp->convertIntegerFromRGB( aRGBColor );
test( aPixel3 == aPixel4,
"Green pixel from bitmap matches with manually RGB-converted green pixel" );
}
@@ -409,28 +435,28 @@ void checkBitmapImport( const rtl::Reference<VclCanvasBitmap>& xBmp,
if( nOriginalDepth > 8 )
{
const uno::Sequence<sal_Int8> aComponentTags( xBmp->getComponentTags() );
- uno::Sequence<rendering::ARGBColor> aARGBColors(1);
- uno::Sequence<rendering::RGBColor> aRGBColors(1);
+ uno::Sequence<rendering::ARGBColor> aARGBColor(1);
+ uno::Sequence<rendering::RGBColor> aRGBColor(1);
uno::Sequence<sal_Int8> aPixel3, aPixel4;
const Color aCol(COL_GREEN);
- aARGBColors[0].Red = vcl::unotools::toDoubleColor(aCol.GetRed());
- aARGBColors[0].Green = vcl::unotools::toDoubleColor(aCol.GetGreen());
- aARGBColors[0].Blue = vcl::unotools::toDoubleColor(aCol.GetBlue());
- aARGBColors[0].Alpha = 1.0;
+ aARGBColor[0].Red = vcl::unotools::toDoubleColor(aCol.GetRed());
+ aARGBColor[0].Green = vcl::unotools::toDoubleColor(aCol.GetGreen());
+ aARGBColor[0].Blue = vcl::unotools::toDoubleColor(aCol.GetBlue());
+ aARGBColor[0].Alpha = 1.0;
- aRGBColors[0].Red = vcl::unotools::toDoubleColor(aCol.GetRed());
- aRGBColors[0].Green = vcl::unotools::toDoubleColor(aCol.GetGreen());
- aRGBColors[0].Blue = vcl::unotools::toDoubleColor(aCol.GetBlue());
+ aRGBColor[0].Red = vcl::unotools::toDoubleColor(aCol.GetRed());
+ aRGBColor[0].Green = vcl::unotools::toDoubleColor(aCol.GetGreen());
+ aRGBColor[0].Blue = vcl::unotools::toDoubleColor(aCol.GetBlue());
- aPixel3 = xBmp->convertIntegerFromARGB( aARGBColors );
+ aPixel3 = xBmp->convertIntegerFromARGB( aARGBColor );
aPixel4 = xBmp->getPixel( aLayout, geometry::IntegerPoint2D(5,0) );
test( aPixel3 == aPixel4,
"Green pixel from bitmap matches with manually converted green pixel" );
if( !aContainedBmpEx.IsTransparent() )
{
- aPixel3 = xBmp->convertIntegerFromRGB( aRGBColors );
+ aPixel3 = xBmp->convertIntegerFromRGB( aRGBColor );
test( aPixel3 == aPixel4,
"Green pixel from bitmap matches with manually RGB-converted green pixel" );
}
@@ -631,6 +657,13 @@ private:
return uno::Sequence< rendering::ARGBColor >();
}
+ virtual uno::Sequence< rendering::ARGBColor > SAL_CALL convertToPARGB( const uno::Sequence< double >& ) throw (lang::IllegalArgumentException,
+ uno::RuntimeException)
+ {
+ test(false, "Method not implemented");
+ return uno::Sequence< rendering::ARGBColor >();
+ }
+
virtual uno::Sequence< double > SAL_CALL convertFromRGB( const uno::Sequence< rendering::RGBColor >& ) throw (lang::IllegalArgumentException,
uno::RuntimeException)
{
@@ -645,6 +678,13 @@ private:
return uno::Sequence< double >();
}
+ virtual uno::Sequence< double > SAL_CALL convertFromPARGB( const uno::Sequence< rendering::ARGBColor >& ) throw (lang::IllegalArgumentException,
+ uno::RuntimeException)
+ {
+ test(false, "This method is not expected to be called!");
+ return uno::Sequence< double >();
+ }
+
virtual ::sal_Int32 SAL_CALL getBitsPerPixel( ) throw (uno::RuntimeException)
{
return mnBitsPerPixel;
@@ -660,9 +700,17 @@ private:
return util::Endianness::LITTLE;
}
- virtual uno::Sequence< ::sal_Int8 > SAL_CALL convertIntegerColorSpace( const uno::Sequence< ::sal_Int8 >&,
- const uno::Reference< rendering::XIntegerBitmapColorSpace >& ) throw (lang::IllegalArgumentException,
- uno::RuntimeException)
+ virtual uno::Sequence< double > SAL_CALL convertFromIntegerColorSpace( const uno::Sequence< ::sal_Int8 >& ,
+ const uno::Reference< rendering::XColorSpace >& ) throw (lang::IllegalArgumentException,
+ uno::RuntimeException)
+ {
+ test(false, "Method not implemented");
+ return uno::Sequence< double >();
+ }
+
+ virtual uno::Sequence< ::sal_Int8 > SAL_CALL convertToIntegerColorSpace( const uno::Sequence< ::sal_Int8 >& ,
+ const uno::Reference< rendering::XIntegerBitmapColorSpace >& ) throw (lang::IllegalArgumentException,
+ uno::RuntimeException)
{
test(false, "Method not implemented");
return uno::Sequence< sal_Int8 >();
@@ -722,6 +770,44 @@ private:
return aRes;
}
+ virtual uno::Sequence< rendering::ARGBColor > SAL_CALL convertIntegerToPARGB( const uno::Sequence< ::sal_Int8 >& deviceColor ) throw (lang::IllegalArgumentException,
+ uno::RuntimeException)
+ {
+ const sal_Size nLen( deviceColor.getLength() );
+ const sal_Int32 nBytesPerPixel(mnBitsPerPixel == 8 ? 1 : 4);
+ test(nLen%nBytesPerPixel==0,
+ "number of channels no multiple of pixel element count");
+
+ uno::Sequence< rendering::ARGBColor > aRes( nLen / nBytesPerPixel );
+ rendering::ARGBColor* pOut( aRes.getArray() );
+
+ if( getPalette().is() )
+ {
+ for( sal_Size i=0; i<nLen; ++i )
+ {
+ *pOut++ = rendering::ARGBColor(
+ 1.0,
+ vcl::unotools::toDoubleColor(deviceColor[i]),
+ vcl::unotools::toDoubleColor(deviceColor[i]),
+ vcl::unotools::toDoubleColor(deviceColor[i]));
+ }
+ }
+ else
+ {
+ for( sal_Size i=0; i<nLen; i+=4 )
+ {
+ const double fAlpha=vcl::unotools::toDoubleColor(deviceColor[i+3]);
+ *pOut++ = rendering::ARGBColor(
+ fAlpha,
+ fAlpha*vcl::unotools::toDoubleColor(deviceColor[i+0]),
+ fAlpha*vcl::unotools::toDoubleColor(deviceColor[i+1]),
+ fAlpha*vcl::unotools::toDoubleColor(deviceColor[i+2]));
+ }
+ }
+
+ return aRes;
+ }
+
virtual uno::Sequence< ::sal_Int8 > SAL_CALL convertIntegerFromRGB( const uno::Sequence< rendering::RGBColor >& ) throw (lang::IllegalArgumentException,
uno::RuntimeException)
{
@@ -736,6 +822,13 @@ private:
return uno::Sequence< sal_Int8 >();
}
+ virtual uno::Sequence< ::sal_Int8 > SAL_CALL convertIntegerFromPARGB( const uno::Sequence< rendering::ARGBColor >& ) throw (lang::IllegalArgumentException,
+ uno::RuntimeException)
+ {
+ test(false, "Method not implemented");
+ return uno::Sequence< sal_Int8 >();
+ }
+
public:
TestBitmap( const geometry::IntegerSize2D& rSize, bool bPalette ) :
maSize(rSize),
@@ -784,14 +877,14 @@ public:
void TestWindow::Paint( const Rectangle& )
{
- static sal_Int8 lcl_depths[]={1,4,8,16,24,32};
+ static sal_Int8 lcl_depths[]={1,4,8,16,24};
try
{
// Testing VclCanvasBitmap wrapper
// ===============================
- for( int i=0; i<sizeof(lcl_depths)/sizeof(*lcl_depths); ++i )
+ for( unsigned int i=0; i<sizeof(lcl_depths)/sizeof(*lcl_depths); ++i )
{
const sal_Int8 nDepth( lcl_depths[i] );
Bitmap aBitmap(Size(200,200),nDepth);
@@ -801,8 +894,8 @@ void TestWindow::Paint( const Rectangle& )
aBitmap);
if( pAcc.get() )
{
- BitmapColor aBlack;
- BitmapColor aWhite;
+ BitmapColor aBlack(0);
+ BitmapColor aWhite(0);
if( pAcc->HasPalette() )
{
aBlack.SetIndex( sal::static_int_cast<BYTE>(pAcc->GetBestPaletteIndex(BitmapColor(0,0,0))) );
@@ -943,73 +1036,14 @@ void TestWindow::Paint( const Rectangle& )
exit(2);
}
-USHORT TestApp::Exception( USHORT nError )
-{
- switch( nError & EXC_MAJORTYPE )
- {
- case EXC_RSCNOTLOADED:
- Abort( String::CreateFromAscii(
- "Error: could not load language resources.\nPlease check your installation.\n" ) );
- break;
- }
- return 0;
-}
+} // namespace
-void TestApp::Main()
+void Main()
{
- bool bHelp = false;
-
- for( USHORT i = 0; i < GetCommandLineParamCount(); i++ )
- {
- ::rtl::OUString aParam = GetCommandLineParam( i );
-
- if( aParam.equalsAscii( "--help" ) ||
- aParam.equalsAscii( "-h" ) )
- bHelp = true;
- }
-
- if( bHelp )
- {
- printf( "outdevgrind - Profile OutputDevice\n" );
- return;
- }
-
- //-------------------------------------------------
- // create the global service-manager
- //-------------------------------------------------
- uno::Reference< lang::XMultiServiceFactory > xFactory;
- try
- {
- uno::Reference< uno::XComponentContext > xCtx = ::cppu::defaultBootstrap_InitialComponentContext();
- xFactory = uno::Reference< lang::XMultiServiceFactory >( xCtx->getServiceManager(),
- uno::UNO_QUERY );
- if( xFactory.is() )
- ::comphelper::setProcessServiceFactory( xFactory );
- }
- catch( uno::Exception& )
- {
- }
+ TestWindow aWindow;
+ aWindow.Execute();
+ aWindow.SetText( XubString( RTL_CONSTASCII_USTRINGPARAM( "VCL - canvasbitmaptest" ) ) );
- if( !xFactory.is() )
- {
- fprintf( stderr,
- "Could not bootstrap UNO, installation must be in disorder. Exiting.\n" );
- exit( 1 );
- }
-
- // Create UCB.
- uno::Sequence< uno::Any > aArgs( 2 );
- aArgs[ 0 ] <<= rtl::OUString::createFromAscii( UCB_CONFIGURATION_KEY1_LOCAL );
- aArgs[ 1 ] <<= rtl::OUString::createFromAscii( UCB_CONFIGURATION_KEY2_OFFICE );
- ::ucbhelper::ContentBroker::initialize( xFactory, aArgs );
-
- TestWindow pWindow;
- pWindow.Execute();
-
- // clean up UCB
- ::ucbhelper::ContentBroker::deinitialize();
+ Application::Execute();
}
-} // namespace
-
-TestApp aTestApp;
diff --git a/vcl/test/dndtest.cxx b/vcl/test/dndtest.cxx
index bd912fcdf444..2d426acf84b5 100755
--- a/vcl/test/dndtest.cxx
+++ b/vcl/test/dndtest.cxx
@@ -138,7 +138,7 @@ class StringTransferable : public ::cppu::WeakImplHelper1< XTransferable >
Sequence< DataFlavor > m_aFlavorList;
public:
- StringTransferable( const OUString& rString ) : m_aFlavorList( 1 ), m_aData( rString )
+ StringTransferable( const OUString& rString ) : m_aData( rString ), m_aFlavorList( 1 )
{
DataFlavor df;
@@ -297,7 +297,7 @@ void MyWin::Resize()
void SAL_CALL MyDragAndDropListener::dragGestureRecognized( const DragGestureEvent& dge ) throw(RuntimeException)
{
- printf( "XDragGestureListener::dragGestureRecognized called ( Window: %X, %d, %d ).\n", m_pWindow, dge.DragOriginX, dge.DragOriginY );
+ printf( "XDragGestureListener::dragGestureRecognized called ( Window: %p, %"SAL_PRIdINT32", %"SAL_PRIdINT32" ).\n", m_pWindow, dge.DragOriginX, dge.DragOriginY );
Reference< XDragSource > xDragSource( dge.DragSource, UNO_QUERY );
xDragSource->startDrag( dge, -1, 0, 0, new StringTransferable( OUString::createFromAscii( "TestString" ) ), this );
@@ -308,7 +308,7 @@ void SAL_CALL MyDragAndDropListener::dragGestureRecognized( const DragGestureEve
void SAL_CALL MyDragAndDropListener::drop( const DropTargetDropEvent& dtde ) throw(RuntimeException)
{
- printf( "XDropTargetListener::drop called ( Window: %X, %d, %d ).\n", m_pWindow, dtde.LocationX, dtde.LocationY );
+ printf( "XDropTargetListener::drop called ( Window: %p, %"SAL_PRIdINT32", %"SAL_PRIdINT32" ).\n", m_pWindow, dtde.LocationX, dtde.LocationY );
dtde.Context->dropComplete( sal_True );
}
@@ -317,7 +317,7 @@ void SAL_CALL MyDragAndDropListener::drop( const DropTargetDropEvent& dtde ) thr
void SAL_CALL MyDragAndDropListener::dragEnter( const DropTargetDragEnterEvent& dtdee ) throw(RuntimeException)
{
- printf( "XDropTargetListener::dragEnter called ( Window: %X, %d, %d ).\n", m_pWindow, dtdee.LocationX, dtdee.LocationY );
+ printf( "XDropTargetListener::dragEnter called ( Window: %p, %"SAL_PRIdINT32", %"SAL_PRIdINT32" ).\n", m_pWindow, dtdee.LocationX, dtdee.LocationY );
dtdee.Context->acceptDrag( dtdee.DropAction );
}
@@ -325,14 +325,14 @@ void SAL_CALL MyDragAndDropListener::dragEnter( const DropTargetDragEnterEvent&
void SAL_CALL MyDragAndDropListener::dragExit( const DropTargetEvent& ) throw(RuntimeException)
{
- printf( "XDropTargetListener::dragExit called ( Window: %X ).\n", m_pWindow );
+ printf( "XDropTargetListener::dragExit called ( Window: %p ).\n", m_pWindow );
}
// -----------------------------------------------------------------------
void SAL_CALL MyDragAndDropListener::dragOver( const DropTargetDragEvent& dtde ) throw(RuntimeException)
{
- printf( "XDropTargetListener::dragOver called ( Window: %X, %d, %d ).\n", m_pWindow, dtde.LocationX, dtde.LocationY );
+ printf( "XDropTargetListener::dragOver called ( Window: %p, %"SAL_PRIdINT32", %"SAL_PRIdINT32" ).\n", m_pWindow, dtde.LocationX, dtde.LocationY );
dtde.Context->acceptDrag( dtde.DropAction );
}
@@ -340,7 +340,7 @@ void SAL_CALL MyDragAndDropListener::dragOver( const DropTargetDragEvent& dtde )
void SAL_CALL MyDragAndDropListener::dropActionChanged( const DropTargetDragEvent& dtde ) throw(RuntimeException)
{
- printf( "XDropTargetListener::dropActionChanged called ( Window: %X, %d, %d ).\n", m_pWindow, dtde.LocationX, dtde.LocationY );
+ printf( "XDropTargetListener::dropActionChanged called ( Window: %p, %"SAL_PRIdINT32", %"SAL_PRIdINT32" ).\n", m_pWindow, dtde.LocationX, dtde.LocationY );
dtde.Context->acceptDrag( dtde.DropAction );
}
@@ -348,42 +348,42 @@ void SAL_CALL MyDragAndDropListener::dropActionChanged( const DropTargetDragEven
void SAL_CALL MyDragAndDropListener::dragDropEnd( const DragSourceDropEvent& dsde ) throw(RuntimeException)
{
- printf( "XDragSourceListener::dropDropEnd called ( Window: %X, %s ).\n", m_pWindow, dsde.DropSuccess ? "sucess" : "failed" );
+ printf( "XDragSourceListener::dropDropEnd called ( Window: %p, %s ).\n", m_pWindow, dsde.DropSuccess ? "sucess" : "failed" );
}
// -----------------------------------------------------------------------
void SAL_CALL MyDragAndDropListener::dragEnter( const DragSourceDragEvent& ) throw(RuntimeException)
{
- printf( "XDragSourceListener::dragEnter called ( Window: %X ).\n", m_pWindow );
+ printf( "XDragSourceListener::dragEnter called ( Window: %p ).\n", m_pWindow );
}
// -----------------------------------------------------------------------
void SAL_CALL MyDragAndDropListener::dragExit( const DragSourceEvent& ) throw(RuntimeException)
{
- printf( "XDragSourceListener::dragExit called ( Window: %X ).\n", m_pWindow );
+ printf( "XDragSourceListener::dragExit called ( Window: %p ).\n", m_pWindow );
}
// -----------------------------------------------------------------------
void SAL_CALL MyDragAndDropListener::dragOver( const DragSourceDragEvent& ) throw(RuntimeException)
{
- printf( "XDragSourceListener::dragOver called ( Window: %X ).\n", m_pWindow );
+ printf( "XDragSourceListener::dragOver called ( Window: %p ).\n", m_pWindow );
}
// -----------------------------------------------------------------------
void SAL_CALL MyDragAndDropListener::dropActionChanged( const DragSourceDragEvent& ) throw(RuntimeException)
{
- printf( "XDragSourceListener::dropActionChanged called ( Window: %X ).\n", m_pWindow );
+ printf( "XDragSourceListener::dropActionChanged called ( Window: %p ).\n", m_pWindow );
}
// -----------------------------------------------------------------------
void SAL_CALL MyDragAndDropListener::disposing( const EventObject& ) throw(RuntimeException)
{
- printf( "XEventListener::disposing called ( Window: %X ).\n", m_pWindow );
+ printf( "XEventListener::disposing called ( Window: %p ).\n", m_pWindow );
}
// -----------------------------------------------------------------------
diff --git a/vcl/test/makefile.mk b/vcl/test/makefile.mk
index 45f36555c302..4f10be112d2c 100644
--- a/vcl/test/makefile.mk
+++ b/vcl/test/makefile.mk
@@ -46,13 +46,12 @@ TARGETTYPE=GUI
# --- Files --------------------------------------------------------
-OBJFILES= \
+APP1OBJS= \
$(OBJ)$/dndtest.obj
APP1NOSAL= TRUE
APP1TARGET= $(TARGET)
-APP1OBJS= $(OBJFILES) $(OBJ)$/salmain.obj
APP1STDLIBS= $(CPPULIB) \
$(CPPUHELPERLIB) \
$(TOOLSLIB) \
@@ -68,12 +67,6 @@ APP2TARGET= canvasbitmaptest
APP2OBJS= \
$(OBJ)$/canvasbitmaptest.obj
-.IF "$(GUI)"!="UNX"
- APP2OBJS += $(OBJ)$/salmain.obj
-.ELSE
- APP2OBJS += $(SLO)$/salmain.obj
-.ENDIF
-
APP2NOSAL= TRUE
APP2STDLIBS=$(TOOLSLIB) \
$(COMPHELPERLIB) \
diff --git a/vcl/unx/source/gdi/salbmp.cxx b/vcl/unx/source/gdi/salbmp.cxx
index 07fffb6b2218..f70f445ed28c 100644
--- a/vcl/unx/source/gdi/salbmp.cxx
+++ b/vcl/unx/source/gdi/salbmp.cxx
@@ -141,9 +141,15 @@ BitmapBuffer* X11SalBitmap::ImplCreateDIB( const Size& rSize, USHORT nBitCount,
case( 4 ): pDIB->mnFormat |= BMP_FORMAT_4BIT_MSN_PAL; break;
case( 8 ): pDIB->mnFormat |= BMP_FORMAT_8BIT_PAL; break;
#ifdef OSL_BIGENDIAN
- case(16 ) : pDIB->mnFormat|= BMP_FORMAT_16BIT_TC_MSB_MASK; break;
+ case(16 ):
+ pDIB->mnFormat|= BMP_FORMAT_16BIT_TC_MSB_MASK;
+ pDIB->maColorMask = ColorMask( 0xf800, 0x07e0, 0x001f );
+ break;
#else
- case(16 ) : pDIB->mnFormat|= BMP_FORMAT_16BIT_TC_LSB_MASK; break;
+ case(16 ):
+ pDIB->mnFormat|= BMP_FORMAT_16BIT_TC_LSB_MASK;
+ pDIB->maColorMask = ColorMask( 0xf800, 0x07e0, 0x001f );
+ break;
#endif
default:
nBitCount = 24;
@@ -251,7 +257,7 @@ BitmapBuffer* X11SalBitmap::ImplCreateDIB( Drawable aDrawable,
case( 16 ):
{
nDstFormat |= BMP_FORMAT_24BIT_TC_BGR;
- aSrcBuf.maColorMask = ColorMask( pImage->red_mask, pImage->green_mask, pImage->blue_mask );
+ aSrcBuf.maColorMask = ColorMask( pImage->red_mask, pImage->green_mask, pImage->blue_mask );
if( LSBFirst == pImage->byte_order )
{