/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
CPPUNIT_ASSERT_EQUAL_MESSAGE( "Original bitmap size not (200,200)",
Size(200,200), aContainedBmp.GetSizePixel());
CPPUNIT_ASSERT_EQUAL_MESSAGE( "Original bitmap size via API not (200,200)",
sal_Int32(200), xBmp->getSize().Width);
CPPUNIT_ASSERT_EQUAL_MESSAGE( "Original bitmap size via API not (200,200)",
sal_Int32(200), xBmp->getSize().Height);
CPPUNIT_ASSERT_EQUAL_MESSAGE( "alpha state mismatch",
aContainedBmpEx.IsAlpha(), bool(xBmp->hasAlpha()));
CPPUNIT_ASSERT_MESSAGE( "rgb colors are not within [0,1] range",
std::none_of(pRGBStart,pRGBEnd,&rangeCheck));
CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( "First pixel is not white", 1.0, pRGBStart[0].Red, 1E-12);
CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( "First pixel is not white", 1.0, pRGBStart[0].Green, 1E-12);
CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( "First pixel is not white", 1.0, pRGBStart[0].Blue, 1E-12);
CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( "Second pixel is not opaque", 1.0, pARGBStart[1].Alpha, 1E-12); if( aContainedBmpEx.IsAlpha() )
{
CPPUNIT_ASSERT_EQUAL_MESSAGE( "First pixel is not fully transparent",
0.0, pARGBStart[0].Alpha);
}
CPPUNIT_ASSERT_EQUAL_MESSAGE( "Second pixel is not black",
0.0, pRGBStart[1].Red);
CPPUNIT_ASSERT_EQUAL_MESSAGE( "Second pixel is not black",
0.0, pRGBStart[1].Green);
CPPUNIT_ASSERT_EQUAL_MESSAGE( "Second pixel is not black",
0.0, pRGBStart[1].Blue);
if( nOriginalDepth > 8 )
{ const Color aCol(COL_GREEN);
CPPUNIT_ASSERT_EQUAL_MESSAGE( "Sixth pixel is not green (red component)",
vcl::unotools::toDoubleColor(aCol.GetRed()), pRGBStart[5].Red);
CPPUNIT_ASSERT_EQUAL_MESSAGE( "Sixth pixel is not green (green component)",
vcl::unotools::toDoubleColor(aCol.GetGreen()), pRGBStart[5].Green);
CPPUNIT_ASSERT_EQUAL_MESSAGE( "Sixth pixel is not green (blue component)",
vcl::unotools::toDoubleColor(aCol.GetBlue()), pRGBStart[5].Blue);
} elseif( nDepth <= 8 )
{
uno::Reference<rendering::XBitmapPalette> xPal = xBmp->getPalette();
CPPUNIT_ASSERT_MESSAGE( "8bit or less: missing palette",
xPal.is());
CPPUNIT_ASSERT_EQUAL_MESSAGE( "Palette incorrect entry count", static_cast<sal_Int32>(1 << nOriginalDepth), xPal->getNumberOfEntries());
uno::Sequence<double> aIndex;
CPPUNIT_ASSERT_MESSAGE( "Palette is not read-only",
!xPal->setIndex(aIndex,true,0));
CPPUNIT_ASSERT_MESSAGE( "Palette entry 0 is not opaque",
xPal->getIndex(aIndex,0));
CPPUNIT_ASSERT_MESSAGE( "Palette has no valid color space",
xPal->getColorSpace().is());
}
CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( "150th pixel is not white", 1.0, pRGBStart[150].Red, 1E-12);
CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( "150th pixel is not white", 1.0, pRGBStart[150].Green, 1E-12);
CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( "150th pixel is not white", 1.0, pRGBStart[150].Blue, 1E-12);
// XBitmapPalette virtual sal_Int32 SAL_CALL getNumberOfEntries() override
{
CPPUNIT_ASSERT_MESSAGE( "Got palette getNumberOfEntries interface call without handing out palette",
getPalette().is() );
return 255;
}
virtual sal_Bool SAL_CALL getIndex( uno::Sequence< double >& entry,
::sal_Int32 nIndex ) override
{
CPPUNIT_ASSERT_MESSAGE( "Got palette getIndex interface call without handing out palette",
getPalette().is() );
CPPUNIT_ASSERT_MESSAGE( "getIndex: index out of range",
nIndex >= 0 );
CPPUNIT_ASSERT_MESSAGE( "getIndex: index out of range",
nIndex < 256 );
entry = colorToStdColorSpaceSequence(
Color(sal_uInt8(nIndex),
sal_uInt8(nIndex),
sal_uInt8(nIndex)) );
returntrue; // no palette transparency here.
}
virtual sal_Bool SAL_CALL setIndex( const uno::Sequence< double >&,
sal_Bool,
::sal_Int32 nIndex ) override
{
CPPUNIT_ASSERT_MESSAGE( "Got palette setIndex interface call without handing out palette",
getPalette().is());
CPPUNIT_ASSERT_MESSAGE( "setIndex: index out of range",
nIndex >= 0);
CPPUNIT_ASSERT_MESSAGE( "setIndex: index out of range",
nIndex < 256); returnfalse;
}
virtual uno::Reference< rendering::XColorSpace > SAL_CALL getColorSpace( ) override
{ // this is the method from XBitmapPalette. Return palette color // space here static uno::Reference<rendering::XColorSpace> aColorSpace =
vcl::unotools::createStandardColorSpace(); return aColorSpace;
}
uno::Reference< rendering::XIntegerReadOnlyBitmap > xTestBmp( new TestBitmap( geometry::IntegerSize2D(10,10), true ));
BitmapEx aBmp = vcl::unotools::bitmapExFromXBitmap(xTestBmp);
CPPUNIT_ASSERT_MESSAGE( "Palette bitmap is alpha",
!aBmp.IsAlpha());
CPPUNIT_ASSERT_EQUAL_MESSAGE( "Bitmap does not have size (10,10)",
Size(10,10), aBmp.GetSizePixel());
CPPUNIT_ASSERT_EQUAL_MESSAGE( "Bitmap does not have the expected pixel format",
vcl::PixelFormat::N8_BPP, aBmp.getPixelFormat());
{
Bitmap aBitmap = aBmp.GetBitmap();
BitmapScopedReadAccess pBmpAcc(aBitmap);
CPPUNIT_ASSERT_MESSAGE( "Bitmap has invalid BitmapReadAccess",
pBmpAcc );
xTestBmp.set( new TestBitmap( geometry::IntegerSize2D(10,10), false ));
aBmp = vcl::unotools::bitmapExFromXBitmap(xTestBmp);
CPPUNIT_ASSERT_MESSAGE( "Palette bitmap has no alpha",
aBmp.IsAlpha());
CPPUNIT_ASSERT_EQUAL_MESSAGE( "Bitmap does not have size (10,10)",
Size(10,10), aBmp.GetSizePixel());
CPPUNIT_ASSERT_EQUAL_MESSAGE( "Bitmap does not have the expected pixel format",
vcl::PixelFormat::N24_BPP, aBmp.getPixelFormat());
{
Bitmap aBitmap = aBmp.GetBitmap();
BitmapScopedReadAccess pBmpAcc(aBitmap);
AlphaMask aBitmapAlpha = aBmp.GetAlphaMask();
BitmapScopedReadAccess pAlphaAcc(aBitmapAlpha);
CPPUNIT_ASSERT_MESSAGE( "Bitmap has invalid BitmapReadAccess",
pBmpAcc);
CPPUNIT_ASSERT_MESSAGE( "Bitmap has invalid alpha BitmapReadAccess",
pAlphaAcc);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.