bump product version to 4.2.0.1
[LibreOffice.git] / basebmp / source / debug.cxx
blobd8348ffd379bc242080e51c71be39677d847dfb9
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <osl/diagnose.h>
22 #include <basegfx/point/b2ipoint.hxx>
23 #include <basegfx/vector/b2ivector.hxx>
25 #include <basebmp/scanlineformats.hxx>
26 #include <basebmp/color.hxx>
27 #include <basebmp/bitmapdevice.hxx>
28 #include <basebmp/debug.hxx>
30 #include <iomanip>
32 namespace basebmp
34 const char* formatName( Format nScanlineFormat )
36 switch( nScanlineFormat )
38 case FORMAT_NONE:
39 return "NONE";
40 case FORMAT_ONE_BIT_MSB_GREY:
41 return "ONE_BIT_MSB_GREY";
42 case FORMAT_ONE_BIT_LSB_GREY:
43 return "ONE_BIT_LSB_GREY";
44 case FORMAT_ONE_BIT_MSB_PAL:
45 return "ONE_BIT_MSB_PAL";
46 case FORMAT_ONE_BIT_LSB_PAL:
47 return "ONE_BIT_LSB_PAL";
48 case FORMAT_FOUR_BIT_MSB_GREY:
49 return "FOUR_BIT_MSB_GREY";
50 case FORMAT_FOUR_BIT_LSB_GREY:
51 return "FOUR_BIT_LSB_GREY";
52 case FORMAT_FOUR_BIT_MSB_PAL:
53 return "FOUR_BIT_MSB_PAL";
54 case FORMAT_FOUR_BIT_LSB_PAL:
55 return "FOUR_BIT_LSB_PAL";
56 case FORMAT_EIGHT_BIT_PAL:
57 return "EIGHT_BIT_PAL";
58 case FORMAT_EIGHT_BIT_GREY:
59 return "EIGHT_BIT_GREY";
60 case FORMAT_SIXTEEN_BIT_LSB_TC_MASK:
61 return "SIXTEEN_BIT_LSB_TC_MASK";
62 case FORMAT_SIXTEEN_BIT_MSB_TC_MASK:
63 return "SIXTEEN_BIT_MSB_TC_MASK";
64 case FORMAT_TWENTYFOUR_BIT_TC_MASK:
65 return "TWENTYFOUR_BIT_TC_MASK";
66 case FORMAT_THIRTYTWO_BIT_TC_MASK_BGRA:
67 return "THIRTYTWO_BIT_TC_MASK_BGRA";
68 case FORMAT_THIRTYTWO_BIT_TC_MASK_ARGB:
69 return "THIRTYTWO_BIT_TC_MASK_ARGB";
70 case FORMAT_THIRTYTWO_BIT_TC_MASK_ABGR:
71 return "THIRTYTWO_BIT_TC_MASK_ABGR";
72 case FORMAT_THIRTYTWO_BIT_TC_MASK_RGBA:
73 return "THIRTYTWO_BIT_TC_MASK_RGBA";
74 default:
75 return "<unknown>";
79 #if OSL_DEBUG_LEVEL > 2
81 void debugDump( const BitmapDeviceSharedPtr& rDevice,
82 std::ostream& rOutputStream )
84 const basegfx::B2IVector aSize( rDevice->getSize() );
85 const bool bTopDown( rDevice->isTopDown() );
86 const Format nScanlineFormat( rDevice->getScanlineFormat() );
88 rOutputStream
89 << "/* basebmp::BitmapDevice content dump */" << std::endl
90 << "/* Width = " << aSize.getX() << " */" << std::endl
91 << "/* Height = " << aSize.getY() << " */" << std::endl
92 << "/* TopDown = " << bTopDown << " */" << std::endl
93 << "/* Format = " << formatName(nScanlineFormat) << " */" << std::endl
94 << "/* (dumped entries are already mapped RGBA color values) */" << std::endl
95 << std::endl;
97 rOutputStream << std::hex;
98 for( int y=0; y<aSize.getY(); ++y )
100 for( int x=0; x<aSize.getX(); ++x )
101 rOutputStream << std::setw(8) << (sal_uInt32)rDevice->getPixel( basegfx::B2IPoint(x,y) ).toInt32() << " ";
102 rOutputStream << std::endl;
106 #endif // OSL_DEBUG_LEVEL > 2
110 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */