LibreOffice Module vcl (master) 1
BitmapTypes.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 */
10
11#pragma once
12
13#include <sal/types.h>
14#include <cassert>
15
16namespace vcl
17{
19enum class PixelFormat
20{
21 INVALID = 0,
22 N1_BPP = 1,
23 N8_BPP = 8,
24 N24_BPP = 24,
25 N32_BPP = 32
26};
27
29constexpr bool isPalettePixelFormat(PixelFormat ePixelFormat)
30{
31 assert(ePixelFormat != PixelFormat::INVALID);
32 return sal_uInt16(ePixelFormat) <= 8;
33}
34
35constexpr sal_uInt16 pixelFormatBitCount(PixelFormat ePixelFormat)
36{
37 return sal_uInt16(ePixelFormat);
38}
39
40constexpr sal_Int64 numberOfColors(PixelFormat ePixelFormat)
41{
42 return sal_Int64(1) << sal_Int64(ePixelFormat);
43}
44
45constexpr PixelFormat bitDepthToPixelFormat(sal_uInt16 nBitDepth)
46{
47 switch (nBitDepth)
48 {
49 case 1:
51 case 4:
52 assert(false);
53 break;
54 case 8:
56 case 24:
58 case 32:
60 default:
61 break;
62 }
64}
65
66} // end namespace vcl
67
68/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define INVALID
constexpr sal_Int64 numberOfColors(PixelFormat ePixelFormat)
Definition: BitmapTypes.hxx:40
constexpr PixelFormat bitDepthToPixelFormat(sal_uInt16 nBitDepth)
Definition: BitmapTypes.hxx:45
constexpr bool isPalettePixelFormat(PixelFormat ePixelFormat)
Is it a pixel format that forces creation of a palette.
Definition: BitmapTypes.hxx:29
PixelFormat
Pixel format of the bitmap in bits per pixel.
Definition: BitmapTypes.hxx:20
constexpr sal_uInt16 pixelFormatBitCount(PixelFormat ePixelFormat)
Definition: BitmapTypes.hxx:35