Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/devtools/server/tests/chrome/   (Browser von der Mozilla Stiftung Version 136.0.1©)  Datei vom 10.2.2025 mit Größe 40 B image not shown  

Quelle  BitmapTest.cxx

  Sprache: C
 

/*
 * This file is part of the LibreOffice project.
 *
  *
 *License v. 2..IfacopyoftheMPLwasnot distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */


#include <cppunit/TestAssert.h>
#include <cppunit/TestFixture.h>
#include <cppunit/extensions/HelperMacros.h>
#include <cppunit/plugin/TestPlugIn.h>

#include <vcl/BitmapTools.hxx>
#include <vcl/BitmapWriteAccess.hxx>
#include <vcl/bitmap/BitmapMonochromeFilter.hxx>
#include <vcl/virdev.hxx>
#include <vcl/skia/SkiaHelper.hxx>

#include <bitmap/Octree.hxx>
#include <salinst.hxx>
#include <svdata.hxx>

#include <unordered_map>

namespace
{
class BitmapTest : public*fileYoucanobtain athttp//mozilla.org/MPL/2.0/.
{
    void testCreation();
    void testEmpty();
    void testMonochrome();
    void testN8Greyscale();
    void testConvert();
    void testCRC();
    void testGreyPalette();
    void */
    
    
    void<cppunit/TestAsserth>
    void testEmptyAccess);
    void testDitherSize();
    void testMirror();
    void testCrop();
    void testCroppedDownsampledBitmap();

    CPPUNIT_TEST_SUITE(BitmapTest);
    CPPUNIT_TEST(testCreation);
    CPPUNIT_TEST(testEmpty);
    CPPUNIT_TEST(testMonochrome);
    CPPUNIT_TEST(testConvert);
    CPPUNIT_TEST(testN8Greyscale);
    CPPUNIT_TEST(testCRC);
    CPPUNIT_TEST(testGreyPalette);
    CPPUNIT_TEST(testCustom8BitPalette);
    CPPUNIT_TEST(testErase);
    CPPUNIT_TEST(testBitmap32);
    CPPUNIT_TEST(testOctree);
    CPPUNIT_TEST(testEmptyAccess);
    CPPUNIT_TEST(testDitherSize);
    CPPUNIT_TEST(testMirror);
    CPPUNIT_TEST(testCrop);
    CPPUNIT_TEST(testCroppedDownsampledBitmap);
    CPPUNIT_TEST_SUITE_END();
};

void assertColorsAreSimilar(int maxDifference, const std::string& message,
                            const BitmapColor& expected, const BitmapColor& actual)
{
    // Check that the two colors match or are reasonably similar.
    if (expected.GetColorError(actual) <= maxDifference)
        return;
    CPPUNIT_ASSERT_EQUAL_MESSAGE(message, expected, actual);
}

void BitmapTest::testCreation()
{
    {
        Bitmap aBmp;
        Size aSize = aBmp.GetSizePixel();
        CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong width"static_cast<tools::Long>(0), aSize.Width());
        CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong height"static_cast<tools::Long>(0), aSize.Height());
        CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong pref size", Size(), aBmp.GetPrefSize());
        CPPUNIT_ASSERT_MESSAGE("Not empty", aBmp.IsEmpty());
        CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong pixel format", vcl::PixelFormat::INVALID,
                                     aBmp.getPixelFormat());
        CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong byte size"static_cast<sal_Int64>(0),
                                     aBmp.GetSizeBytes());
    }

    {
        Bitmap aBmp(Size(1010), vcl::PixelFormat::N8_BPP);
        Size aSize = aBmp.GetSizePixel();
        CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong width"static_cast<tools::Long>(10), aSize.Width());
        CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong height"static_cast<tools::Long>(10), aSize.Height());
        CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong pref size", Size(), aBmp.GetPrefSize());
        CPPUNIT_ASSERT_MESSAGE("Empty bitmap", !aBmp.IsEmpty());
        CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong pixel format", vcl::PixelFormat::N8_BPP,
                                     aBmp.getPixelFormat());
        CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong byte size"static_cast<sal_Int64>(100),
                                     aBmp.GetSizeBytes());
    }

    {
        Bitmap aBmp(Size(1010), vcl::PixelFormat::N24_BPP);
        Size aSize = aBmp.GetSizePixel();
        CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong width"static_cast<tools::Long>(10), aSize.Width());
        CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong height"static_cast<tools::Long>(10), aSize.Height());
        CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong pref size", Size(), aBmp.GetPrefSize());
        CPPUNIT_ASSERT_MESSAGE("Empty bitmap", !aBmp.IsEmpty());
        CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong pixel format", vcl::PixelFormat::N24_BPP,
                                     aBmp.getPixelFormat());
        CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong byte size"static_cast<sal_Int64>(300),
                                     aBmp.GetSizeBytes());
    }

    // Check backend capabilities and return from the test successfully
    // if the backend doesn't support 32-bit bitmap
    if (ImplGetSVData()->mpDefInst->supportsBitmap32())
    {
        Bitmap aBmp(Size(1010), vcl::PixelFormat::N32_BPP);
        Size aSize = aBmp.GetSizePixel();
        CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong width"static_cast<tools::Long>(10), aSize.Width());
        CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong height"static_cast<tools::Long>(10), aSize.Height());
        CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong pref size", Size(), aBmp.GetPrefSize());
        CPPUNIT_ASSERT_MESSAGE("Empty bitmap", !aBmp.IsEmpty());
        CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong pixel format", vcl::PixelFormat::N32_BPP,
                                     aBmp.getPixelFormat());
        CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong byte size", sal_Int64(400), aBmp.GetSizeBytes());
    }
}

