1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 #include <osl/diagnose.h>
30 #include <basegfx/point/b2ipoint.hxx>
31 #include <basegfx/vector/b2ivector.hxx>
33 #include <basebmp/scanlineformats.hxx>
34 #include <basebmp/color.hxx>
35 #include <basebmp/bitmapdevice.hxx>
36 #include <basebmp/debug.hxx>
44 static const char* getFormatString( sal_Int32 nScanlineFormat
)
46 switch( nScanlineFormat
)
48 case Format::ONE_BIT_MSB_GREY
:
49 return "ONE_BIT_MSB_GREY";
50 case Format::ONE_BIT_LSB_GREY
:
51 return "ONE_BIT_LSB_GREY";
52 case Format::ONE_BIT_MSB_PAL
:
53 return "ONE_BIT_MSB_PAL";
54 case Format::ONE_BIT_LSB_PAL
:
55 return "ONE_BIT_LSB_PAL";
56 case Format::FOUR_BIT_MSB_GREY
:
57 return "FOUR_BIT_MSB_GREY";
58 case Format::FOUR_BIT_LSB_GREY
:
59 return "FOUR_BIT_LSB_GREY";
60 case Format::FOUR_BIT_MSB_PAL
:
61 return "FOUR_BIT_MSB_PAL";
62 case Format::FOUR_BIT_LSB_PAL
:
63 return "FOUR_BIT_LSB_PAL";
64 case Format::EIGHT_BIT_PAL
:
65 return "EIGHT_BIT_PAL";
66 case Format::EIGHT_BIT_GREY
:
67 return "EIGHT_BIT_GREY";
68 case Format::SIXTEEN_BIT_LSB_TC_MASK
:
69 return "SIXTEEN_BIT_LSB_TC_MASK";
70 case Format::SIXTEEN_BIT_MSB_TC_MASK
:
71 return "SIXTEEN_BIT_MSB_TC_MASK";
72 case Format::TWENTYFOUR_BIT_TC_MASK
:
73 return "TWENTYFOUR_BIT_TC_MASK";
74 case Format::THIRTYTWO_BIT_TC_MASK
:
75 return "THIRTYTWO_BIT_TC_MASK";
82 void debugDump( const BitmapDeviceSharedPtr
& rDevice
,
83 std::ostream
& rOutputStream
)
85 const basegfx::B2IVector
aSize( rDevice
->getSize() );
86 const bool bTopDown( rDevice
->isTopDown() );
87 const sal_Int32
nScanlineFormat( rDevice
->getScanlineFormat() );
90 << "/* basebmp::BitmapDevice content dump */" << std::endl
91 << "/* Width = " << aSize
.getX() << " */" << std::endl
92 << "/* Height = " << aSize
.getY() << " */" << std::endl
93 << "/* TopDown = " << bTopDown
<< " */" << std::endl
94 << "/* Format = " << getFormatString(nScanlineFormat
) << " */" << std::endl
95 << "/* (dumped entries are already mapped RGBA color values) */" << std::endl
98 rOutputStream
<< std::hex
;
99 for( int y
=0; y
<aSize
.getY(); ++y
)
101 for( int x
=0; x
<aSize
.getX(); ++x
)
102 rOutputStream
<< std::setw(8) << (sal_uInt32
)rDevice
->getPixel( basegfx::B2IPoint(x
,y
) ).toInt32() << " ";
103 rOutputStream
<< std::endl
;