1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_vcl.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir // bootstrap stuff 32*cdf0e10cSrcweir #include <sal/main.h> 33*cdf0e10cSrcweir #include <rtl/bootstrap.hxx> 34*cdf0e10cSrcweir #include <rtl/ref.hxx> 35*cdf0e10cSrcweir #include <comphelper/processfactory.hxx> 36*cdf0e10cSrcweir #include <comphelper/regpathhelper.hxx> 37*cdf0e10cSrcweir #include <cppuhelper/servicefactory.hxx> 38*cdf0e10cSrcweir #include <cppuhelper/bootstrap.hxx> 39*cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp> 40*cdf0e10cSrcweir #include <com/sun/star/lang/XInitialization.hpp> 41*cdf0e10cSrcweir #include <com/sun/star/registry/XSimpleRegistry.hpp> 42*cdf0e10cSrcweir #include <com/sun/star/util/Endianness.hpp> 43*cdf0e10cSrcweir #include <com/sun/star/rendering/ColorComponentTag.hpp> 44*cdf0e10cSrcweir #include <com/sun/star/rendering/ColorSpaceType.hpp> 45*cdf0e10cSrcweir #include <com/sun/star/rendering/RenderingIntent.hpp> 46*cdf0e10cSrcweir #include <com/sun/star/rendering/XIntegerReadOnlyBitmap.hpp> 47*cdf0e10cSrcweir #include <com/sun/star/rendering/XIntegerBitmapColorSpace.hpp> 48*cdf0e10cSrcweir #include <com/sun/star/rendering/XBitmapPalette.hpp> 49*cdf0e10cSrcweir 50*cdf0e10cSrcweir #include <ucbhelper/contentbroker.hxx> 51*cdf0e10cSrcweir #include <ucbhelper/configurationkeys.hxx> 52*cdf0e10cSrcweir #include <cppuhelper/compbase3.hxx> 53*cdf0e10cSrcweir 54*cdf0e10cSrcweir #include <tools/diagnose_ex.h> 55*cdf0e10cSrcweir #include <tools/extendapplicationenvironment.hxx> 56*cdf0e10cSrcweir 57*cdf0e10cSrcweir #include "vcl/svapp.hxx" 58*cdf0e10cSrcweir #include "vcl/canvastools.hxx" 59*cdf0e10cSrcweir #include "vcl/canvasbitmap.hxx" 60*cdf0e10cSrcweir #include "vcl/dialog.hxx" 61*cdf0e10cSrcweir #include "vcl/outdev.hxx" 62*cdf0e10cSrcweir #include "vcl/bmpacc.hxx" 63*cdf0e10cSrcweir #include "vcl/virdev.hxx" 64*cdf0e10cSrcweir #include "vcl/bitmapex.hxx" 65*cdf0e10cSrcweir 66*cdf0e10cSrcweir 67*cdf0e10cSrcweir using namespace ::com::sun::star; 68*cdf0e10cSrcweir using namespace ::vcl::unotools; 69*cdf0e10cSrcweir 70*cdf0e10cSrcweir // ----------------------------------------------------------------------- 71*cdf0e10cSrcweir 72*cdf0e10cSrcweir void Main(); 73*cdf0e10cSrcweir 74*cdf0e10cSrcweir // ----------------------------------------------------------------------- 75*cdf0e10cSrcweir 76*cdf0e10cSrcweir SAL_IMPLEMENT_MAIN() 77*cdf0e10cSrcweir { 78*cdf0e10cSrcweir tools::extendApplicationEnvironment(); 79*cdf0e10cSrcweir 80*cdf0e10cSrcweir uno::Reference< lang::XMultiServiceFactory > xMS; 81*cdf0e10cSrcweir xMS = cppu::createRegistryServiceFactory( 82*cdf0e10cSrcweir rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "applicat.rdb" ) ), 83*cdf0e10cSrcweir sal_True ); 84*cdf0e10cSrcweir 85*cdf0e10cSrcweir InitVCL( xMS ); 86*cdf0e10cSrcweir ::Main(); 87*cdf0e10cSrcweir DeInitVCL(); 88*cdf0e10cSrcweir 89*cdf0e10cSrcweir return 0; 90*cdf0e10cSrcweir } 91*cdf0e10cSrcweir 92*cdf0e10cSrcweir // ----------------------------------------------------------------------- 93*cdf0e10cSrcweir 94*cdf0e10cSrcweir namespace com { namespace sun { namespace star { namespace rendering 95*cdf0e10cSrcweir { 96*cdf0e10cSrcweir 97*cdf0e10cSrcweir bool operator==( const RGBColor& rLHS, const ARGBColor& rRHS ) 98*cdf0e10cSrcweir { 99*cdf0e10cSrcweir return rLHS.Red == rRHS.Red && rLHS.Green == rRHS.Green && rLHS.Blue == rRHS.Blue; 100*cdf0e10cSrcweir } 101*cdf0e10cSrcweir bool operator==( const ARGBColor& rLHS, const RGBColor& rRHS ) 102*cdf0e10cSrcweir { 103*cdf0e10cSrcweir return rLHS.Red == rRHS.Red && rLHS.Green == rRHS.Green && rLHS.Blue == rRHS.Blue; 104*cdf0e10cSrcweir } 105*cdf0e10cSrcweir 106*cdf0e10cSrcweir } } } } 107*cdf0e10cSrcweir 108*cdf0e10cSrcweir //---------------------------------------------------------------------------------- 109*cdf0e10cSrcweir 110*cdf0e10cSrcweir namespace 111*cdf0e10cSrcweir { 112*cdf0e10cSrcweir 113*cdf0e10cSrcweir class TestApp : public Application 114*cdf0e10cSrcweir { 115*cdf0e10cSrcweir public: 116*cdf0e10cSrcweir virtual void Main(); 117*cdf0e10cSrcweir virtual USHORT Exception( USHORT nError ); 118*cdf0e10cSrcweir }; 119*cdf0e10cSrcweir 120*cdf0e10cSrcweir class TestWindow : public Dialog 121*cdf0e10cSrcweir { 122*cdf0e10cSrcweir public: 123*cdf0e10cSrcweir TestWindow() : Dialog( (Window *) NULL ) 124*cdf0e10cSrcweir { 125*cdf0e10cSrcweir SetText( rtl::OUString::createFromAscii( "CanvasBitmap test harness" ) ); 126*cdf0e10cSrcweir SetSizePixel( Size( 1024, 1024 ) ); 127*cdf0e10cSrcweir EnablePaint( true ); 128*cdf0e10cSrcweir Show(); 129*cdf0e10cSrcweir } 130*cdf0e10cSrcweir 131*cdf0e10cSrcweir virtual ~TestWindow() {} 132*cdf0e10cSrcweir virtual void Paint( const Rectangle& rRect ); 133*cdf0e10cSrcweir }; 134*cdf0e10cSrcweir 135*cdf0e10cSrcweir //---------------------------------------------------------------------------------- 136*cdf0e10cSrcweir 137*cdf0e10cSrcweir static bool g_failure=false; 138*cdf0e10cSrcweir 139*cdf0e10cSrcweir void test( bool bResult, const char* msg ) 140*cdf0e10cSrcweir { 141*cdf0e10cSrcweir if( bResult ) 142*cdf0e10cSrcweir { 143*cdf0e10cSrcweir OSL_TRACE("Testing: %s - PASSED", msg); 144*cdf0e10cSrcweir } 145*cdf0e10cSrcweir else 146*cdf0e10cSrcweir { 147*cdf0e10cSrcweir g_failure = true; 148*cdf0e10cSrcweir OSL_TRACE("Testing: %s - FAILED", msg); 149*cdf0e10cSrcweir } 150*cdf0e10cSrcweir } 151*cdf0e10cSrcweir 152*cdf0e10cSrcweir //---------------------------------------------------------------------------------- 153*cdf0e10cSrcweir 154*cdf0e10cSrcweir bool rangeCheck( const rendering::RGBColor& rColor ) 155*cdf0e10cSrcweir { 156*cdf0e10cSrcweir return rColor.Red < 0.0 || rColor.Red > 1.0 || 157*cdf0e10cSrcweir rColor.Green < 0.0 || rColor.Green > 1.0 || 158*cdf0e10cSrcweir rColor.Blue < 0.0 || rColor.Blue > 1.0; 159*cdf0e10cSrcweir } 160*cdf0e10cSrcweir 161*cdf0e10cSrcweir //---------------------------------------------------------------------------------- 162*cdf0e10cSrcweir 163*cdf0e10cSrcweir void checkCanvasBitmap( const rtl::Reference<VclCanvasBitmap>& xBmp, 164*cdf0e10cSrcweir const char* msg, 165*cdf0e10cSrcweir int nOriginalDepth ) 166*cdf0e10cSrcweir { 167*cdf0e10cSrcweir OSL_TRACE("-------------------------"); 168*cdf0e10cSrcweir OSL_TRACE("Testing %s, with depth %d", msg, nOriginalDepth); 169*cdf0e10cSrcweir 170*cdf0e10cSrcweir BitmapEx aContainedBmpEx( xBmp->getBitmapEx() ); 171*cdf0e10cSrcweir Bitmap aContainedBmp( aContainedBmpEx.GetBitmap() ); 172*cdf0e10cSrcweir int nDepth = nOriginalDepth; 173*cdf0e10cSrcweir 174*cdf0e10cSrcweir { 175*cdf0e10cSrcweir ScopedBitmapReadAccess pAcc( aContainedBmp.AcquireReadAccess(), 176*cdf0e10cSrcweir aContainedBmp ); 177*cdf0e10cSrcweir nDepth = pAcc->GetBitCount(); 178*cdf0e10cSrcweir } 179*cdf0e10cSrcweir 180*cdf0e10cSrcweir test( aContainedBmp.GetSizePixel() == Size(200,200), 181*cdf0e10cSrcweir "Original bitmap size" ); 182*cdf0e10cSrcweir 183*cdf0e10cSrcweir test( xBmp->getSize().Width == 200 && xBmp->getSize().Height == 200, 184*cdf0e10cSrcweir "Original bitmap size via API" ); 185*cdf0e10cSrcweir 186*cdf0e10cSrcweir test( xBmp->hasAlpha() == aContainedBmpEx.IsTransparent(), 187*cdf0e10cSrcweir "Correct alpha state" ); 188*cdf0e10cSrcweir 189*cdf0e10cSrcweir test( xBmp->getScaledBitmap( geometry::RealSize2D(500,500), sal_False ).is(), 190*cdf0e10cSrcweir "getScaledBitmap()" ); 191*cdf0e10cSrcweir 192*cdf0e10cSrcweir rendering::IntegerBitmapLayout aLayout; 193*cdf0e10cSrcweir uno::Sequence<sal_Int8> aPixelData = xBmp->getData(aLayout, geometry::IntegerRectangle2D(0,0,1,1)); 194*cdf0e10cSrcweir 195*cdf0e10cSrcweir const sal_Int32 nExpectedBitsPerPixel( 196*cdf0e10cSrcweir aContainedBmpEx.IsTransparent() ? std::max(8,nDepth)+8 : nDepth); 197*cdf0e10cSrcweir test( aLayout.ScanLines == 1, 198*cdf0e10cSrcweir "# scanlines" ); 199*cdf0e10cSrcweir test( aLayout.ScanLineBytes == (nExpectedBitsPerPixel+7)/8, 200*cdf0e10cSrcweir "# scanline bytes" ); 201*cdf0e10cSrcweir test( aLayout.ScanLineStride == (nExpectedBitsPerPixel+7)/8 || 202*cdf0e10cSrcweir aLayout.ScanLineStride == -(nExpectedBitsPerPixel+7)/8, 203*cdf0e10cSrcweir "# scanline stride" ); 204*cdf0e10cSrcweir test( aLayout.PlaneStride == 0, 205*cdf0e10cSrcweir "# plane stride" ); 206*cdf0e10cSrcweir 207*cdf0e10cSrcweir test( aLayout.ColorSpace.is(), 208*cdf0e10cSrcweir "Color space there" ); 209*cdf0e10cSrcweir 210*cdf0e10cSrcweir test( aLayout.Palette.is() == (nDepth <= 8), 211*cdf0e10cSrcweir "Palette existance conforms to bitmap" ); 212*cdf0e10cSrcweir 213*cdf0e10cSrcweir uno::Sequence<sal_Int8> aPixelData2 = xBmp->getPixel( aLayout, geometry::IntegerPoint2D(0,0) ); 214*cdf0e10cSrcweir 215*cdf0e10cSrcweir test( aPixelData2.getLength() == aPixelData.getLength(), 216*cdf0e10cSrcweir "getData and getPixel return same amount of data" ); 217*cdf0e10cSrcweir 218*cdf0e10cSrcweir aPixelData = xBmp->getData(aLayout, geometry::IntegerRectangle2D(0,0,200,1)); 219*cdf0e10cSrcweir test( aLayout.ScanLines == 1, 220*cdf0e10cSrcweir "# scanlines" ); 221*cdf0e10cSrcweir test( aLayout.ScanLineBytes == (200*nExpectedBitsPerPixel+7)/8, 222*cdf0e10cSrcweir "# scanline bytes" ); 223*cdf0e10cSrcweir test( aLayout.ScanLineStride == (200*nExpectedBitsPerPixel+7)/8 || 224*cdf0e10cSrcweir aLayout.ScanLineStride == -(200*nExpectedBitsPerPixel+7)/8, 225*cdf0e10cSrcweir "# scanline stride" ); 226*cdf0e10cSrcweir 227*cdf0e10cSrcweir uno::Sequence< rendering::RGBColor > aRGBColors = xBmp->convertIntegerToRGB( aPixelData ); 228*cdf0e10cSrcweir uno::Sequence< rendering::ARGBColor > aARGBColors = xBmp->convertIntegerToARGB( aPixelData ); 229*cdf0e10cSrcweir 230*cdf0e10cSrcweir const rendering::RGBColor* pRGBStart ( aRGBColors.getConstArray() ); 231*cdf0e10cSrcweir const rendering::RGBColor* pRGBEnd ( aRGBColors.getConstArray()+aRGBColors.getLength() ); 232*cdf0e10cSrcweir const rendering::ARGBColor* pARGBStart( aARGBColors.getConstArray() ); 233*cdf0e10cSrcweir std::pair<const rendering::RGBColor*, 234*cdf0e10cSrcweir const rendering::ARGBColor*> aRes = std::mismatch( pRGBStart, pRGBEnd, pARGBStart ); 235*cdf0e10cSrcweir test( aRes.first == pRGBEnd, 236*cdf0e10cSrcweir "argb and rgb colors are equal" ); 237*cdf0e10cSrcweir 238*cdf0e10cSrcweir test( std::find_if(pRGBStart,pRGBEnd,&rangeCheck) == pRGBEnd, 239*cdf0e10cSrcweir "rgb colors are within [0,1] range" ); 240*cdf0e10cSrcweir 241*cdf0e10cSrcweir test( pRGBStart[0].Red == 1.0 && pRGBStart[0].Green == 1.0 && pRGBStart[0].Blue == 1.0, 242*cdf0e10cSrcweir "First pixel is white" ); 243*cdf0e10cSrcweir test( pARGBStart[1].Alpha == 1.0, 244*cdf0e10cSrcweir "Second pixel is opaque" ); 245*cdf0e10cSrcweir if( aContainedBmpEx.IsTransparent() ) 246*cdf0e10cSrcweir { 247*cdf0e10cSrcweir test( pARGBStart[0].Alpha == 0.0, 248*cdf0e10cSrcweir "First pixel is fully transparent" ); 249*cdf0e10cSrcweir } 250*cdf0e10cSrcweir 251*cdf0e10cSrcweir test( pRGBStart[1].Red == 0.0 && pRGBStart[1].Green == 0.0 && pRGBStart[1].Blue == 0.0, 252*cdf0e10cSrcweir "Second pixel is black" ); 253*cdf0e10cSrcweir 254*cdf0e10cSrcweir if( nOriginalDepth > 8 ) 255*cdf0e10cSrcweir { 256*cdf0e10cSrcweir const Color aCol(COL_GREEN); 257*cdf0e10cSrcweir test( pRGBStart[5].Red == vcl::unotools::toDoubleColor(aCol.GetRed()) && 258*cdf0e10cSrcweir pRGBStart[5].Green == vcl::unotools::toDoubleColor(aCol.GetGreen()) && 259*cdf0e10cSrcweir pRGBStart[5].Blue == vcl::unotools::toDoubleColor(aCol.GetBlue()), 260*cdf0e10cSrcweir "Sixth pixel is green" ); 261*cdf0e10cSrcweir } 262*cdf0e10cSrcweir else if( nDepth <= 8 ) 263*cdf0e10cSrcweir { 264*cdf0e10cSrcweir uno::Reference<rendering::XBitmapPalette> xPal = xBmp->getPalette(); 265*cdf0e10cSrcweir test( xPal.is(), 266*cdf0e10cSrcweir "8bit or less: needs palette" ); 267*cdf0e10cSrcweir test( xPal->getNumberOfEntries() == 1L << nOriginalDepth, 268*cdf0e10cSrcweir "Palette has correct entry count" ); 269*cdf0e10cSrcweir uno::Sequence<double> aIndex; 270*cdf0e10cSrcweir test( xPal->setIndex(aIndex,sal_True,0) == sal_False, 271*cdf0e10cSrcweir "Palette is read-only" ); 272*cdf0e10cSrcweir test( xPal->getIndex(aIndex,0), 273*cdf0e10cSrcweir "Palette entry 0 is opaque" ); 274*cdf0e10cSrcweir test( xPal->getColorSpace().is(), 275*cdf0e10cSrcweir "Palette has a valid color space" ); 276*cdf0e10cSrcweir } 277*cdf0e10cSrcweir 278*cdf0e10cSrcweir test( pRGBStart[150].Red == 1.0 && pRGBStart[150].Green == 1.0 && pRGBStart[150].Blue == 1.0, 279*cdf0e10cSrcweir "150th pixel is white" ); 280*cdf0e10cSrcweir 281*cdf0e10cSrcweir if( nOriginalDepth > 8 ) 282*cdf0e10cSrcweir { 283*cdf0e10cSrcweir const uno::Sequence<sal_Int8> aComponentTags( xBmp->getComponentTags() ); 284*cdf0e10cSrcweir uno::Sequence<rendering::ARGBColor> aARGBColor(1); 285*cdf0e10cSrcweir uno::Sequence<rendering::RGBColor> aRGBColor(1); 286*cdf0e10cSrcweir uno::Sequence<sal_Int8> aPixel3, aPixel4; 287*cdf0e10cSrcweir 288*cdf0e10cSrcweir const Color aCol(COL_GREEN); 289*cdf0e10cSrcweir aARGBColor[0].Red = vcl::unotools::toDoubleColor(aCol.GetRed()); 290*cdf0e10cSrcweir aARGBColor[0].Green = vcl::unotools::toDoubleColor(aCol.GetGreen()); 291*cdf0e10cSrcweir aARGBColor[0].Blue = vcl::unotools::toDoubleColor(aCol.GetBlue()); 292*cdf0e10cSrcweir aARGBColor[0].Alpha = 1.0; 293*cdf0e10cSrcweir 294*cdf0e10cSrcweir aRGBColor[0].Red = vcl::unotools::toDoubleColor(aCol.GetRed()); 295*cdf0e10cSrcweir aRGBColor[0].Green = vcl::unotools::toDoubleColor(aCol.GetGreen()); 296*cdf0e10cSrcweir aRGBColor[0].Blue = vcl::unotools::toDoubleColor(aCol.GetBlue()); 297*cdf0e10cSrcweir 298*cdf0e10cSrcweir aPixel3 = xBmp->convertIntegerFromARGB( aARGBColor ); 299*cdf0e10cSrcweir aPixel4 = xBmp->getPixel( aLayout, geometry::IntegerPoint2D(5,0) ); 300*cdf0e10cSrcweir test( aPixel3 == aPixel4, 301*cdf0e10cSrcweir "Green pixel from bitmap matches with manually converted green pixel" ); 302*cdf0e10cSrcweir 303*cdf0e10cSrcweir if( !aContainedBmpEx.IsTransparent() ) 304*cdf0e10cSrcweir { 305*cdf0e10cSrcweir aPixel3 = xBmp->convertIntegerFromRGB( aRGBColor ); 306*cdf0e10cSrcweir test( aPixel3 == aPixel4, 307*cdf0e10cSrcweir "Green pixel from bitmap matches with manually RGB-converted green pixel" ); 308*cdf0e10cSrcweir } 309*cdf0e10cSrcweir } 310*cdf0e10cSrcweir } 311*cdf0e10cSrcweir 312*cdf0e10cSrcweir //---------------------------------------------------------------------------------- 313*cdf0e10cSrcweir 314*cdf0e10cSrcweir void checkBitmapImport( const rtl::Reference<VclCanvasBitmap>& xBmp, 315*cdf0e10cSrcweir const char* msg, 316*cdf0e10cSrcweir int nOriginalDepth ) 317*cdf0e10cSrcweir { 318*cdf0e10cSrcweir OSL_TRACE("-------------------------"); 319*cdf0e10cSrcweir OSL_TRACE("Testing %s, with depth %d", msg, nOriginalDepth); 320*cdf0e10cSrcweir 321*cdf0e10cSrcweir BitmapEx aContainedBmpEx( xBmp->getBitmapEx() ); 322*cdf0e10cSrcweir Bitmap aContainedBmp( aContainedBmpEx.GetBitmap() ); 323*cdf0e10cSrcweir int nDepth = nOriginalDepth; 324*cdf0e10cSrcweir 325*cdf0e10cSrcweir { 326*cdf0e10cSrcweir ScopedBitmapReadAccess pAcc( aContainedBmp.AcquireReadAccess(), 327*cdf0e10cSrcweir aContainedBmp ); 328*cdf0e10cSrcweir nDepth = pAcc->GetBitCount(); 329*cdf0e10cSrcweir } 330*cdf0e10cSrcweir 331*cdf0e10cSrcweir test( aContainedBmp.GetSizePixel() == Size(200,200), 332*cdf0e10cSrcweir "Original bitmap size" ); 333*cdf0e10cSrcweir 334*cdf0e10cSrcweir test( xBmp->getSize().Width == 200 && xBmp->getSize().Height == 200, 335*cdf0e10cSrcweir "Original bitmap size via API" ); 336*cdf0e10cSrcweir 337*cdf0e10cSrcweir test( xBmp->hasAlpha() == aContainedBmpEx.IsTransparent(), 338*cdf0e10cSrcweir "Correct alpha state" ); 339*cdf0e10cSrcweir 340*cdf0e10cSrcweir test( xBmp->getScaledBitmap( geometry::RealSize2D(500,500), sal_False ).is(), 341*cdf0e10cSrcweir "getScaledBitmap()" ); 342*cdf0e10cSrcweir 343*cdf0e10cSrcweir rendering::IntegerBitmapLayout aLayout; 344*cdf0e10cSrcweir uno::Sequence<sal_Int8> aPixelData = xBmp->getData(aLayout, geometry::IntegerRectangle2D(0,0,1,1)); 345*cdf0e10cSrcweir 346*cdf0e10cSrcweir const sal_Int32 nExpectedBitsPerPixel( 347*cdf0e10cSrcweir aContainedBmpEx.IsTransparent() ? std::max(8,nDepth)+8 : nDepth); 348*cdf0e10cSrcweir test( aLayout.ScanLines == 1, 349*cdf0e10cSrcweir "# scanlines" ); 350*cdf0e10cSrcweir test( aLayout.ScanLineBytes == (nExpectedBitsPerPixel+7)/8, 351*cdf0e10cSrcweir "# scanline bytes" ); 352*cdf0e10cSrcweir test( aLayout.ScanLineStride == (nExpectedBitsPerPixel+7)/8 || 353*cdf0e10cSrcweir aLayout.ScanLineStride == -(nExpectedBitsPerPixel+7)/8, 354*cdf0e10cSrcweir "# scanline stride" ); 355*cdf0e10cSrcweir test( aLayout.PlaneStride == 0, 356*cdf0e10cSrcweir "# plane stride" ); 357*cdf0e10cSrcweir 358*cdf0e10cSrcweir test( aLayout.ColorSpace.is(), 359*cdf0e10cSrcweir "Color space there" ); 360*cdf0e10cSrcweir 361*cdf0e10cSrcweir test( aLayout.Palette.is() == (nDepth <= 8), 362*cdf0e10cSrcweir "Palette existance conforms to bitmap" ); 363*cdf0e10cSrcweir 364*cdf0e10cSrcweir uno::Sequence<sal_Int8> aPixelData2 = xBmp->getPixel( aLayout, geometry::IntegerPoint2D(0,0) ); 365*cdf0e10cSrcweir 366*cdf0e10cSrcweir test( aPixelData2.getLength() == aPixelData.getLength(), 367*cdf0e10cSrcweir "getData and getPixel return same amount of data" ); 368*cdf0e10cSrcweir 369*cdf0e10cSrcweir aPixelData = xBmp->getData(aLayout, geometry::IntegerRectangle2D(0,0,200,1)); 370*cdf0e10cSrcweir test( aLayout.ScanLines == 1, 371*cdf0e10cSrcweir "# scanlines" ); 372*cdf0e10cSrcweir test( aLayout.ScanLineBytes == (200*nExpectedBitsPerPixel+7)/8, 373*cdf0e10cSrcweir "# scanline bytes" ); 374*cdf0e10cSrcweir test( aLayout.ScanLineStride == (200*nExpectedBitsPerPixel+7)/8 || 375*cdf0e10cSrcweir aLayout.ScanLineStride == -(200*nExpectedBitsPerPixel+7)/8, 376*cdf0e10cSrcweir "# scanline stride" ); 377*cdf0e10cSrcweir 378*cdf0e10cSrcweir uno::Sequence< rendering::RGBColor > aRGBColors = xBmp->convertIntegerToRGB( aPixelData ); 379*cdf0e10cSrcweir uno::Sequence< rendering::ARGBColor > aARGBColors = xBmp->convertIntegerToARGB( aPixelData ); 380*cdf0e10cSrcweir 381*cdf0e10cSrcweir const rendering::RGBColor* pRGBStart ( aRGBColors.getConstArray() ); 382*cdf0e10cSrcweir const rendering::RGBColor* pRGBEnd ( aRGBColors.getConstArray()+aRGBColors.getLength() ); 383*cdf0e10cSrcweir const rendering::ARGBColor* pARGBStart( aARGBColors.getConstArray() ); 384*cdf0e10cSrcweir std::pair<const rendering::RGBColor*, 385*cdf0e10cSrcweir const rendering::ARGBColor*> aRes = std::mismatch( pRGBStart, pRGBEnd, pARGBStart ); 386*cdf0e10cSrcweir test( aRes.first == pRGBEnd, 387*cdf0e10cSrcweir "argb and rgb colors are equal" ); 388*cdf0e10cSrcweir 389*cdf0e10cSrcweir test( std::find_if(pRGBStart,pRGBEnd,&rangeCheck) == pRGBEnd, 390*cdf0e10cSrcweir "rgb colors are within [0,1] range" ); 391*cdf0e10cSrcweir 392*cdf0e10cSrcweir test( pRGBStart[0].Red == 1.0 && pRGBStart[0].Green == 1.0 && pRGBStart[0].Blue == 1.0, 393*cdf0e10cSrcweir "First pixel is white" ); 394*cdf0e10cSrcweir test( pARGBStart[1].Alpha == 1.0, 395*cdf0e10cSrcweir "Second pixel is opaque" ); 396*cdf0e10cSrcweir if( aContainedBmpEx.IsTransparent() ) 397*cdf0e10cSrcweir { 398*cdf0e10cSrcweir test( pARGBStart[0].Alpha == 0.0, 399*cdf0e10cSrcweir "First pixel is fully transparent" ); 400*cdf0e10cSrcweir } 401*cdf0e10cSrcweir 402*cdf0e10cSrcweir test( pRGBStart[1].Red == 0.0 && pRGBStart[1].Green == 0.0 && pRGBStart[1].Blue == 0.0, 403*cdf0e10cSrcweir "Second pixel is black" ); 404*cdf0e10cSrcweir 405*cdf0e10cSrcweir if( nOriginalDepth > 8 ) 406*cdf0e10cSrcweir { 407*cdf0e10cSrcweir const Color aCol(COL_GREEN); 408*cdf0e10cSrcweir test( pRGBStart[5].Red == vcl::unotools::toDoubleColor(aCol.GetRed()) && 409*cdf0e10cSrcweir pRGBStart[5].Green == vcl::unotools::toDoubleColor(aCol.GetGreen()) && 410*cdf0e10cSrcweir pRGBStart[5].Blue == vcl::unotools::toDoubleColor(aCol.GetBlue()), 411*cdf0e10cSrcweir "Sixth pixel is green" ); 412*cdf0e10cSrcweir } 413*cdf0e10cSrcweir else if( nDepth <= 8 ) 414*cdf0e10cSrcweir { 415*cdf0e10cSrcweir uno::Reference<rendering::XBitmapPalette> xPal = xBmp->getPalette(); 416*cdf0e10cSrcweir test( xPal.is(), 417*cdf0e10cSrcweir "8bit or less: needs palette" ); 418*cdf0e10cSrcweir test( xPal->getNumberOfEntries() == 1L << nOriginalDepth, 419*cdf0e10cSrcweir "Palette has correct entry count" ); 420*cdf0e10cSrcweir uno::Sequence<double> aIndex; 421*cdf0e10cSrcweir test( xPal->setIndex(aIndex,sal_True,0) == sal_False, 422*cdf0e10cSrcweir "Palette is read-only" ); 423*cdf0e10cSrcweir test( xPal->getIndex(aIndex,0), 424*cdf0e10cSrcweir "Palette entry 0 is opaque" ); 425*cdf0e10cSrcweir test( xPal->getColorSpace().is(), 426*cdf0e10cSrcweir "Palette has a valid color space" ); 427*cdf0e10cSrcweir } 428*cdf0e10cSrcweir 429*cdf0e10cSrcweir test( pRGBStart[150].Red == 1.0 && pRGBStart[150].Green == 1.0 && pRGBStart[150].Blue == 1.0, 430*cdf0e10cSrcweir "150th pixel is white" ); 431*cdf0e10cSrcweir 432*cdf0e10cSrcweir if( nOriginalDepth > 8 ) 433*cdf0e10cSrcweir { 434*cdf0e10cSrcweir const uno::Sequence<sal_Int8> aComponentTags( xBmp->getComponentTags() ); 435*cdf0e10cSrcweir uno::Sequence<rendering::ARGBColor> aARGBColor(1); 436*cdf0e10cSrcweir uno::Sequence<rendering::RGBColor> aRGBColor(1); 437*cdf0e10cSrcweir uno::Sequence<sal_Int8> aPixel3, aPixel4; 438*cdf0e10cSrcweir 439*cdf0e10cSrcweir const Color aCol(COL_GREEN); 440*cdf0e10cSrcweir aARGBColor[0].Red = vcl::unotools::toDoubleColor(aCol.GetRed()); 441*cdf0e10cSrcweir aARGBColor[0].Green = vcl::unotools::toDoubleColor(aCol.GetGreen()); 442*cdf0e10cSrcweir aARGBColor[0].Blue = vcl::unotools::toDoubleColor(aCol.GetBlue()); 443*cdf0e10cSrcweir aARGBColor[0].Alpha = 1.0; 444*cdf0e10cSrcweir 445*cdf0e10cSrcweir aRGBColor[0].Red = vcl::unotools::toDoubleColor(aCol.GetRed()); 446*cdf0e10cSrcweir aRGBColor[0].Green = vcl::unotools::toDoubleColor(aCol.GetGreen()); 447*cdf0e10cSrcweir aRGBColor[0].Blue = vcl::unotools::toDoubleColor(aCol.GetBlue()); 448*cdf0e10cSrcweir 449*cdf0e10cSrcweir aPixel3 = xBmp->convertIntegerFromARGB( aARGBColor ); 450*cdf0e10cSrcweir aPixel4 = xBmp->getPixel( aLayout, geometry::IntegerPoint2D(5,0) ); 451*cdf0e10cSrcweir test( aPixel3 == aPixel4, 452*cdf0e10cSrcweir "Green pixel from bitmap matches with manually converted green pixel" ); 453*cdf0e10cSrcweir 454*cdf0e10cSrcweir if( !aContainedBmpEx.IsTransparent() ) 455*cdf0e10cSrcweir { 456*cdf0e10cSrcweir aPixel3 = xBmp->convertIntegerFromRGB( aRGBColor ); 457*cdf0e10cSrcweir test( aPixel3 == aPixel4, 458*cdf0e10cSrcweir "Green pixel from bitmap matches with manually RGB-converted green pixel" ); 459*cdf0e10cSrcweir } 460*cdf0e10cSrcweir } 461*cdf0e10cSrcweir } 462*cdf0e10cSrcweir 463*cdf0e10cSrcweir //---------------------------------------------------------------------------------- 464*cdf0e10cSrcweir 465*cdf0e10cSrcweir class TestBitmap : public cppu::WeakImplHelper3< rendering::XIntegerReadOnlyBitmap, 466*cdf0e10cSrcweir rendering::XBitmapPalette, 467*cdf0e10cSrcweir rendering::XIntegerBitmapColorSpace > 468*cdf0e10cSrcweir { 469*cdf0e10cSrcweir private: 470*cdf0e10cSrcweir geometry::IntegerSize2D maSize; 471*cdf0e10cSrcweir uno::Sequence<sal_Int8> maComponentTags; 472*cdf0e10cSrcweir uno::Sequence<sal_Int32> maComponentBitCounts; 473*cdf0e10cSrcweir rendering::IntegerBitmapLayout maLayout; 474*cdf0e10cSrcweir const sal_Int32 mnBitsPerPixel; 475*cdf0e10cSrcweir 476*cdf0e10cSrcweir // XBitmap 477*cdf0e10cSrcweir virtual geometry::IntegerSize2D SAL_CALL getSize() throw (uno::RuntimeException) { return maSize; } 478*cdf0e10cSrcweir virtual ::sal_Bool SAL_CALL hasAlpha( ) throw (uno::RuntimeException) { return mnBitsPerPixel != 8; } 479*cdf0e10cSrcweir virtual uno::Reference< rendering::XBitmap > SAL_CALL getScaledBitmap( const geometry::RealSize2D&, 480*cdf0e10cSrcweir sal_Bool ) throw (uno::RuntimeException) { return this; } 481*cdf0e10cSrcweir 482*cdf0e10cSrcweir // XIntegerReadOnlyBitmap 483*cdf0e10cSrcweir virtual uno::Sequence< ::sal_Int8 > SAL_CALL getData( rendering::IntegerBitmapLayout& bitmapLayout, 484*cdf0e10cSrcweir const geometry::IntegerRectangle2D& rect ) throw (lang::IndexOutOfBoundsException, 485*cdf0e10cSrcweir rendering::VolatileContentDestroyedException, uno::RuntimeException) 486*cdf0e10cSrcweir { 487*cdf0e10cSrcweir test( rect.X1 >= 0, "X1 within bounds" ); 488*cdf0e10cSrcweir test( rect.Y1 >= 0, "Y1 within bounds" ); 489*cdf0e10cSrcweir test( rect.X2 <= maSize.Width, "X2 within bounds" ); 490*cdf0e10cSrcweir test( rect.Y2 <= maSize.Height, "Y2 within bounds" ); 491*cdf0e10cSrcweir 492*cdf0e10cSrcweir bitmapLayout = getMemoryLayout(); 493*cdf0e10cSrcweir 494*cdf0e10cSrcweir const sal_Int32 nWidth = rect.X2-rect.X1; 495*cdf0e10cSrcweir const sal_Int32 nHeight = rect.Y2-rect.Y1; 496*cdf0e10cSrcweir const sal_Int32 nScanlineLen = (nWidth * mnBitsPerPixel + 7)/8; 497*cdf0e10cSrcweir uno::Sequence<sal_Int8> aRes( nScanlineLen * nHeight ); 498*cdf0e10cSrcweir sal_Int8* pOut = aRes.getArray(); 499*cdf0e10cSrcweir 500*cdf0e10cSrcweir bitmapLayout.ScanLines = nHeight; 501*cdf0e10cSrcweir bitmapLayout.ScanLineBytes = 502*cdf0e10cSrcweir bitmapLayout.ScanLineStride= nScanlineLen; 503*cdf0e10cSrcweir 504*cdf0e10cSrcweir if( mnBitsPerPixel == 8 ) 505*cdf0e10cSrcweir { 506*cdf0e10cSrcweir for( sal_Int32 y=0; y<nHeight; ++y ) 507*cdf0e10cSrcweir { 508*cdf0e10cSrcweir for( sal_Int32 x=0; x<nWidth; ++x ) 509*cdf0e10cSrcweir pOut[ y*nScanlineLen + x ] = sal_Int8(x); 510*cdf0e10cSrcweir } 511*cdf0e10cSrcweir } 512*cdf0e10cSrcweir else 513*cdf0e10cSrcweir { 514*cdf0e10cSrcweir for( sal_Int32 y=0; y<nHeight; ++y ) 515*cdf0e10cSrcweir { 516*cdf0e10cSrcweir for( sal_Int32 x=0; x<nWidth; ++x ) 517*cdf0e10cSrcweir { 518*cdf0e10cSrcweir pOut[ y*nScanlineLen + 4*x ] = sal_Int8(rect.X1); 519*cdf0e10cSrcweir pOut[ y*nScanlineLen + 4*x + 1 ] = sal_Int8(rect.Y2); 520*cdf0e10cSrcweir pOut[ y*nScanlineLen + 4*x + 2 ] = sal_Int8(x); 521*cdf0e10cSrcweir pOut[ y*nScanlineLen + 4*x + 3 ] = sal_Int8(rect.Y1); 522*cdf0e10cSrcweir } 523*cdf0e10cSrcweir } 524*cdf0e10cSrcweir } 525*cdf0e10cSrcweir 526*cdf0e10cSrcweir return aRes; 527*cdf0e10cSrcweir } 528*cdf0e10cSrcweir 529*cdf0e10cSrcweir virtual uno::Sequence< ::sal_Int8 > SAL_CALL getPixel( rendering::IntegerBitmapLayout&, 530*cdf0e10cSrcweir const geometry::IntegerPoint2D& ) throw (lang::IndexOutOfBoundsException, 531*cdf0e10cSrcweir rendering::VolatileContentDestroyedException, uno::RuntimeException) 532*cdf0e10cSrcweir { 533*cdf0e10cSrcweir test(false, "Method not implemented"); 534*cdf0e10cSrcweir return uno::Sequence< sal_Int8 >(); 535*cdf0e10cSrcweir } 536*cdf0e10cSrcweir 537*cdf0e10cSrcweir virtual uno::Reference< rendering::XBitmapPalette > SAL_CALL getPalette( ) throw (uno::RuntimeException) 538*cdf0e10cSrcweir { 539*cdf0e10cSrcweir uno::Reference< XBitmapPalette > aRet; 540*cdf0e10cSrcweir if( mnBitsPerPixel == 8 ) 541*cdf0e10cSrcweir aRet.set(this); 542*cdf0e10cSrcweir return aRet; 543*cdf0e10cSrcweir } 544*cdf0e10cSrcweir 545*cdf0e10cSrcweir virtual rendering::IntegerBitmapLayout SAL_CALL getMemoryLayout( ) throw (uno::RuntimeException) 546*cdf0e10cSrcweir { 547*cdf0e10cSrcweir rendering::IntegerBitmapLayout aLayout( maLayout ); 548*cdf0e10cSrcweir 549*cdf0e10cSrcweir const sal_Int32 nScanlineLen = (maSize.Width * mnBitsPerPixel + 7)/8; 550*cdf0e10cSrcweir 551*cdf0e10cSrcweir aLayout.ScanLines = maSize.Height; 552*cdf0e10cSrcweir aLayout.ScanLineBytes = 553*cdf0e10cSrcweir aLayout.ScanLineStride= nScanlineLen; 554*cdf0e10cSrcweir aLayout.Palette = getPalette(); 555*cdf0e10cSrcweir aLayout.ColorSpace.set( this ); 556*cdf0e10cSrcweir 557*cdf0e10cSrcweir return aLayout; 558*cdf0e10cSrcweir } 559*cdf0e10cSrcweir 560*cdf0e10cSrcweir // XBitmapPalette 561*cdf0e10cSrcweir virtual sal_Int32 SAL_CALL getNumberOfEntries() throw (uno::RuntimeException) 562*cdf0e10cSrcweir { 563*cdf0e10cSrcweir test( getPalette().is(), 564*cdf0e10cSrcweir "Got palette interface call without handing out palette?!" ); 565*cdf0e10cSrcweir 566*cdf0e10cSrcweir return 255; 567*cdf0e10cSrcweir } 568*cdf0e10cSrcweir 569*cdf0e10cSrcweir virtual ::sal_Bool SAL_CALL getIndex( uno::Sequence< double >& entry, 570*cdf0e10cSrcweir ::sal_Int32 nIndex ) throw (lang::IndexOutOfBoundsException, 571*cdf0e10cSrcweir uno::RuntimeException) 572*cdf0e10cSrcweir { 573*cdf0e10cSrcweir test( getPalette().is(), 574*cdf0e10cSrcweir "Got palette interface call without handing out palette?!" ); 575*cdf0e10cSrcweir test( nIndex >= 0 && nIndex < 256, 576*cdf0e10cSrcweir "Index out of range" ); 577*cdf0e10cSrcweir entry = colorToStdColorSpaceSequence( 578*cdf0e10cSrcweir Color(UINT8(nIndex), 579*cdf0e10cSrcweir UINT8(nIndex), 580*cdf0e10cSrcweir UINT8(nIndex)) ); 581*cdf0e10cSrcweir 582*cdf0e10cSrcweir return sal_True; // no palette transparency here. 583*cdf0e10cSrcweir } 584*cdf0e10cSrcweir 585*cdf0e10cSrcweir virtual ::sal_Bool SAL_CALL setIndex( const uno::Sequence< double >&, 586*cdf0e10cSrcweir ::sal_Bool, 587*cdf0e10cSrcweir ::sal_Int32 nIndex ) throw (lang::IndexOutOfBoundsException, 588*cdf0e10cSrcweir lang::IllegalArgumentException, 589*cdf0e10cSrcweir uno::RuntimeException) 590*cdf0e10cSrcweir { 591*cdf0e10cSrcweir test( getPalette().is(), 592*cdf0e10cSrcweir "Got palette interface call without handing out palette?!" ); 593*cdf0e10cSrcweir test( nIndex >= 0 && nIndex < 256, 594*cdf0e10cSrcweir "Index out of range" ); 595*cdf0e10cSrcweir return sal_False; 596*cdf0e10cSrcweir } 597*cdf0e10cSrcweir 598*cdf0e10cSrcweir struct PaletteColorSpaceHolder: public rtl::StaticWithInit<uno::Reference<rendering::XColorSpace>, 599*cdf0e10cSrcweir PaletteColorSpaceHolder> 600*cdf0e10cSrcweir { 601*cdf0e10cSrcweir uno::Reference<rendering::XColorSpace> operator()() 602*cdf0e10cSrcweir { 603*cdf0e10cSrcweir return vcl::unotools::createStandardColorSpace(); 604*cdf0e10cSrcweir } 605*cdf0e10cSrcweir }; 606*cdf0e10cSrcweir 607*cdf0e10cSrcweir virtual uno::Reference< rendering::XColorSpace > SAL_CALL getColorSpace( ) throw (uno::RuntimeException) 608*cdf0e10cSrcweir { 609*cdf0e10cSrcweir // this is the method from XBitmapPalette. Return palette color 610*cdf0e10cSrcweir // space here 611*cdf0e10cSrcweir return PaletteColorSpaceHolder::get(); 612*cdf0e10cSrcweir } 613*cdf0e10cSrcweir 614*cdf0e10cSrcweir // XIntegerBitmapColorSpace 615*cdf0e10cSrcweir virtual ::sal_Int8 SAL_CALL getType( ) throw (uno::RuntimeException) 616*cdf0e10cSrcweir { 617*cdf0e10cSrcweir return rendering::ColorSpaceType::RGB; 618*cdf0e10cSrcweir } 619*cdf0e10cSrcweir 620*cdf0e10cSrcweir virtual uno::Sequence< sal_Int8 > SAL_CALL getComponentTags( ) throw (uno::RuntimeException) 621*cdf0e10cSrcweir { 622*cdf0e10cSrcweir return maComponentTags; 623*cdf0e10cSrcweir } 624*cdf0e10cSrcweir 625*cdf0e10cSrcweir virtual ::sal_Int8 SAL_CALL getRenderingIntent( ) throw (uno::RuntimeException) 626*cdf0e10cSrcweir { 627*cdf0e10cSrcweir return rendering::RenderingIntent::PERCEPTUAL; 628*cdf0e10cSrcweir } 629*cdf0e10cSrcweir 630*cdf0e10cSrcweir virtual uno::Sequence< beans::PropertyValue > SAL_CALL getProperties( ) throw (uno::RuntimeException) 631*cdf0e10cSrcweir { 632*cdf0e10cSrcweir test(false, "Method not implemented"); 633*cdf0e10cSrcweir return uno::Sequence< ::beans::PropertyValue >(); 634*cdf0e10cSrcweir } 635*cdf0e10cSrcweir 636*cdf0e10cSrcweir virtual uno::Sequence< double > SAL_CALL convertColorSpace( const uno::Sequence< double >&, 637*cdf0e10cSrcweir const uno::Reference< rendering::XColorSpace >& ) throw (uno::RuntimeException) 638*cdf0e10cSrcweir { 639*cdf0e10cSrcweir test(false, "Method not implemented"); 640*cdf0e10cSrcweir return uno::Sequence< double >(); 641*cdf0e10cSrcweir } 642*cdf0e10cSrcweir 643*cdf0e10cSrcweir virtual uno::Sequence< rendering::RGBColor > SAL_CALL convertToRGB( const uno::Sequence< double >& ) throw (lang::IllegalArgumentException, 644*cdf0e10cSrcweir uno::RuntimeException) 645*cdf0e10cSrcweir { 646*cdf0e10cSrcweir test(false, "Method not implemented"); 647*cdf0e10cSrcweir return uno::Sequence< rendering::RGBColor >(); 648*cdf0e10cSrcweir } 649*cdf0e10cSrcweir 650*cdf0e10cSrcweir virtual uno::Sequence< rendering::ARGBColor > SAL_CALL convertToARGB( const uno::Sequence< double >& ) throw (lang::IllegalArgumentException, 651*cdf0e10cSrcweir uno::RuntimeException) 652*cdf0e10cSrcweir { 653*cdf0e10cSrcweir test(false, "Method not implemented"); 654*cdf0e10cSrcweir return uno::Sequence< rendering::ARGBColor >(); 655*cdf0e10cSrcweir } 656*cdf0e10cSrcweir 657*cdf0e10cSrcweir virtual uno::Sequence< rendering::ARGBColor > SAL_CALL convertToPARGB( const uno::Sequence< double >& ) throw (lang::IllegalArgumentException, 658*cdf0e10cSrcweir uno::RuntimeException) 659*cdf0e10cSrcweir { 660*cdf0e10cSrcweir test(false, "Method not implemented"); 661*cdf0e10cSrcweir return uno::Sequence< rendering::ARGBColor >(); 662*cdf0e10cSrcweir } 663*cdf0e10cSrcweir 664*cdf0e10cSrcweir virtual uno::Sequence< double > SAL_CALL convertFromRGB( const uno::Sequence< rendering::RGBColor >& ) throw (lang::IllegalArgumentException, 665*cdf0e10cSrcweir uno::RuntimeException) 666*cdf0e10cSrcweir { 667*cdf0e10cSrcweir test(false, "Method not implemented"); 668*cdf0e10cSrcweir return uno::Sequence< double >(); 669*cdf0e10cSrcweir } 670*cdf0e10cSrcweir 671*cdf0e10cSrcweir virtual uno::Sequence< double > SAL_CALL convertFromARGB( const uno::Sequence< rendering::ARGBColor >& ) throw (lang::IllegalArgumentException, 672*cdf0e10cSrcweir uno::RuntimeException) 673*cdf0e10cSrcweir { 674*cdf0e10cSrcweir test(false, "This method is not expected to be called!"); 675*cdf0e10cSrcweir return uno::Sequence< double >(); 676*cdf0e10cSrcweir } 677*cdf0e10cSrcweir 678*cdf0e10cSrcweir virtual uno::Sequence< double > SAL_CALL convertFromPARGB( const uno::Sequence< rendering::ARGBColor >& ) throw (lang::IllegalArgumentException, 679*cdf0e10cSrcweir uno::RuntimeException) 680*cdf0e10cSrcweir { 681*cdf0e10cSrcweir test(false, "This method is not expected to be called!"); 682*cdf0e10cSrcweir return uno::Sequence< double >(); 683*cdf0e10cSrcweir } 684*cdf0e10cSrcweir 685*cdf0e10cSrcweir virtual ::sal_Int32 SAL_CALL getBitsPerPixel( ) throw (uno::RuntimeException) 686*cdf0e10cSrcweir { 687*cdf0e10cSrcweir return mnBitsPerPixel; 688*cdf0e10cSrcweir } 689*cdf0e10cSrcweir 690*cdf0e10cSrcweir virtual uno::Sequence< ::sal_Int32 > SAL_CALL getComponentBitCounts( ) throw (uno::RuntimeException) 691*cdf0e10cSrcweir { 692*cdf0e10cSrcweir return maComponentBitCounts; 693*cdf0e10cSrcweir } 694*cdf0e10cSrcweir 695*cdf0e10cSrcweir virtual ::sal_Int8 SAL_CALL getEndianness( ) throw (uno::RuntimeException) 696*cdf0e10cSrcweir { 697*cdf0e10cSrcweir return util::Endianness::LITTLE; 698*cdf0e10cSrcweir } 699*cdf0e10cSrcweir 700*cdf0e10cSrcweir virtual uno::Sequence< double > SAL_CALL convertFromIntegerColorSpace( const uno::Sequence< ::sal_Int8 >& , 701*cdf0e10cSrcweir const uno::Reference< rendering::XColorSpace >& ) throw (lang::IllegalArgumentException, 702*cdf0e10cSrcweir uno::RuntimeException) 703*cdf0e10cSrcweir { 704*cdf0e10cSrcweir test(false, "Method not implemented"); 705*cdf0e10cSrcweir return uno::Sequence< double >(); 706*cdf0e10cSrcweir } 707*cdf0e10cSrcweir 708*cdf0e10cSrcweir virtual uno::Sequence< ::sal_Int8 > SAL_CALL convertToIntegerColorSpace( const uno::Sequence< ::sal_Int8 >& , 709*cdf0e10cSrcweir const uno::Reference< rendering::XIntegerBitmapColorSpace >& ) throw (lang::IllegalArgumentException, 710*cdf0e10cSrcweir uno::RuntimeException) 711*cdf0e10cSrcweir { 712*cdf0e10cSrcweir test(false, "Method not implemented"); 713*cdf0e10cSrcweir return uno::Sequence< sal_Int8 >(); 714*cdf0e10cSrcweir } 715*cdf0e10cSrcweir 716*cdf0e10cSrcweir virtual uno::Sequence< rendering::RGBColor > SAL_CALL convertIntegerToRGB( const uno::Sequence< ::sal_Int8 >& deviceColor ) throw (lang::IllegalArgumentException, 717*cdf0e10cSrcweir uno::RuntimeException) 718*cdf0e10cSrcweir { 719*cdf0e10cSrcweir const uno::Sequence< rendering::ARGBColor > aTemp( convertIntegerToARGB(deviceColor) ); 720*cdf0e10cSrcweir const sal_Size nLen(aTemp.getLength()); 721*cdf0e10cSrcweir uno::Sequence< rendering::RGBColor > aRes( nLen ); 722*cdf0e10cSrcweir rendering::RGBColor* pOut = aRes.getArray(); 723*cdf0e10cSrcweir for( sal_Size i=0; i<nLen; ++i ) 724*cdf0e10cSrcweir { 725*cdf0e10cSrcweir *pOut++ = rendering::RGBColor(aTemp[i].Red, 726*cdf0e10cSrcweir aTemp[i].Green, 727*cdf0e10cSrcweir aTemp[i].Blue); 728*cdf0e10cSrcweir } 729*cdf0e10cSrcweir 730*cdf0e10cSrcweir return aRes; 731*cdf0e10cSrcweir } 732*cdf0e10cSrcweir 733*cdf0e10cSrcweir virtual uno::Sequence< rendering::ARGBColor > SAL_CALL convertIntegerToARGB( const uno::Sequence< ::sal_Int8 >& deviceColor ) throw (lang::IllegalArgumentException, 734*cdf0e10cSrcweir uno::RuntimeException) 735*cdf0e10cSrcweir { 736*cdf0e10cSrcweir const sal_Size nLen( deviceColor.getLength() ); 737*cdf0e10cSrcweir const sal_Int32 nBytesPerPixel(mnBitsPerPixel == 8 ? 1 : 4); 738*cdf0e10cSrcweir test(nLen%nBytesPerPixel==0, 739*cdf0e10cSrcweir "number of channels no multiple of pixel element count"); 740*cdf0e10cSrcweir 741*cdf0e10cSrcweir uno::Sequence< rendering::ARGBColor > aRes( nLen / nBytesPerPixel ); 742*cdf0e10cSrcweir rendering::ARGBColor* pOut( aRes.getArray() ); 743*cdf0e10cSrcweir 744*cdf0e10cSrcweir if( getPalette().is() ) 745*cdf0e10cSrcweir { 746*cdf0e10cSrcweir for( sal_Size i=0; i<nLen; ++i ) 747*cdf0e10cSrcweir { 748*cdf0e10cSrcweir *pOut++ = rendering::ARGBColor( 749*cdf0e10cSrcweir 1.0, 750*cdf0e10cSrcweir vcl::unotools::toDoubleColor(deviceColor[i]), 751*cdf0e10cSrcweir vcl::unotools::toDoubleColor(deviceColor[i]), 752*cdf0e10cSrcweir vcl::unotools::toDoubleColor(deviceColor[i])); 753*cdf0e10cSrcweir } 754*cdf0e10cSrcweir } 755*cdf0e10cSrcweir else 756*cdf0e10cSrcweir { 757*cdf0e10cSrcweir for( sal_Size i=0; i<nLen; i+=4 ) 758*cdf0e10cSrcweir { 759*cdf0e10cSrcweir *pOut++ = rendering::ARGBColor( 760*cdf0e10cSrcweir vcl::unotools::toDoubleColor(deviceColor[i+3]), 761*cdf0e10cSrcweir vcl::unotools::toDoubleColor(deviceColor[i+0]), 762*cdf0e10cSrcweir vcl::unotools::toDoubleColor(deviceColor[i+1]), 763*cdf0e10cSrcweir vcl::unotools::toDoubleColor(deviceColor[i+2])); 764*cdf0e10cSrcweir } 765*cdf0e10cSrcweir } 766*cdf0e10cSrcweir 767*cdf0e10cSrcweir return aRes; 768*cdf0e10cSrcweir } 769*cdf0e10cSrcweir 770*cdf0e10cSrcweir virtual uno::Sequence< rendering::ARGBColor > SAL_CALL convertIntegerToPARGB( const uno::Sequence< ::sal_Int8 >& deviceColor ) throw (lang::IllegalArgumentException, 771*cdf0e10cSrcweir uno::RuntimeException) 772*cdf0e10cSrcweir { 773*cdf0e10cSrcweir const sal_Size nLen( deviceColor.getLength() ); 774*cdf0e10cSrcweir const sal_Int32 nBytesPerPixel(mnBitsPerPixel == 8 ? 1 : 4); 775*cdf0e10cSrcweir test(nLen%nBytesPerPixel==0, 776*cdf0e10cSrcweir "number of channels no multiple of pixel element count"); 777*cdf0e10cSrcweir 778*cdf0e10cSrcweir uno::Sequence< rendering::ARGBColor > aRes( nLen / nBytesPerPixel ); 779*cdf0e10cSrcweir rendering::ARGBColor* pOut( aRes.getArray() ); 780*cdf0e10cSrcweir 781*cdf0e10cSrcweir if( getPalette().is() ) 782*cdf0e10cSrcweir { 783*cdf0e10cSrcweir for( sal_Size i=0; i<nLen; ++i ) 784*cdf0e10cSrcweir { 785*cdf0e10cSrcweir *pOut++ = rendering::ARGBColor( 786*cdf0e10cSrcweir 1.0, 787*cdf0e10cSrcweir vcl::unotools::toDoubleColor(deviceColor[i]), 788*cdf0e10cSrcweir vcl::unotools::toDoubleColor(deviceColor[i]), 789*cdf0e10cSrcweir vcl::unotools::toDoubleColor(deviceColor[i])); 790*cdf0e10cSrcweir } 791*cdf0e10cSrcweir } 792*cdf0e10cSrcweir else 793*cdf0e10cSrcweir { 794*cdf0e10cSrcweir for( sal_Size i=0; i<nLen; i+=4 ) 795*cdf0e10cSrcweir { 796*cdf0e10cSrcweir const double fAlpha=vcl::unotools::toDoubleColor(deviceColor[i+3]); 797*cdf0e10cSrcweir *pOut++ = rendering::ARGBColor( 798*cdf0e10cSrcweir fAlpha, 799*cdf0e10cSrcweir fAlpha*vcl::unotools::toDoubleColor(deviceColor[i+0]), 800*cdf0e10cSrcweir fAlpha*vcl::unotools::toDoubleColor(deviceColor[i+1]), 801*cdf0e10cSrcweir fAlpha*vcl::unotools::toDoubleColor(deviceColor[i+2])); 802*cdf0e10cSrcweir } 803*cdf0e10cSrcweir } 804*cdf0e10cSrcweir 805*cdf0e10cSrcweir return aRes; 806*cdf0e10cSrcweir } 807*cdf0e10cSrcweir 808*cdf0e10cSrcweir virtual uno::Sequence< ::sal_Int8 > SAL_CALL convertIntegerFromRGB( const uno::Sequence< rendering::RGBColor >& ) throw (lang::IllegalArgumentException, 809*cdf0e10cSrcweir uno::RuntimeException) 810*cdf0e10cSrcweir { 811*cdf0e10cSrcweir test(false, "Method not implemented"); 812*cdf0e10cSrcweir return uno::Sequence< sal_Int8 >(); 813*cdf0e10cSrcweir } 814*cdf0e10cSrcweir 815*cdf0e10cSrcweir virtual uno::Sequence< ::sal_Int8 > SAL_CALL convertIntegerFromARGB( const uno::Sequence< rendering::ARGBColor >& ) throw (lang::IllegalArgumentException, 816*cdf0e10cSrcweir uno::RuntimeException) 817*cdf0e10cSrcweir { 818*cdf0e10cSrcweir test(false, "Method not implemented"); 819*cdf0e10cSrcweir return uno::Sequence< sal_Int8 >(); 820*cdf0e10cSrcweir } 821*cdf0e10cSrcweir 822*cdf0e10cSrcweir virtual uno::Sequence< ::sal_Int8 > SAL_CALL convertIntegerFromPARGB( const uno::Sequence< rendering::ARGBColor >& ) throw (lang::IllegalArgumentException, 823*cdf0e10cSrcweir uno::RuntimeException) 824*cdf0e10cSrcweir { 825*cdf0e10cSrcweir test(false, "Method not implemented"); 826*cdf0e10cSrcweir return uno::Sequence< sal_Int8 >(); 827*cdf0e10cSrcweir } 828*cdf0e10cSrcweir 829*cdf0e10cSrcweir public: 830*cdf0e10cSrcweir TestBitmap( const geometry::IntegerSize2D& rSize, bool bPalette ) : 831*cdf0e10cSrcweir maSize(rSize), 832*cdf0e10cSrcweir maComponentTags(), 833*cdf0e10cSrcweir maComponentBitCounts(), 834*cdf0e10cSrcweir maLayout(), 835*cdf0e10cSrcweir mnBitsPerPixel( bPalette ? 8 : 32 ) 836*cdf0e10cSrcweir { 837*cdf0e10cSrcweir if( bPalette ) 838*cdf0e10cSrcweir { 839*cdf0e10cSrcweir maComponentTags.realloc(1); 840*cdf0e10cSrcweir maComponentTags[0] = rendering::ColorComponentTag::INDEX; 841*cdf0e10cSrcweir 842*cdf0e10cSrcweir maComponentBitCounts.realloc(1); 843*cdf0e10cSrcweir maComponentBitCounts[0] = 8; 844*cdf0e10cSrcweir } 845*cdf0e10cSrcweir else 846*cdf0e10cSrcweir { 847*cdf0e10cSrcweir maComponentTags.realloc(4); 848*cdf0e10cSrcweir sal_Int8* pTags = maComponentTags.getArray(); 849*cdf0e10cSrcweir pTags[0] = rendering::ColorComponentTag::RGB_BLUE; 850*cdf0e10cSrcweir pTags[1] = rendering::ColorComponentTag::RGB_GREEN; 851*cdf0e10cSrcweir pTags[2] = rendering::ColorComponentTag::RGB_RED; 852*cdf0e10cSrcweir pTags[3] = rendering::ColorComponentTag::ALPHA; 853*cdf0e10cSrcweir 854*cdf0e10cSrcweir maComponentBitCounts.realloc(4); 855*cdf0e10cSrcweir sal_Int32* pCounts = maComponentBitCounts.getArray(); 856*cdf0e10cSrcweir pCounts[0] = 8; 857*cdf0e10cSrcweir pCounts[1] = 8; 858*cdf0e10cSrcweir pCounts[2] = 8; 859*cdf0e10cSrcweir pCounts[3] = 8; 860*cdf0e10cSrcweir } 861*cdf0e10cSrcweir 862*cdf0e10cSrcweir maLayout.ScanLines = 0; 863*cdf0e10cSrcweir maLayout.ScanLineBytes = 0; 864*cdf0e10cSrcweir maLayout.ScanLineStride = 0; 865*cdf0e10cSrcweir maLayout.PlaneStride = 0; 866*cdf0e10cSrcweir maLayout.ColorSpace.clear(); 867*cdf0e10cSrcweir maLayout.Palette.clear(); 868*cdf0e10cSrcweir maLayout.IsMsbFirst = sal_False; 869*cdf0e10cSrcweir } 870*cdf0e10cSrcweir }; 871*cdf0e10cSrcweir 872*cdf0e10cSrcweir 873*cdf0e10cSrcweir //---------------------------------------------------------------------------------- 874*cdf0e10cSrcweir 875*cdf0e10cSrcweir void TestWindow::Paint( const Rectangle& ) 876*cdf0e10cSrcweir { 877*cdf0e10cSrcweir static sal_Int8 lcl_depths[]={1,4,8,16,24}; 878*cdf0e10cSrcweir 879*cdf0e10cSrcweir try 880*cdf0e10cSrcweir { 881*cdf0e10cSrcweir // Testing VclCanvasBitmap wrapper 882*cdf0e10cSrcweir // =============================== 883*cdf0e10cSrcweir 884*cdf0e10cSrcweir for( unsigned int i=0; i<sizeof(lcl_depths)/sizeof(*lcl_depths); ++i ) 885*cdf0e10cSrcweir { 886*cdf0e10cSrcweir const sal_Int8 nDepth( lcl_depths[i] ); 887*cdf0e10cSrcweir Bitmap aBitmap(Size(200,200),nDepth); 888*cdf0e10cSrcweir aBitmap.Erase(COL_WHITE); 889*cdf0e10cSrcweir { 890*cdf0e10cSrcweir ScopedBitmapWriteAccess pAcc(aBitmap.AcquireWriteAccess(), 891*cdf0e10cSrcweir aBitmap); 892*cdf0e10cSrcweir if( pAcc.get() ) 893*cdf0e10cSrcweir { 894*cdf0e10cSrcweir BitmapColor aBlack(0); 895*cdf0e10cSrcweir BitmapColor aWhite(0); 896*cdf0e10cSrcweir if( pAcc->HasPalette() ) 897*cdf0e10cSrcweir { 898*cdf0e10cSrcweir aBlack.SetIndex( sal::static_int_cast<BYTE>(pAcc->GetBestPaletteIndex(BitmapColor(0,0,0))) ); 899*cdf0e10cSrcweir aWhite.SetIndex( sal::static_int_cast<BYTE>(pAcc->GetBestPaletteIndex(BitmapColor(255,255,255))) ); 900*cdf0e10cSrcweir } 901*cdf0e10cSrcweir else 902*cdf0e10cSrcweir { 903*cdf0e10cSrcweir aBlack = Color(COL_BLACK); 904*cdf0e10cSrcweir aWhite = Color(COL_WHITE); 905*cdf0e10cSrcweir } 906*cdf0e10cSrcweir pAcc->SetFillColor(COL_GREEN); 907*cdf0e10cSrcweir pAcc->FillRect(Rectangle(0,0,100,100)); 908*cdf0e10cSrcweir pAcc->SetPixel(0,0,aWhite); 909*cdf0e10cSrcweir pAcc->SetPixel(0,1,aBlack); 910*cdf0e10cSrcweir pAcc->SetPixel(0,2,aWhite); 911*cdf0e10cSrcweir } 912*cdf0e10cSrcweir } 913*cdf0e10cSrcweir 914*cdf0e10cSrcweir rtl::Reference<VclCanvasBitmap> xBmp( new VclCanvasBitmap(aBitmap) ); 915*cdf0e10cSrcweir 916*cdf0e10cSrcweir checkCanvasBitmap( xBmp, "single bitmap", nDepth ); 917*cdf0e10cSrcweir 918*cdf0e10cSrcweir Bitmap aMask(Size(200,200),1); 919*cdf0e10cSrcweir aMask.Erase(COL_WHITE); 920*cdf0e10cSrcweir { 921*cdf0e10cSrcweir ScopedBitmapWriteAccess pAcc(aMask.AcquireWriteAccess(), 922*cdf0e10cSrcweir aMask); 923*cdf0e10cSrcweir if( pAcc.get() ) 924*cdf0e10cSrcweir { 925*cdf0e10cSrcweir pAcc->SetFillColor(COL_BLACK); 926*cdf0e10cSrcweir pAcc->FillRect(Rectangle(0,0,100,100)); 927*cdf0e10cSrcweir pAcc->SetPixel(0,0,BitmapColor(1)); 928*cdf0e10cSrcweir pAcc->SetPixel(0,1,BitmapColor(0)); 929*cdf0e10cSrcweir pAcc->SetPixel(0,2,BitmapColor(1)); 930*cdf0e10cSrcweir } 931*cdf0e10cSrcweir } 932*cdf0e10cSrcweir 933*cdf0e10cSrcweir xBmp.set( new VclCanvasBitmap(BitmapEx(aBitmap,aMask)) ); 934*cdf0e10cSrcweir 935*cdf0e10cSrcweir checkCanvasBitmap( xBmp, "masked bitmap", nDepth ); 936*cdf0e10cSrcweir 937*cdf0e10cSrcweir AlphaMask aAlpha(Size(200,200)); 938*cdf0e10cSrcweir aAlpha.Erase(255); 939*cdf0e10cSrcweir { 940*cdf0e10cSrcweir BitmapWriteAccess* pAcc = aAlpha.AcquireWriteAccess(); 941*cdf0e10cSrcweir if( pAcc ) 942*cdf0e10cSrcweir { 943*cdf0e10cSrcweir pAcc->SetFillColor(COL_BLACK); 944*cdf0e10cSrcweir pAcc->FillRect(Rectangle(0,0,100,100)); 945*cdf0e10cSrcweir pAcc->SetPixel(0,0,BitmapColor(255)); 946*cdf0e10cSrcweir pAcc->SetPixel(0,1,BitmapColor(0)); 947*cdf0e10cSrcweir pAcc->SetPixel(0,2,BitmapColor(255)); 948*cdf0e10cSrcweir aAlpha.ReleaseAccess(pAcc); 949*cdf0e10cSrcweir } 950*cdf0e10cSrcweir } 951*cdf0e10cSrcweir 952*cdf0e10cSrcweir xBmp.set( new VclCanvasBitmap(BitmapEx(aBitmap,aAlpha)) ); 953*cdf0e10cSrcweir 954*cdf0e10cSrcweir checkCanvasBitmap( xBmp, "alpha bitmap", nDepth ); 955*cdf0e10cSrcweir } 956*cdf0e10cSrcweir 957*cdf0e10cSrcweir // Testing XBitmap import 958*cdf0e10cSrcweir // ====================== 959*cdf0e10cSrcweir uno::Reference< rendering::XIntegerReadOnlyBitmap > xTestBmp( 960*cdf0e10cSrcweir new TestBitmap( geometry::IntegerSize2D(10,10), true )); 961*cdf0e10cSrcweir 962*cdf0e10cSrcweir BitmapEx aBmp = vcl::unotools::bitmapExFromXBitmap(xTestBmp); 963*cdf0e10cSrcweir test( aBmp.IsTransparent() == false, 964*cdf0e10cSrcweir "Palette bitmap is not transparent" ); 965*cdf0e10cSrcweir test( aBmp.GetSizePixel() == Size(10,10), 966*cdf0e10cSrcweir "Bitmap has size (10,10)" ); 967*cdf0e10cSrcweir test( aBmp.GetBitCount() == 8, 968*cdf0e10cSrcweir "Bitmap has bitcount of 8" ); 969*cdf0e10cSrcweir { 970*cdf0e10cSrcweir BitmapReadAccess* pBmpAcc = aBmp.GetBitmap().AcquireReadAccess(); 971*cdf0e10cSrcweir 972*cdf0e10cSrcweir test( pBmpAcc, 973*cdf0e10cSrcweir "Bitmap has valid BitmapReadAccess" ); 974*cdf0e10cSrcweir 975*cdf0e10cSrcweir test(pBmpAcc->GetPixel(0,0) == BitmapColor(0), 976*cdf0e10cSrcweir "(0,0) correct content"); 977*cdf0e10cSrcweir test(pBmpAcc->GetPixel(2,2) == BitmapColor(2), 978*cdf0e10cSrcweir "(2,2) correct content"); 979*cdf0e10cSrcweir test(pBmpAcc->GetPixel(2,9) == BitmapColor(9), 980*cdf0e10cSrcweir "(9,2) correct content"); 981*cdf0e10cSrcweir 982*cdf0e10cSrcweir aBmp.GetBitmap().ReleaseAccess(pBmpAcc); 983*cdf0e10cSrcweir } 984*cdf0e10cSrcweir 985*cdf0e10cSrcweir xTestBmp.set( new TestBitmap( geometry::IntegerSize2D(10,10), false )); 986*cdf0e10cSrcweir 987*cdf0e10cSrcweir aBmp = vcl::unotools::bitmapExFromXBitmap(xTestBmp); 988*cdf0e10cSrcweir test( aBmp.IsTransparent() == TRUE, 989*cdf0e10cSrcweir "Palette bitmap is transparent" ); 990*cdf0e10cSrcweir test( aBmp.IsAlpha() == TRUE, 991*cdf0e10cSrcweir "Palette bitmap has alpha" ); 992*cdf0e10cSrcweir test( aBmp.GetSizePixel() == Size(10,10), 993*cdf0e10cSrcweir "Bitmap has size (10,10)" ); 994*cdf0e10cSrcweir test( aBmp.GetBitCount() == 24, 995*cdf0e10cSrcweir "Bitmap has bitcount of 24" ); 996*cdf0e10cSrcweir { 997*cdf0e10cSrcweir BitmapReadAccess* pBmpAcc = aBmp.GetBitmap().AcquireReadAccess(); 998*cdf0e10cSrcweir BitmapReadAccess* pAlphaAcc = aBmp.GetAlpha().AcquireReadAccess(); 999*cdf0e10cSrcweir 1000*cdf0e10cSrcweir test( pBmpAcc, 1001*cdf0e10cSrcweir "Bitmap has valid BitmapReadAccess" ); 1002*cdf0e10cSrcweir test( pAlphaAcc, 1003*cdf0e10cSrcweir "Bitmap has valid alpha BitmapReadAccess" ); 1004*cdf0e10cSrcweir 1005*cdf0e10cSrcweir test(pBmpAcc->GetPixel(0,0) == BitmapColor(0,1,0), 1006*cdf0e10cSrcweir "(0,0) correct content"); 1007*cdf0e10cSrcweir test(pAlphaAcc->GetPixel(0,0) == BitmapColor(255), 1008*cdf0e10cSrcweir "(0,0) correct alpha content"); 1009*cdf0e10cSrcweir test(pBmpAcc->GetPixel(2,2) == BitmapColor(0,3,2), 1010*cdf0e10cSrcweir "(2,2) correct content"); 1011*cdf0e10cSrcweir test(pAlphaAcc->GetPixel(2,2) == BitmapColor(253), 1012*cdf0e10cSrcweir "(2,2) correct alpha content"); 1013*cdf0e10cSrcweir test(pBmpAcc->GetPixel(2,9) == BitmapColor(0,3,9), 1014*cdf0e10cSrcweir "(9,2) correct content"); 1015*cdf0e10cSrcweir test(pAlphaAcc->GetPixel(2,9) == BitmapColor(253), 1016*cdf0e10cSrcweir "(9,2) correct alpha content"); 1017*cdf0e10cSrcweir 1018*cdf0e10cSrcweir aBmp.GetAlpha().ReleaseAccess(pAlphaAcc); 1019*cdf0e10cSrcweir aBmp.GetBitmap().ReleaseAccess(pBmpAcc); 1020*cdf0e10cSrcweir } 1021*cdf0e10cSrcweir } 1022*cdf0e10cSrcweir catch( uno::Exception& ) 1023*cdf0e10cSrcweir { 1024*cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 1025*cdf0e10cSrcweir exit(2); 1026*cdf0e10cSrcweir } 1027*cdf0e10cSrcweir catch( std::exception& ) 1028*cdf0e10cSrcweir { 1029*cdf0e10cSrcweir OSL_TRACE( "Caught std exception!" ); 1030*cdf0e10cSrcweir } 1031*cdf0e10cSrcweir 1032*cdf0e10cSrcweir if( g_failure ) 1033*cdf0e10cSrcweir exit(2); 1034*cdf0e10cSrcweir } 1035*cdf0e10cSrcweir 1036*cdf0e10cSrcweir } // namespace 1037*cdf0e10cSrcweir 1038*cdf0e10cSrcweir void Main() 1039*cdf0e10cSrcweir { 1040*cdf0e10cSrcweir TestWindow aWindow; 1041*cdf0e10cSrcweir aWindow.Execute(); 1042*cdf0e10cSrcweir aWindow.SetText( XubString( RTL_CONSTASCII_USTRINGPARAM( "VCL - canvasbitmaptest" ) ) ); 1043*cdf0e10cSrcweir 1044*cdf0e10cSrcweir Application::Execute(); 1045*cdf0e10cSrcweir } 1046*cdf0e10cSrcweir 1047