cid#1607171 Data race condition
[LibreOffice.git] / sdext / source / pdfimport / xpdfwrapper / pnghelper.hxx
blobe0f2ea98b6f0649c4e8ef71c754318472c05d927
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_SDEXT_SOURCE_PDFIMPORT_XPDFWRAPPER_PNGHELPER_HXX
21 #define INCLUDED_SDEXT_SOURCE_PDFIMPORT_XPDFWRAPPER_PNGHELPER_HXX
23 #include <sal/types.h>
24 #include "pdfioutdev_gpl.hxx"
27 namespace pdfi
29 class PngHelper
31 static sal_uInt32 crc_table[ 256 ];
32 static bool bCRCTableInit;
34 static void initCRCTable();
35 static void appendFileHeader( OutputBuffer& o_rOutputBuf );
36 static size_t startChunk( const char* pChunkName, OutputBuffer& o_rOut );
37 static void endChunk( size_t nStart, OutputBuffer& o_rOut );
39 static void set( sal_uInt32 i_nValue, OutputBuffer& o_rOutputBuf, size_t i_nIndex );
40 static void append( sal_uInt32 i_nValue, OutputBuffer& o_rOutputBuf )
42 size_t nCur = o_rOutputBuf.size();
43 o_rOutputBuf.insert( o_rOutputBuf.end(), 4, Output_t(0) );
44 set( i_nValue, o_rOutputBuf, nCur );
47 static void appendIHDR( OutputBuffer& o_rOutputBuf, int width, int height, int depth, int colortype );
48 static void appendIEND( OutputBuffer& o_rOutputBuf );
50 public:
51 static void updateCRC( sal_uInt32& io_rCRC, const sal_uInt8* i_pBuf, size_t i_nLen );
52 static sal_uInt32 getCRC( const sal_uInt8* i_pBuf, size_t i_nLen );
54 // deflates the passed buff i_pBuf and appends it to the output vector
55 // returns the number of bytes added to the output
56 static sal_uInt32 deflateBuffer( const Output_t* i_pBuf, size_t i_nLen, OutputBuffer& o_rOut );
58 static void createPng( OutputBuffer& o_rOutputBuf,
59 Stream* str,
60 int width,
61 int height,
62 GfxRGB const & zeroColor,
63 GfxRGB const & oneColor,
64 bool bIsMask
66 static void createPng( OutputBuffer& o_rOutputBuf,
67 Stream* str,
68 int width, int height, GfxImageColorMap* colorMap,
69 Stream* maskStr,
70 int maskWidth, int maskHeight, GfxImageColorMap* maskColorMap );
72 // for one bit masks
73 static void createPng( OutputBuffer& o_rOutputBuf,
74 Stream* str,
75 int width, int height, GfxImageColorMap* colorMap,
76 Stream* maskStr,
77 int maskWidth, int maskHeight, bool maskInvert );
82 #endif
84 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */