author | nemo |
Sun, 30 Jul 2017 19:06:57 -0400 | |
changeset 12444 | 832b969ea00c |
parent 11046 | 47a8c19ecb60 |
child 12621 | d972b31f8881 |
permissions | -rw-r--r-- |
6882 | 1 |
(* |
2 |
* Hedgewars, a free turn based strategy game |
|
11046 | 3 |
* Copyright (c) 2004-2015 Andrey Korotaev <unC0Rr@gmail.com> |
6882 | 4 |
* |
5 |
* This program is free software; you can redistribute it and/or modify |
|
6 |
* it under the terms of the GNU General Public License as published by |
|
7 |
* the Free Software Foundation; version 2 of the License |
|
8 |
* |
|
9 |
* This program is distributed in the hope that it will be useful, |
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
13 |
* |
|
14 |
* You should have received a copy of the GNU General Public License |
|
15 |
* along with this program; if not, write to the Free Software |
|
10108
c68cf030eded
update FSF address. note: two sdl include files (by Sam Lantinga) still have the old FSF address in their copyright - but I ain't gonna touch their copyright headers
sheepluva
parents:
9998
diff
changeset
|
16 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
6882 | 17 |
*) |
18 |
||
19 |
{$INCLUDE "options.inc"} |
|
20 |
||
21 |
unit PNGh; |
|
22 |
interface |
|
23 |
||
24 |
uses png; |
|
25 |
||
26 |
||
8685 | 27 |
{$IFDEF DARWIN} |
28 |
{$linklib png} |
|
29 |
{$ENDIF} |
|
30 |
||
6882 | 31 |
const |
32 |
// Constants for libpng, they are not defined in png unit. |
|
8685 | 33 |
// We actually do not need all of them. |
6882 | 34 |
|
35 |
// These describe the color_type field in png_info. |
|
36 |
// color type masks |
|
37 |
PNG_COLOR_MASK_PALETTE = 1; |
|
38 |
PNG_COLOR_MASK_COLOR = 2; |
|
39 |
PNG_COLOR_MASK_ALPHA = 4; |
|
40 |
||
41 |
// color types. Note that not all combinations are legal |
|
42 |
PNG_COLOR_TYPE_GRAY = 0; |
|
6893 | 43 |
PNG_COLOR_TYPE_PALETTE = PNG_COLOR_MASK_COLOR or PNG_COLOR_MASK_PALETTE; |
44 |
PNG_COLOR_TYPE_RGB = PNG_COLOR_MASK_COLOR; |
|
45 |
PNG_COLOR_TYPE_RGB_ALPHA = PNG_COLOR_MASK_COLOR or PNG_COLOR_MASK_ALPHA; |
|
46 |
PNG_COLOR_TYPE_GRAY_ALPHA = PNG_COLOR_MASK_ALPHA; |
|
6882 | 47 |
|
48 |
// aliases |
|
49 |
PNG_COLOR_TYPE_RGBA = PNG_COLOR_TYPE_RGB_ALPHA; |
|
50 |
PNG_COLOR_TYPE_GA = PNG_COLOR_TYPE_GRAY_ALPHA; |
|
51 |
||
52 |
// This is for compression type. PNG 1.0-1.2 only define the single type. |
|
53 |
PNG_COMPRESSION_TYPE_BASE = 0; // Deflate method 8, 32K window |
|
54 |
PNG_COMPRESSION_TYPE_DEFAULT = PNG_COMPRESSION_TYPE_BASE; |
|
55 |
||
56 |
// This is for filter type. PNG 1.0-1.2 only define the single type. |
|
57 |
PNG_FILTER_TYPE_BASE = 0; // Single row per-byte filtering |
|
58 |
PNG_INTRAPIXEL_DIFFERENCING = 64; // Used only in MNG datastreams |
|
59 |
PNG_FILTER_TYPE_DEFAULT = PNG_FILTER_TYPE_BASE; |
|
60 |
||
61 |
// These are for the interlacing type. These values should NOT be changed. |
|
62 |
PNG_INTERLACE_NONE = 0; // Non-interlaced image |
|
63 |
PNG_INTERLACE_ADAM7 = 1; // Adam7 interlacing |
|
64 |
PNG_INTERLACE_LAST = 2; // Not a valid value |
|
65 |
||
66 |
type |
|
67 |
// where is better place for this definition? |
|
68 |
PFile = ^file; |
|
69 |
||
70 |
procedure png_init_pascal_io(png_ptr: png_structp; pf : PFile); |
|
71 |
||
72 |
implementation |
|
73 |
||
74 |
// We cannot get c-style FILE* pointer to pass it to libpng, so we implement our own writing functions |
|
75 |
procedure PngWriteData(png_ptr: png_structp; p: PByte; len: png_size_t); cdecl; |
|
76 |
begin |
|
77 |
BlockWrite( PFile(png_get_io_ptr(png_ptr))^, p^, len); |
|
78 |
end; |
|
79 |
||
80 |
procedure PngFlushData(png_ptr: png_structp); cdecl; |
|
81 |
begin |
|
82 |
end; |
|
83 |
||
84 |
procedure png_init_pascal_io(png_ptr: png_structp; pf : PFile); |
|
85 |
begin |
|
86 |
png_set_write_fn(png_ptr, pf, @PngWriteData, @PngFlushData); |
|
87 |
end; |
|
88 |
||
89 |
end. |