update dev300-m58
[ooovba.git] / basebmp / source / debug.cxx
blobfe4d94496c12b65c96626d81cf6064e21f9b47f9
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: debug.cxx,v $
10 * $Revision: 1.8 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #include <osl/diagnose.h>
33 #include <basegfx/point/b2ipoint.hxx>
34 #include <basegfx/vector/b2ivector.hxx>
36 #include <basebmp/scanlineformats.hxx>
37 #include <basebmp/color.hxx>
38 #include <basebmp/bitmapdevice.hxx>
39 #include <basebmp/debug.hxx>
41 #include <iomanip>
43 namespace basebmp
45 namespace
47 static const char* getFormatString( sal_Int32 nScanlineFormat )
49 switch( nScanlineFormat )
51 case Format::ONE_BIT_MSB_GREY:
52 return "ONE_BIT_MSB_GREY";
53 case Format::ONE_BIT_LSB_GREY:
54 return "ONE_BIT_LSB_GREY";
55 case Format::ONE_BIT_MSB_PAL:
56 return "ONE_BIT_MSB_PAL";
57 case Format::ONE_BIT_LSB_PAL:
58 return "ONE_BIT_LSB_PAL";
59 case Format::FOUR_BIT_MSB_GREY:
60 return "FOUR_BIT_MSB_GREY";
61 case Format::FOUR_BIT_LSB_GREY:
62 return "FOUR_BIT_LSB_GREY";
63 case Format::FOUR_BIT_MSB_PAL:
64 return "FOUR_BIT_MSB_PAL";
65 case Format::FOUR_BIT_LSB_PAL:
66 return "FOUR_BIT_LSB_PAL";
67 case Format::EIGHT_BIT_PAL:
68 return "EIGHT_BIT_PAL";
69 case Format::EIGHT_BIT_GREY:
70 return "EIGHT_BIT_GREY";
71 case Format::SIXTEEN_BIT_LSB_TC_MASK:
72 return "SIXTEEN_BIT_LSB_TC_MASK";
73 case Format::SIXTEEN_BIT_MSB_TC_MASK:
74 return "SIXTEEN_BIT_MSB_TC_MASK";
75 case Format::TWENTYFOUR_BIT_TC_MASK:
76 return "TWENTYFOUR_BIT_TC_MASK";
77 case Format::THIRTYTWO_BIT_TC_MASK:
78 return "THIRTYTWO_BIT_TC_MASK";
79 default:
80 return "<unknown>";
85 void debugDump( const BitmapDeviceSharedPtr& rDevice,
86 std::ostream& rOutputStream )
88 const basegfx::B2IVector aSize( rDevice->getSize() );
89 const bool bTopDown( rDevice->isTopDown() );
90 const sal_Int32 nScanlineFormat( rDevice->getScanlineFormat() );
92 rOutputStream
93 << "/* basebmp::BitmapDevice content dump */" << std::endl
94 << "/* Width = " << aSize.getX() << " */" << std::endl
95 << "/* Height = " << aSize.getY() << " */" << std::endl
96 << "/* TopDown = " << bTopDown << " */" << std::endl
97 << "/* Format = " << getFormatString(nScanlineFormat) << " */" << std::endl
98 << "/* (dumped entries are already mapped RGBA color values) */" << std::endl
99 << std::endl;
101 rOutputStream << std::hex;
102 for( int y=0; y<aSize.getY(); ++y )
104 for( int x=0; x<aSize.getX(); ++x )
105 rOutputStream << std::setw(8) << (sal_uInt32)rDevice->getPixel( basegfx::B2IPoint(x,y) ).toInt32() << " ";
106 rOutputStream << std::endl;