Debian Codegraph @

src/engine/zzlib.h

raw symbols SCIP
1 /***************************************************************************
2 * fheroes2: https://github.com/ihhub/fheroes2 *
3 * Copyright (C) 2019 - 2026 *
4 * *
5 * Free Heroes2 Engine: http://sourceforge.net/projects/fheroes2 *
6 * Copyright (C) 2009 by Andrey Afletdinov <[email protected]> *
7 * *
8 * This program is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU General Public License as published by *
10 * the Free Software Foundation; either version 2 of the License, or *
11 * (at your option) any later version. *
12 * *
13 * This program is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16 * GNU General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU General Public License *
19 * along with this program; if not, write to the *
20 * Free Software Foundation, Inc., *
21 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
22 ***************************************************************************/
23
24 #pragma once
25
26 #include <cstddef>
27 #include <cstdint>
28 #include <vector>
29
30 #include "image.h"
31
32 class IStreamBase;
33 class OStreamBase;
34 class IStreamBuf;
35
36 namespace Compression
37 {
38 // Unzips the input data and returns the uncompressed data or an empty vector in case of an error.
39 // The 'realSize' parameter represents the planned size of the decompressed data and is optional
40 // (it is only used to speed up the decompression process). If this parameter is omitted or set to
41 // zero, the size of the decompressed data will be determined automatically.
42 std::vector<uint8_t> unzipData( const uint8_t * src, const size_t srcSize, size_t realSize = 0 );
43
44 // Unzips the input data and puts the uncompressed data into the destination buffer.
45 // If the destination buffer is empty or the destination buffer size is not the same as the
46 // decompressed data size, the function returns false.
47 bool unzipData( const uint8_t * src, const size_t srcSize, uint8_t * dst, const size_t dstSize );
48
49 // Zips the input data and returns the compressed data or an empty vector in case of an error.
50 // Set isMaximumCompression only when compressing data not during the gameplay.
51 std::vector<uint8_t> zipData( const uint8_t * src, const size_t srcSize, const bool isMaximumCompression );
52
53 // Reads & unzips the zipped chunk from the given input stream and writes it to the given output
54 // stream. Returns true on success or false on error.
55 bool unzipStream( IStreamBase & inputStream, OStreamBase & outputStream );
56
57 // Zips the contents of the buffer from the current read position to the end of the buffer and writes
58 // it to the given output stream. The current read position of the buffer does not change. Returns
59 // true on success and false on error.
60 bool zipStreamBuf( const IStreamBuf & inputStream, OStreamBase & outputStream );
61
62 fheroes2::Image CreateImageFromZlib( int32_t width, int32_t height, const uint8_t * imageData, size_t imageSize, bool doubleLayer );
63 }