{ Copyright (C) 2008 Peter Green For conditions of distribution and use, see copyright notice in zlib_license.txt which is included in the package ----------------------------------------------------------------------------- } //test program for png code, uses ct8bp mode to draw a red and white heart //in 1 2 4 and 8 bit per pixel modes. program drawheart; uses pngwrite,classes,sysutils; { $R *.RES} const imagedata : array[0..10] of array [0..10] of byte=( (0,0,0,0,0,0,0,0,0,0,0), (0,0,1,1,1,0,1,1,1,0,0), (0,1,1,1,1,0,1,1,1,1,0), (0,1,1,1,1,1,1,1,1,1,0), (0,1,1,1,1,1,1,1,1,1,0), (0,1,1,1,1,1,1,1,1,1,0), (0,0,1,1,1,1,1,1,1,0,0), (0,0,0,1,1,1,1,1,0,0,0), (0,0,0,0,1,1,1,0,0,0,0), (0,0,0,0,0,1,0,0,0,0,0), (0,0,0,0,0,0,0,0,0,0,0) ); paldata : array[0..5] of byte=(255,255,255,255,0,0); var outer,counter : integer; stream : tfilestream; f : tpngwrite; begin for outer := 0 to 3 do begin stream := tfilestream.Create('heart'+inttostr(1 shl outer)+'.png',fmCreate{fmOpenWrite} or fmShareDenyNone ); try pngstart(f,stream,1 shl outer,ct8bp,11,11); pngwritepal(f,@paldata,2); pngstartdata(f); for counter := 0 to 10 do begin pngwritescanline(f,@imagedata[counter]); end; pngfinishdata(f); pngfinish(f); finally stream.Free; end; end; end.