blob: 201e3a08b8c03b537172a912cf508ee44979b4da (
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
*/
#ifndef INCLUDED_VCL_FILTER_PNGIMAGEREADER_HXX
#define INCLUDED_VCL_FILTER_PNGIMAGEREADER_HXX
#include <sal/config.h>
#include <memory>
#include <vector>
#include <vcl/dllapi.h>
#include <vcl/BinaryDataContainer.hxx>
#include <com/sun/star/uno/Reference.hxx>
constexpr sal_uInt64 PNG_SIGNATURE = 0x89504E470D0A1A0A;
constexpr sal_uInt32 PNG_IHDR_SIGNATURE = 0x49484452;
constexpr sal_uInt32 PNG_IDAT_SIGNATURE = 0x49444154;
constexpr sal_uInt32 PNG_PHYS_SIGNATURE = 0x70485973;
constexpr sal_uInt32 PNG_TRNS_SIGNATURE = 0x74524E53;
constexpr sal_uInt32 PNG_ACTL_SIGNATURE = 0x6163544C;
constexpr sal_uInt32 PNG_FCTL_SIGNATURE = 0x6663544C;
constexpr sal_uInt32 PNG_FDAT_SIGNATURE = 0x66644154;
constexpr sal_uInt32 PNG_IEND_SIGNATURE = 0x49454E44;
constexpr sal_uInt32 PNG_IEND_CRC = 0xAE426082;
constexpr int PNG_SIGNATURE_SIZE = 8;
constexpr int PNG_IHDR_SIZE = 13;
constexpr int PNG_TYPE_SIZE = 4;
constexpr int PNG_SIZE_SIZE = 4;
constexpr int PNG_CRC_SIZE = 4;
constexpr int PNG_IEND_SIZE = 0;
namespace com::sun::star::task
{
class XStatusIndicator;
}
class Graphic;
class BitmapEx;
class SvStream;
namespace vcl
{
class VCL_DLLPUBLIC PngImageReader
{
SvStream& mrStream;
css::uno::Reference<css::task::XStatusIndicator> mxStatusIndicator;
public:
PngImageReader(SvStream& rStream);
// Returns true if image was successfully read without errors.
// A usable bitmap may be returned even if there were errors (e.g. incomplete image).
bool read(BitmapEx& rBitmap);
bool read(Graphic& rGraphic);
// Returns a bitmap without indicating if there were errors.
BitmapEx read();
// Returns the contents of the msOG chunk (containing a Gif image), if it exists.
// Does not change position in the stream.
static BinaryDataContainer getMicrosoftGifChunk(SvStream& rStream);
static bool isAPng(SvStream& rStream);
};
} // namespace vcl
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|