1//========================================================================
2//
3// PNGWriter.h
4//
5// This file is licensed under the GPLv2 or later
6//
7// Copyright (C) 2009 Warren Toomey <wkt@tuhs.org>
8// Copyright (C) 2009 Shen Liang <shenzhuxi@gmail.com>
9// Copyright (C) 2009, 2011-2013, 2021, 2022 Albert Astals Cid <aacid@kde.org>
10// Copyright (C) 2009 Stefan Thomas <thomas@eload24.com>
11// Copyright (C) 2010, 2011, 2013, 2017 Adrian Johnson <ajohnson@redneon.com>
12// Copyright (C) 2012 Pino Toscano <pino@kde.org>
13//
14//========================================================================
15
16#ifndef PNGWRITER_H
17#define PNGWRITER_H
18
19#include "poppler-config.h"
20#include "poppler_private_export.h"
21
22#ifdef ENABLE_LIBPNG
23
24# include "ImgWriter.h"
25
26struct PNGWriterPrivate;
27
28class POPPLER_PRIVATE_EXPORT PNGWriter : public ImgWriter
29{
30public:
31 /* RGB - 3 bytes/pixel
32 * RGBA - 4 bytes/pixel
33 * GRAY - 1 byte/pixel
34 * MONOCHROME - 8 pixels/byte
35 * RGB48 - 6 bytes/pixel
36 */
37 enum Format
38 {
39 RGB,
40 RGBA,
41 GRAY,
42 MONOCHROME,
43 RGB48
44 };
45
46 explicit PNGWriter(Format format = RGB);
47 ~PNGWriter() override;
48
49 PNGWriter(const PNGWriter &other) = delete;
50 PNGWriter &operator=(const PNGWriter &other) = delete;
51
52 void setICCProfile(const char *name, unsigned char *data, int size);
53 void setSRGBProfile();
54
55 bool init(FILE *f, int width, int height, double hDPI, double vDPI) override;
56
57 bool writePointers(unsigned char **rowPointers, int rowCount) override;
58 bool writeRow(unsigned char **row) override;
59
60 bool close() override;
61
62private:
63 PNGWriterPrivate *priv;
64};
65
66#endif
67
68#endif
69

source code of poppler/goo/PNGWriter.h