1 |
{ Copyright (C) 2008 Peter Green
|
2 |
For conditions of distribution and use, see copyright notice in zlib_license.txt
|
3 |
which is included in the package
|
4 |
----------------------------------------------------------------------------- }
|
5 |
|
6 |
//test program for png code, uses ct8bp mode to draw a red and white heart
|
7 |
//in 1 2 4 and 8 bit per pixel modes.
|
8 |
|
9 |
program drawheart;
|
10 |
|
11 |
uses
|
12 |
pngwrite,classes,sysutils;
|
13 |
|
14 |
{ $R *.RES}
|
15 |
const
|
16 |
imagedata : array[0..10] of array [0..10] of byte=(
|
17 |
(0,0,0,0,0,0,0,0,0,0,0),
|
18 |
(0,0,1,1,1,0,1,1,1,0,0),
|
19 |
(0,1,1,1,1,0,1,1,1,1,0),
|
20 |
(0,1,1,1,1,1,1,1,1,1,0),
|
21 |
(0,1,1,1,1,1,1,1,1,1,0),
|
22 |
(0,1,1,1,1,1,1,1,1,1,0),
|
23 |
(0,0,1,1,1,1,1,1,1,0,0),
|
24 |
(0,0,0,1,1,1,1,1,0,0,0),
|
25 |
(0,0,0,0,1,1,1,0,0,0,0),
|
26 |
(0,0,0,0,0,1,0,0,0,0,0),
|
27 |
(0,0,0,0,0,0,0,0,0,0,0)
|
28 |
);
|
29 |
paldata : array[0..5] of byte=(255,255,255,255,0,0);
|
30 |
var
|
31 |
outer,counter : integer;
|
32 |
stream : tfilestream;
|
33 |
f : tpngwrite;
|
34 |
begin
|
35 |
for outer := 0 to 3 do begin
|
36 |
|
37 |
stream := tfilestream.Create('heart'+inttostr(1 shl outer)+'.png',fmCreate{fmOpenWrite} or fmShareDenyNone );
|
38 |
try
|
39 |
pngstart(f,stream,1 shl outer,ct8bp,11,11);
|
40 |
pngwritepal(f,@paldata,2);
|
41 |
pngstartdata(f);
|
42 |
|
43 |
for counter := 0 to 10 do begin
|
44 |
pngwritescanline(f,@imagedata[counter]);
|
45 |
end;
|
46 |
pngfinishdata(f);
|
47 |
pngfinish(f);
|
48 |
finally
|
49 |
stream.Free;
|
50 |
end;
|
51 |
end;
|
52 |
end.
|