1 /*************************************************************************
3 * OpenOffice.org - a multi-platform office productivity suite
5 * The Contents of this file are made available subject to
6 * the terms of GNU General Public License Version 2.
9 * GNU General Public License, version 2
10 * =============================================
11 * Copyright 2005 by Sun Microsystems, Inc.
12 * 901 San Antonio Road, Palo Alto, CA 94303, USA
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License as
16 * published by the Free Software Foundation; either version 2 of
17 * the License, or (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public
25 * License along with this program; if not, write to the Free
26 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
27 * Boston, MA 02110-1301, USA.
29 ************************************************************************/
30 #ifndef _IPDF_PNGHELPER_HXX
31 #define _IPDF_PNGHELPER_HXX
33 #include "sal/types.h"
34 #include "pdfioutdev_gpl.hxx"
41 static sal_uInt32 crc_table
[ 256 ];
42 static bool bCRCTableInit
;
44 static void initCRCTable();
45 static void appendFileHeader( OutputBuffer
& o_rOutputBuf
);
46 static size_t startChunk( const char* pChunkName
, OutputBuffer
& o_rOut
);
47 static void endChunk( size_t nStart
, OutputBuffer
& o_rOut
);
49 static void set( sal_uInt32 i_nValue
, OutputBuffer
& o_rOutputBuf
, size_t i_nIndex
);
50 static void append( sal_uInt32 i_nValue
, OutputBuffer
& o_rOutputBuf
)
52 size_t nCur
= o_rOutputBuf
.size();
53 o_rOutputBuf
.insert( o_rOutputBuf
.end(), 4, (Output_t
)0 );
54 set( i_nValue
, o_rOutputBuf
, nCur
);
57 static void appendIHDR( OutputBuffer
& o_rOutputBuf
, int width
, int height
, int depth
, int colortype
);
58 static void appendIEND( OutputBuffer
& o_rOutputBuf
);
61 static void updateCRC( sal_uInt32
& io_rCRC
, const sal_uInt8
* i_pBuf
, size_t i_nLen
);
62 static sal_uInt32
getCRC( const sal_uInt8
* i_pBuf
, size_t i_nLen
);
64 // deflates the passed buff i_pBuf and appends it to the output vector
65 // returns the number of bytes added to the output
66 static sal_uInt32
deflateBuffer( const Output_t
* i_pBuf
, size_t i_nLen
, OutputBuffer
& o_rOut
);
68 static void createPng( OutputBuffer
& o_rOutputBuf
,
76 static void createPng( OutputBuffer
& o_rOutputBuf
,
78 int width
, int height
, GfxImageColorMap
* colorMap
,
80 int maskWidth
, int maskHeight
, GfxImageColorMap
* maskColorMap
);
83 static void createPng( OutputBuffer
& o_rOutputBuf
,
85 int width
, int height
, GfxImageColorMap
* colorMap
,
87 int maskWidth
, int maskHeight
, bool maskInvert
);