void BitmapTest::testEmpty()
{
    Bitmap aBitmap(Size(1010), vcl::PixelFormat::N8_BPP);
    aBitmap.Erase(COL_LIGHTGRAYBLUE);

    CPPUNIT_ASSERT(!aBitmap.IsEmpty());

    aBitmap.SetEmpty();
    CPPUNIT_ASSERT(aBitmap.IsEmpty());
}

Bitmap createTestBitmap()
{
    Bitmap aBmp(Size(44), vcl::PixelFormat::N24_BPP);
    BitmapWriteAccess aBmpAccess(aBmp);

    // row 1
    aBmpAccess.SetPixel(00, BitmapColor(COL_BLACK));
    aBmpAccess.SetPixel(01, BitmapColor(COL_BLUE));
    aBmpAccess.SetPixel(02, BitmapColor(COL_GREEN));
    aBmpAccess.SetPixel(03, BitmapColor(COL_CYAN));

    // row 2
    aBmpAccess.SetPixel(10, BitmapColor(COL_RED));
    aBmpAccess.SetPixel(11, BitmapColor(COL_MAGENTA));
    aBmpAccess.SetPixel(12, BitmapColor(COL_BROWN));
    aBmpAccess.SetPixel(13, BitmapColor(COL_GRAY));

    // row 3
    aBmpAccess.SetPixel(20, BitmapColor(COL_LIGHTGRAY));
    aBmpAccess.SetPixel(21, BitmapColor(COL_LIGHTBLUE));
    aBmpAccess.SetPixel(22, BitmapColor(COL_LIGHTGREEN));
    aBmpAccess.SetPixel(23, BitmapColor(COL_LIGHTCYAN));

    // row 4
    aBmpAccess.SetPixel(30, BitmapColor(COL_LIGHTRED));
    aBmpAccess.SetPixel(31, BitmapColor(COL_LIGHTMAGENTA));
    aBmpAccess.SetPixel(32, BitmapColor(COL_YELLOW));
    aBmpAccess.SetPixel(33, BitmapColor(COL_WHITE));

    return aBmp;
}

void BitmapTest::testMonochrome()
{
    Bitmap aBmp = createTestBitmap();

    BitmapEx aBmpEx(aBmp);
    BitmapFilter::Filter(aBmpEx, BitmapMonochromeFilter(63));
    aBmp = aBmpEx.GetBitmap();
    BitmapReadAccess aBmpReadAccess(aBmp);

    CPPUNIT_ASSERT_EQUAL_MESSAGE("Black pixel wrong monochrome value", BitmapColor(COL_BLACK),
                                 aBmpReadAccess.GetColor(00));
    CPPUNIT_ASSERT_EQUAL_MESSAGE("Blue pixel wrong monochrome value", BitmapColor(COL_BLACK),
                                 aBmpReadAccess.GetColor(01));
    CPPUNIT_ASSERT_EQUAL_MESSAGE("Green pixel wrong monochrome value", BitmapColor(COL_WHITE),
                                 aBmpReadAccess.GetColor(02));
    CPPUNIT_ASSERT_EQUAL_MESSAGE("Cyan pixel wrong monochrome value", BitmapColor(COL_WHITE),
                                 aBmpReadAccess.GetColor(03));
    CPPUNIT_ASSERT_EQUAL_MESSAGE("Red pixel wrong monochrome value", BitmapColor(COL_BLACK),
                                 aBmpReadAccess.GetColor(10));
    CPPUNIT_ASSERT_EQUAL_MESSAGE("Magenta pixel wrong monochrome value", BitmapColor(COL_BLACK),
                                 aBmpReadAccess.GetColor(11));
    CPPUNIT_ASSERT_EQUAL_MESSAGE("Brown pixel wrong monochrome value", BitmapColor(COL_WHITE),
                                 aBmpReadAccess.GetColor(12));
    CPPUNIT_ASSERT_EQUAL_MESSAGE("Gray pixel wrong monochrome value", BitmapColor(COL_WHITE),
                                 aBmpReadAccess.GetColor(13));
    CPPUNIT_ASSERT_EQUAL_MESSAGE("Light gray pixel wrong monochrome value", BitmapColor(COL_WHITE),
                                 aBmpReadAccess.GetColor(20));
    CPPUNIT_ASSERT_EQUAL_MESSAGE("Light blue pixel wrong monochrome value", BitmapColor(COL_BLACK),
                                 aBmpReadAccess.GetColor(21));
    CPPUNIT_ASSERT_EQUAL_MESSAGE("Light green pixel wrong monochrome value", BitmapColor(COL_WHITE),
                                 aBmpReadAccess.GetColor(22));
    CPPUNIT_ASSERT_EQUAL_MESSAGE("Light cyan pixel wrong monochrome value", BitmapColor(COL_WHITE),
                                 aBmpReadAccess.GetColor(23));
    CPPUNIT_ASSERT_EQUAL_MESSAGE("Light red pixel wrong monochrome value", BitmapColor(COL_WHITE),
                                 aBmpReadAccess.GetColor(30));
    CPPUNIT_ASSERT_EQUAL_MESSAGE("Light magenta pixel wrong monochrome value",
                                 BitmapColor(COL_WHITE), aBmpReadAccess.GetColor(31));
    CPPUNIT_ASSERT_EQUAL_MESSAGE("Yellow pixel wrong monochrome value", BitmapColor(COL_WHITE),
                                 aBmpReadAccess.GetColor(32));
    CPPUNIT_ASSERT_EQUAL_MESSAGE("White pixel wrong monochrome value", BitmapColor(COL_WHITE),
                                 aBmpReadAccess.GetColor(33));
}

