Fix typo
[LibreOffice.git] / include / vcl / bitmap / BitmapTypes.hxx
blob6f1cc220a977ad163998b32957a672ca3f4b6a9d
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 */
11 #pragma once
13 #include <sal/types.h>
14 #include <cassert>
16 namespace vcl
18 /** Pixel format of the bitmap in bits per pixel */
19 enum class PixelFormat
21 INVALID = 0,
22 N8_BPP = 8,
23 N24_BPP = 24,
24 N32_BPP = 32
27 /** Is it a pixel format that forces creation of a palette */
28 constexpr bool isPalettePixelFormat(PixelFormat ePixelFormat)
30 assert(ePixelFormat != PixelFormat::INVALID);
31 return sal_uInt16(ePixelFormat) <= 8;
34 constexpr sal_uInt16 pixelFormatBitCount(PixelFormat ePixelFormat)
36 return sal_uInt16(ePixelFormat);
39 constexpr sal_Int64 numberOfColors(PixelFormat ePixelFormat)
41 return sal_Int64(1) << sal_Int64(ePixelFormat);
44 constexpr PixelFormat bitDepthToPixelFormat(sal_uInt16 nBitDepth)
46 switch (nBitDepth)
48 case 1:
49 case 4:
50 assert(false && "no longer supported");
51 break;
52 case 8:
53 return PixelFormat::N8_BPP;
54 case 24:
55 return PixelFormat::N24_BPP;
56 case 32:
57 return PixelFormat::N32_BPP;
58 default:
59 break;
61 return PixelFormat::INVALID;
64 } // end namespace vcl
66 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */