summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGfx/BMPWriter.h
blob: fad1c1820a9132877357e7142beb0a4e8f17135a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*
 * Copyright (c) 2020, Ben Jilks <benjyjilks@gmail.com>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

#include <AK/ByteBuffer.h>

namespace Gfx {

class Bitmap;

class BMPWriter {
public:
    BMPWriter() = default;

    enum class Compression : u32 {
        BI_RGB = 0,
        BI_BITFIELDS = 3,
    };

    enum class DibHeader : u32 {
        Info = 40,
        V3 = 56,
        V4 = 108,
    };

    ByteBuffer dump(const RefPtr<Bitmap>, DibHeader dib_header = DibHeader::V4);

    inline void set_compression(Compression compression) { m_compression = compression; }

private:
    Compression m_compression { Compression::BI_BITFIELDS };
    int m_bytes_per_pixel { 4 };
    bool m_include_alpha_channel { true };
};

}