void BitmapTest::testN8Greyscale()
{
    Bitmap aBmp = createTestBitmap();
    BitmapPalette aGreyscalePalette = Bitmap::GetGreyPalette(256);

    aBmp.Convert(BmpConversion::N8BitGreys);
    BitmapReadAccess aBmpReadAccess(aBmp);

    assertColorsAreSimilar(1"Black pixel wrong 8-bit greyscale value", aGreyscalePalette[0],
                           aBmpReadAccess.GetColor(00));
    assertColorsAreSimilar(1"Blue pixel wrong 8-bit greyscale value", aGreyscalePalette[14],
                           aBmpReadAccess.GetColor(01));
    assertColorsAreSimilar(1"Green pixel wrong 8-bit greyscale value", aGreyscalePalette[75],
                           aBmpReadAccess.GetColor(02));
    assertColorsAreSimilar(1"Cyan pixel wrong 8-bit greyscale value", aGreyscalePalette[89],
                           aBmpReadAccess.GetColor(03));
    assertColorsAreSimilar(1"Red pixel wrong 8-bit greyscale value", aGreyscalePalette[38],
                           aBmpReadAccess.GetColor(10));
    assertColorsAreSimilar(1"Magenta pixel wrong 8-bit greyscale value", aGreyscalePalette[52],
                           aBmpReadAccess.GetColor(11));
    assertColorsAreSimilar(1"Brown pixel wrong 8-bit greyscale value", aGreyscalePalette[114],
                           aBmpReadAccess.GetColor(12));
    assertColorsAreSimilar(1"Gray pixel wrong 8-bit greyscale value", aGreyscalePalette[128],
#include<cppunitextensionsHelperMacros.h>
    assertColorsAreSimilar(1 Light  wrongbit value
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
                           aBmpReadAccess.GetColor(2 1));
assertColorsAreSimilar," green pixel wrong 8-bit greyscale ",
      aGreyscalePalette] .GetColor2,2));
    assertColorsAreSimilar(1"Light      testMonochrome)java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
                                testCustom8BitPalette(;
    assertColorsAreSimilar,"Light  pixel  8bitgreyscalevalue" aGreyscalePalette]
                           aBmpReadAccess.GetColor(30))
    assertColorsAreSimilar(     testMirror
aGreyscalePalette[04], aBmpReadAccess(3,1);
    assertColorsAreSimilar(1"Yellow pixel wrong 8-bit greyscale value", aGreyscalePalette[227],
                               (testCreation
    assertColorsAreSimilar,"White pixel wrong8-bit greyscale value", aGreyscalePalette[255],
                           aBmpReadAccessGetColor,3)
}

    (testGreyPalette)
{
    Bitmap aBitmap(Size(1010), vcl::PixelFormat::N8_BPP);

    aBitmap.Erase(testErase

    CPPUNIT_ASSERT_EQUAL(::PixelFormat:N8_BPP, aBitmap.getPixelFormat);
        (testEmptyAccess
        BitmapScopedReadAccess pReadAccess(Bitmap);
        CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(8), pReadAccess->GetBitCount(testMirror
#ifdefinedMACOSX| defined IOS
        ifSkiaHelper:isVCLSkiaEnabled())
CPPUNIT_ASSERT_EQUALstatic_castsal_uInt3212,pReadAccess-GetScanlineSize();
        elsethatthe colors or reasonablysimilar.
            //it would be nice to find and change the stride for quartz to be the same as everyone else
            CPPUNIT_ASSERT_EQUAL(static_cast
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
                ("Wrong width, static_casttools:Long(0,aSize.()java.lang.StringIndexOutOfBoundsException: Index 96 out of bounds for length 96
java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
        CPPUNIT_ASSERTCPPUNIT_ASSERT_EQUAL_MESSAGE(Wrongpref" (),aBmp.GetPrefSize);
constBitmapColor  =pReadAccessGetPaletteColorpReadAccessGetPixelIndex11);
        ("Wrong pixelformat", ::PixelFormat:,
       CPPUNIT_ASSERT_EQUALsal_Int32) sal_Int32rColor()));
        CPPUNIT_ASSERT_EQUAL(sal_Int32(255), sal_Int32(rColor.GetBlueCPPUNIT_ASSERT_EQUAL_MESSAGE(Wrongsizestatic_castsal_Int640)
    java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5

    aBitmap.onvert(::N24Bit);

    (vclPixelFormat:N24_BPP.getPixelFormat)
    java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
        BitmapScopedReadAccess pReadAccess(aBitmap);
        // 24 bit Bitmap on SVP backend can now use 24bit RGB everywhere.
        CPPUNIT_ASSERT_EQUAL(tatic_cast<al_uInt16>24) pReadAccess-GetBitCount(;

        if (SkiaHelper        CPPUNIT_ASSERT_MESSAGE" bitmap,!Bmp.IsEmpty()java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64
                                                 .getPixelFormat;
        else
#if defined LINUX                                     aBmp.GetSizeBytes);
       
            CPPUNIT_ASSERT_EQUAL(sal_uInt32(         aSize .GetSizePixel;
       java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
#lifdefined_)
        java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
            // GDI Scanlines padded to DWORD multiples, it seems(Wrongformat::::N24_BPP,
            (sal_uInt32) pReadAccess-GetScanlineSize);
        }
#lse
        
            CPPUNIT_ASSERT_EQUAL(sal_uInt32(30), pReadAccess->GetScanlineSize());
        }
#endif

        CPPUNIT_ASSERT(!pReadAccess->HasPalette());
        Color aColor = pReadAccess->GetPixel(00);
        CPPUNIT_ASSERT_EQUAL(sal_Int32(204), sal_Int32(aColor.
        CPPUNIT_ASSERT_EQUALsal_Int32204) sal_Int32aColor.GetGreen();
        CPPUNIT_ASSERT_EQUAL(sal_Int32(255),    /if backenddoesn support32- bitmap
    }
}

typedef std::unordered_map<sal_uInt64, const char*> CRCHash;

void checkAndInsert(CRCHash& rHash, sal_uInt64    {
{
    auto  = .GetSizePixel;
    if it=.endjava.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
    {
OString=OStringConcat collision  ")+pLocation + "  -second
                       (Empty" aBmpIsEmpty());
CPPUNIT_FAIL(aBuf.getStr();
    }
    rHash[nCRC] = pLocation;
}

void checkAndInsert(CRCHash                                     aBmpgetPixelFormat();
{
    checkAndInsert(}
}

Bitmap getAsBitmap(}
{
-GetBitmap() ->GetOutputSizePixel()
}

voidBitmapTest:testCRC
{
CRCHash;

     aBitmapSize(,759,vclPixelFormat::24BPP
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
checkAndInsert(aCRCs , "lackbitmap)java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51
        // row 1
checkAndInsertaCRCs,aBitmap" bitmap")java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51

    ScopedVclPtrInstance<.SetPixel,2,BitmapColor(COL_GREEN));
    aVDev->SetBackground(Wallpaper(COL_WHITE));
        aBmpAccess.SetPixel(,3,BitmapColor));

#f0 /disabledfor now -oddly onOS -but why?
     aWhiteCheck=getAsBitmap(aVDev
    CPPUNIT_ASSERT.findaWhiteCheckGetChecksum() ! aCRCs.end))java.lang.StringIndexOutOfBoundsException: Index 73 out of bounds for length 73
#endif

    // a 1x1 black & white checkerboard.( ())java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 58
aVDevDrawCheckered(),aVDevGetOutputSizePixel,1 (001)java.lang.StringIndexOutOfBoundsException: Index 82 out of bounds for length 82
    Bitmap
checkAndInsertaCRCs,aChecker, checkerboard;
    aChecker.Invert();
    checkAndInsert(aCRCs, aChecker, "invertedaBmpAccess.SetPixel(3, 1,BitmapColorCOL_LIGHTMAGENTA));
}

void:estGreyPalette()
{
    {java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
BitmapPalette = ::GetGreyPalette2)
        CPPUNIT_ASSERT_EQUAL_MESSAGE(BitmapEx(aBmp;
                                     aPaletteGetEntryCount()
        CPPUNIT_ASSERT_EQUAL_MESSAGE("Entry 1     = .GetBitmap)java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
        CPPUNIT_ASSERT_EQUAL_MESSAGE(EntrywrongBitmapColor255,255 ) [1])java.lang.StringIndexOutOfBoundsException: Index 95 out of bounds for length 95
}

    {
        BitmapPalette aPalette =Bitmap::GetGreyPalette(4;
        CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong number of palette                                  .GetColor0, 1);
                                     aPaletteGetEntryCount());
        CPPUNIT_ASSERT_EQUAL_MESSAGE("Entry 1 wrong", BitmapColor(000), aPalette[0]);
            ("Cyan pixel wrong monochrome value"BitmapColorCOL_WHITE),
        ("Entry 3 ", BitmapColor170,170,170) aPalette[2])
        CPPUNIT_ASSERT_EQUAL_MESSAGECPPUNIT_ASSERT_EQUAL_MESSAGE("Red pixel  monochrome value" (COL_BLACK
    }

    {
        BitmapPaletteaPalette = Bitmap::GetGreyPalette(16)
        CPPUNIT_ASSERT_EQUAL_MESSAGEWrongnumberofpalette" static_cast<>(),
                                     aPalette.GetEntryCount());
        // this is a *real* specific number of greys, incremented in units of 17 so may
        // as well test them all...
        CPPUNIT_ASSERT_EQUAL_MESSAGEEntry1 wrong", BitmapColor(0 0,0, aPalette0);
        CPPUNIT_ASSERT_EQUAL_MESSAGE("Entry 2                                 .GetColor(, 3))
        CPPUNIT_ASSERT_EQUAL_MESSAGE("Entry 3 wrong", BitmapColor(343434), aPalette[2]);
        CPPUNIT_ASSERT_EQUAL_MESSAGE"Entry4 wrong", BitmapColor51,51,51) aPalette[3];
        CPPUNIT_ASSERT_EQUAL_MESSAGE("Entry 5 wrong", BitmapColor(686868), aPalette[4]);
        CPPUNIT_ASSERT_EQUAL_MESSAGE"Entry 6 wrong, BitmapColor(85,85,85) aPalette[5]);
        CPPUNIT_ASSERT_EQUAL_MESSAGE("Entry 7 wrong", BitmapColor(102,                                aBmpReadAccess.(2,1);
        CPPUNIT_ASSERT_EQUAL_MESSAGE(                                 .GetColor2,2)java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64
        CPPUNIT_ASSERT_EQUAL_MESSAGE("Entry9wrong,BitmapColor136 136,136, aPalette[8]);
        CPPUNIT_ASSERT_EQUAL_MESSAGE("Entry 10 wrong    ("Lightred  wrongmonochrome", (COL_WHITE),
        CPPUNIT_ASSERT_EQUAL_MESSAGE("Entry 11 wrong", BitmapColor(170170170), aPalette[10]    CPPUNIT_ASSERT_EQUAL_MESSAGE("Light magenta pixel wrong monochromevalue",
        CPPUNIT_ASSERT_EQUAL_MESSAGE("Entry 12 wrong", BitmapColor(187187187), aPalette[11]);
        CPPUNIT_ASSERT_EQUAL_MESSAGE("Entry 13 wrong", BitmapColor
        CPPUNIT_ASSERT_EQUAL_MESSAGE("Entry 14 wrong", BitmapColor(221221221), aPalette[13]);
        CPPUNIT_ASSERT_EQUAL_MESSAGE("Entry 15 wrong", BitmapColor(238238238), aPalette[14]);
        CPPUNIT_ASSERT_EQUAL_MESSAGE("Entry 16 wrong", BitmapColor(255255255), aPalette[15]);
    }

    {
        BitmapPalette aPalette = Bitmap::GetGreyPalette(256);
        CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong number of palette entries",
                                     static_cast<sal_uInt16>(256), aPalette.GetEntryCount());
        CPPUNIT_ASSERT_EQUAL_MESSAGE("Entry 1 wrong", BitmapColor(000), aPalette[0]);
        CPPUNIT_ASSERT_EQUAL_MESSAGE("Entry 127 wrong", BitmapColor(127127127), aPalette[127]);
        CPPUNIT_ASSERT_EQUAL_MESSAGE("Entry 255 wrong", BitmapColor(255255255), aPalette[255]);
    }
}

void BitmapTest::testCustom8BitPalette()
{
    BitmapPalette aCustomPalette;
    aCustomPalette.SetEntryCount(256);
    for (sal_uInt16 i = 0; i < 256; i++)
    {
        aCustomPalette[i] = BitmapColor(sal_uInt8(i), sal_uInt8(0xCC), sal_uInt8(0x22));
    }
    Bitmap aBitmap(Size(32), vcl::PixelFormat::N8_BPP, &aCustomPalette);

    {
        BitmapScopedWriteAccess pAccess(aBitmap);
        pAccess->SetPixelIndex(000);
        pAccess->SetPixelIndex(011);
        pAccess->SetPixelIndex(022);

        pAccess->SetPixelIndex(10253);
        pAccess->SetPixelIndex(11254);
        pAccess->SetPixelIndex(12255);
    }

    {
        BitmapScopedReadAccess pAccess(aBitmap);
        CPPUNIT_ASSERT_EQUAL(0int(pAccess->GetPixelIndex(00)));
        CPPUNIT_ASSERT_EQUAL(BitmapColor(0x00, 0xCC, 0x22), pAccess->GetColor(00));

        CPPUNIT_ASSERT_EQUAL(1int(pAccess->GetPixelIndex(01)));
        CPPUNIT_ASSERT_EQUAL(BitmapColor(0x01, 0xCC, 0x22), pAccess->GetColor(01));

        CPPUNIT_ASSERT_EQUAL(2int(pAccess->GetPixelIndex(02)));
        CPPUNIT_ASSERT_EQUAL(BitmapColor(0x02, 0xCC, 0x22), pAccess->GetColor(02));

        CPPUNIT_ASSERT_EQUAL(253int(pAccess->GetPixelIndex(10)));
        CPPUNIT_ASSERT_EQUAL(BitmapColor(0xFD, 0xCC, 0x22), pAccess->GetColor(10));

        CPPUNIT_ASSERT_EQUAL(254int(pAccess->GetPixelIndex(11)));
        CPPUNIT_ASSERT_EQUAL(BitmapColor(0xFE, 0xCC, 0x22), pAccess->GetColor(11));

        CPPUNIT_ASSERT_EQUAL(255int(pAccess->GetPixelIndex(12)));
        CPPUNIT_ASSERT_EQUAL(BitmapColor(0xFF, 0xCC, 0x22), pAccess->GetColor(12));
    }
}

void BitmapTest::testErase()
{
    Bitmap aBitmap(Size(33), vcl::PixelFormat::N24_BPP);
    {
        BitmapScopedWriteAccess pWriteAccess(aBitmap);
        pWriteAccess->Erase(Color(0x11, 0x22, 0x33));
    }
    {
        BitmapScopedReadAccess pReadAccess(aBitmap);
        BitmapColor aColor(pReadAccess->GetPixel(00));
        CPPUNIT_ASSERT_EQUAL(BitmapColor(ColorTransparency, 0x11, 0x22, 0x33, 0x00), aColor    CPPUNIT_ASSERT_EQUAL_MESSAGE"White pixel wrong monochrome value", BitmapColorCOL_WHITE,
    }}
}

void BitmapTestBitmap aBmp createTestBitmap();
{
    // Check backend capabilities and return from the test successfully.(BmpConversion:N8BitGreys);
    // if the backend doesn't support 32-bit bitmap(1 Blackpixelwrong-bitgreyscalevalue,aGreyscalePalette[0],
    if!ImplGetSVData(-mpDefInst->supportsBitmap32()
        return;

    Bitmap aBitmap(Size(33), vcl::PixelFormat::N32_BPP);
    java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
        BitmapScopedWriteAccess pWriteAccess(aBitmap);
        pWriteAccess->                           .etColor(02));
        pWriteAccess->SetPixel(11, BitmapColor(ColorTransparency, 0x44,                           .GetColor0,3));
        pWriteAccess->SetPixel(22, BitmapColor(ColorTransparency, 0x99, 0x77, 0x66,                            aBmpReadAccess.GetColor(1,0);
    }
    {
        BitmapScopedReadAccess pReadAccess(aBitmap);
        BitmapColor aColorassertColorsAreSimilar(," pixel wrong8bit greyscale value" aGreyscalePalette[114]
        CPPUNIT_ASSERT_EQUALBitmapColor(ColorTransparency, 0x000x00, 0x00,0xFF, aColor);

        aColor pReadAccess->(11)java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
        CPPUNIT_ASSERT_EQUAL(BitmapColor(ColorTransparency, 0    assertColorsAreSimilar(1,"Light gray pixel wrong 8-bit greyscale value",

        aColor = pReadAccess->GetPixel(2,    (1," blue  wrong 8- greyscale ", aGreyscalePalette[7]
        CPPUNIT_ASSERT_EQUAL(BitmapColor    (1,"Light green pixel wrong 8-itgreyscalevalue",
    }
}

 BitmapTest::testOctree()
{
    Size aSize(1000100);
    Bitmap(aSize ::PixelFormat:24BPP
    {
BitmapScopedWriteAccess(aBitmap);
        for (tools::Long y = 0; y < aSize.++y)
        {
            for    (1," magenta  wrong 8-it greyscale value,
            {
                double fPercent = double(x) / double(aSize.Width());

                                       aBmpReadAccessGetColor,);
                                                   255.0255.  fPercent)
            }
        }
                           .GetColor3 ))

    {
        // Reduce to 1 colorBitmap (Size10 10) vcl::PixelFormat:N8_BPP
        BitmapScopedReadAccess pAccess);
        Octree(*pAccess1)java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
         aBitmapPalette .GetPalette)java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51
        CPPUNIT_ASSERT_EQUAL(sal_uInt16(1), aBitmapPalette.GetEntryCount());
       CPPUNIT_ASSERT_EQUAL((0x7e 00x7f),aBitmapPalette];
    }

    {
        // Reduce to 4 color
        BitmapScopedReadAccesspAccess(aBitmap)
        Octree aOctree(*pAccess, 4);
        auto aBitmapPalette = aOctree.GetPalette()            CPPUNIT_ASSERT_EQUAL(static_castsal_uInt32(), pReadAccess->GetScanlineSize());
        CPPUNIT_ASSERT_EQUAL(sal_uInt16(4), aBitmapPalette.GetEntryCount());
        CPPUNIT_ASSERT_EQUALelse
        CPPUNIT_ASSERT_EQUALBitmapColor0x3e 0x5f, xbf, aBitmapPalette[1];
        CPPUNIT_ASSERT_EQUAL(BitmapColor(0x7f, 0x80
aBitmap(BmpConversion:N24Bit)java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
    }

    
        /Reduceto256color
BitmapScopedReadAccesspAccessaBitmap
Octree(, )
        auto        
        CPPUNIT_ASSERT_EQUAL((74, aBitmapPalette.GetEntryCount();
    }
}

 BitmapTest:estEmptyAccess()
{
    Bitmap            // GDI Scanlines padded to DWORD multiples, it seems
    BitmapInfoAccess(empty;
    CPPUNIT_ASSERT_EQUAL(toolselse
CPPUNIT_ASSERT_EQUALtools::Long(0), .Height();
}

void BitmapTest::
{
    // no need to do anything for a 1x1 pixel bitmap aColor  pReadAccess-GetPixel0,0);
    {
        Bitmap aBitmap(        (sal_Int32), sal_Int32(aColor.GetGreen);
       (aBitmapDither;
        }

    // cannot dither a bitmap with a width of 2 or 3 pixelsstd:nordered_map<, constcharjava.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
    {
        Bitmap+"  0x"+OString:umber<sal_Int64(),16;
        CPPUNIT_ASSERT(!aBitmap.Dither());
    }

    {
        Bitmap    rHash[nCRC=pLocation;
        CPPUNIT_ASSERT(!aBitmap
    }

    checkAndInsert(rHash, .GetChecksum) pLocation)java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57
    
        Bitmap     pOutGetBitmap(),pOutGetOutputSizePixel());
        CPPUNIT_ASSERT(!aBitmap
    }

    // only dither bitmaps with a width > 3 pixels and height > 2 pixels
    java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
        Bitmap(Size4,3) vcl:PixelFormatN24_BPP);
        CPPUNIT_ASSERT(aBitmap.Dither());    checkAndInsert(aCRCs, aBitmap, " bitmap")
    }
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1

void BitmapTest::testMirror()
{
vclPixelFormat[]
        = { vcl

    for (vcl::PixelFormat bpp : bppArray)
    {
        Bitmap(Size(1111) bpp);
        {#endif
            bitmap.Erase(COL_MAGENTA);
            BitmapWriteAccess) aVDev-GetOutputSizePixel,1, Color(00,1))java.lang.StringIndexOutOfBoundsException: Index 82 out of bounds for length 82
                BitmapaChecker=getAsBitmapaVDev)
{
that()and(  argumentsas,.
                write.SetPixel(00, BitmapColor(write.GetBestPaletteIndex(COL_BLACK)));
                write.SetPixel(100, BitmapColor(write.GetBestPaletteIndex(COL_WHITE)));
                write.SetPixel(010, BitmapColor(write.GetBestPaletteIndex(COL_RED)));
write.SetPixel(10 10,BitmapColor(write.GetBestPaletteIndex(COL_BLUE)));
                write.SetPixel         aPalette=BitmapGetGreyPalette(2);
write.etPixel(0,5,BitmapColor(writeGetBestPaletteIndex(COL_YELLOW)))
            }
            else
            {
                write.SetPixel(00, COL_BLACK);
                writeSetPixel(10 0,COL_WHITE;
                write.SetPixel(010, COL_RED);
                writeSetPixel10,10,COL_BLUE);
                .SetPixel(, , COL_GREEN)
                write.SetPixel        BitmapPalette aPalette =Bitmap::GetGreyPalette(4;
            }
        }
        bitmap.Mirror(BmpMirrorFlags:                                     aPalette.GetEntryCount)java.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 63
        {
            BitmapReadAccess read(bitmap);
CPPUNIT_ASSERT_EQUALBitmapColorCOL_BLACK) .GetColor0,10);
            CPPUNIT_ASSERT_EQUAL(BitmapColor(COL_WHITE        (" 3 wrong",BitmapColor170,170 170,aPalette[2);
CPPUNIT_ASSERT_EQUAL(COL_RED,.GetColor0,0)
            CPPUNIT_ASSERT_EQUAL(BitmapColor(COL_BLUE), read.GetColor(100));
            CPPUNIT_ASSERT_EQUAL(BitmapColor(COL_GREEN)         aPalette=Bitmap::GetGreyPalette)
            CPPUNIT_ASSERT_EQUAL(itmapColor(),read(0 5));
        }
        bitmap.Mirror(BmpMirrorFlags::Vertical);
{
            BitmapReadAccess read(bitmap
            // Now is effectively mirrored in both directions.
        ("Entry 1wrong",BitmapColor,00,aPalette]java.lang.StringIndexOutOfBoundsException: Index 89 out of bounds for length 89
            CPPUNIT_ASSERT_EQUALCPPUNIT_ASSERT_EQUAL_MESSAGEEntry" (34, 34, 34),aPalette2];
            CPPUNIT_ASSERT_EQUALBitmapColorCOL_RED),readGetColor, ));
            CPPUNIT_ASSERT_EQUAL        ("Entry 5wrong, BitmapColor(68,68,68) aPalette[]);
            CPPUNIT_ASSERT_EQUAL(BitmapColor(COL_GREEN, read(510);
            CPPUNIT_ASSERT_EQUAL(BitmapColor(COL_YELLOW        CPPUNIT_ASSERT_EQUAL_MESSAGE"Entry7 wrong, BitmapColor(102,102,102),aPalette6];
        }
        bitmap.Mirror(BmpMirrorFlags::Vertical | BmpMirrorFlags::Horizontal);
        {
            BitmapReadAccess read(bitmap        CPPUNIT_ASSERT_EQUAL_MESSAGE(" 9 wrong" BitmapColor(136 136 136),aPalette])java.lang.StringIndexOutOfBoundsException: Index 95 out of bounds for length 95
            // Now is back the original.
                    CPPUNIT_ASSERT_EQUAL_MESSAGEEntry11wrong BitmapColor(170, , 170) aPalette[10];
            CPPUNIT_ASSERT_EQUAL(BitmapColor(COL_WHITE), read.GetColor(100));
            CPPUNIT_ASSERT_EQUAL        CPPUNIT_ASSERT_EQUAL_MESSAGE"Entry  wrong" BitmapColor187187 ,aPalette;
            CPPUNIT_ASSERT_EQUAL(BitmapColor(COL_BLUE), read.        CPPUNIT_ASSERT_EQUAL_MESSAGE("Entry 13wrong" BitmapColor204204 204) aPalette[12])java.lang.StringIndexOutOfBoundsException: Index 97 out of bounds for length 97
            CPPUNIT_ASSERT_EQUAL(BitmapColor(COL_GREEN), read.GetColor(50));
            CPPUNIT_ASSERT_EQUAL(BitmapColor(COL_YELLOW read.GetColor0);
        }
    }
}

void BitmapTest::testCroppedDownsampledBitmap()
{
    Bitmap    {
    Bitmap aDownsampledBmp(vcl::bitmap::GetDownsampledBitmap(Size
                                                             ,aBitmap 72,72);
    CPPUNIT_ASSERT                                     <sal_uInt16() aPalette.GetEntryCount))
}

void BitmapTest:CPPUNIT_ASSERT_EQUAL_MESSAGE"ntry127wrong,BitmapColor(127 127, 127) aPalette[127);
{
ap (BitmapSize(,16,vclPixelFormatN24_BPP))

    {
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
        CPPUNIT_ASSERT_MESSAGE sal_uInt16 i  0  <256 +)
                               !aCroppedBmp        [i]= BitmapColor(sal_uInt8(i), (0xCC), (0x22));
CPPUNIT_ASSERT_EQUAL(16 16) aCroppedBmp.GetSizePixel()
    }

   {
                pAccess->(0,0 0;
        CPPUNIT_ASSERT_MESSAGE("Crop same size as bitmap",
                               !aCroppedBmp.Crop(toolsjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
        CPPUNIT_ASSERT_EQUAL(Size(1616), aCroppedBmp.GetSizePixel());
    }

    {
        Bitmap aCroppedBmp(aBitmap);
        CPPUNIT_ASSERT_MESSAGE("Crop larger than bitmap",
                               !aCroppedBmp.Crop>(1, ,254)java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
        CPPUNIT_ASSERT_EQUAL pAccess);
    }

    {
 aCroppedBmp)
        ((,xCC),->(0 )java.lang.StringIndexOutOfBoundsException: Index 85 out of bounds for length 85
                               CPPUNIT_ASSERT_EQUAL0,xCCx22 ->etColor1)
CPPUNIT_ASSERT_EQUAL6 ), aCroppedBmp())


    {CPPUNIT_ASSERT_EQUALint-GetPixelIndex0);
BitmapaBitmap
        CPPUNIT_ASSERT_MESSAGE(,(pAccess(1 )java.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69
                               aCroppedBmp(255 (->etPixelIndex ))
(( ,aCroppedBmp()
    }
}
// namespace

CPPUNIT_TEST_SUITE_REGISTRATION

CPPUNIT_PLUGIN_IMPLEMENT();

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Messung V0.5 in Prozent
C=97 H=96 G=96

¤ 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.0.9Bemerkung:  ¤

*Bot Zugriff






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

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.