Factor out and simplify COM-safe wait
[LibreOffice.git] / include / vcl / filter / PngImageReader.hxx
blob86306ad746f44769516b6c9c0de43d63e7c581ef
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 #ifndef INCLUDED_VCL_FILTER_PNGIMAGEREADER_HXX
12 #define INCLUDED_VCL_FILTER_PNGIMAGEREADER_HXX
14 #include <sal/config.h>
16 #include <vcl/dllapi.h>
17 #include <vcl/BinaryDataContainer.hxx>
19 #include <com/sun/star/uno/Reference.hxx>
21 constexpr sal_uInt64 PNG_SIGNATURE = 0x89504E470D0A1A0A;
22 constexpr sal_uInt32 PNG_IHDR_SIGNATURE = 0x49484452;
23 constexpr sal_uInt32 PNG_IDAT_SIGNATURE = 0x49444154;
24 constexpr sal_uInt32 PNG_PHYS_SIGNATURE = 0x70485973;
25 constexpr sal_uInt32 PNG_TRNS_SIGNATURE = 0x74524E53;
26 constexpr sal_uInt32 PNG_ACTL_SIGNATURE = 0x6163544C;
27 constexpr sal_uInt32 PNG_FCTL_SIGNATURE = 0x6663544C;
28 constexpr sal_uInt32 PNG_FDAT_SIGNATURE = 0x66644154;
29 constexpr sal_uInt32 PNG_IEND_SIGNATURE = 0x49454E44;
30 constexpr sal_uInt32 PNG_IEND_CRC = 0xAE426082;
31 constexpr int PNG_SIGNATURE_SIZE = 8;
32 constexpr int PNG_IHDR_SIZE = 13;
33 constexpr int PNG_TYPE_SIZE = 4;
34 constexpr int PNG_SIZE_SIZE = 4;
35 constexpr int PNG_CRC_SIZE = 4;
36 constexpr int PNG_IEND_SIZE = 0;
38 namespace com::sun::star::task
40 class XStatusIndicator;
43 class Graphic;
44 class BitmapEx;
45 class SvStream;
47 namespace vcl
49 class VCL_DLLPUBLIC PngImageReader
51 SvStream& mrStream;
52 css::uno::Reference<css::task::XStatusIndicator> mxStatusIndicator;
54 public:
55 PngImageReader(SvStream& rStream);
57 // Returns true if image was successfully read without errors.
58 // A usable bitmap may be returned even if there were errors (e.g. incomplete image).
59 bool read(BitmapEx& rBitmap);
60 bool read(Graphic& rGraphic);
61 // Returns a bitmap without indicating if there were errors.
62 BitmapEx read();
64 // Returns the contents of the msOG chunk (containing a Gif image), if it exists.
65 // Does not change position in the stream.
66 static BinaryDataContainer getMicrosoftGifChunk(SvStream& rStream);
68 static bool isAPng(SvStream& rStream);
71 } // namespace vcl
73 #endif
75 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */