/usr/include/podofo/doc/PdfImage.h is in libpodofo-dev 0.9.0-1.2+b2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 | /***************************************************************************
* Copyright (C) 2005 by Dominik Seichter *
* domseichter@web.de *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Library General Public License as *
* published by the Free Software Foundation; either version 2 of the *
* License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef _PDF_IMAGE_H_
#define _PDF_IMAGE_H_
#include "podofo/base/PdfDefines.h"
#include "podofo/base/PdfFilter.h"
#include "PdfXObject.h"
namespace PoDoFo {
class PdfDocument;
class PdfInputStream;
class PdfObject;
class PdfVecObjects;
/** A PdfImage object is needed when ever you want to embedd an image
* file into a PDF document.
* The PdfImage object is embedded once and can be drawn as often
* as you want on any page in the document using PdfPainter
*
* \see GetImageReference
* \see PdfPainter::DrawImage
*
* \see SetImageData
*/
class PODOFO_DOC_API PdfImage : public PdfXObject {
public:
/** Constuct a new PdfImage object
*
* \param pParent parent vector of this image
* \param pszPrefix optional prefix for XObject-name
*/
PdfImage( PdfVecObjects* pParent, const char* pszPrefix = NULL );
/** Constuct a new PdfImage object
* This is an overloaded constructor.
*
* \param pParent parent document
* \param pszPrefix optional prefix for XObject-name
*/
PdfImage( PdfDocument* pParent, const char* pszPrefix = NULL );
/** Construct an image from an existing PdfObject
*
* \param pObject a PdfObject that has to be an image
*/
PdfImage( PdfObject* pObject );
~PdfImage();
/**
* Get a list of all image formats supported by this PoDoFo build.
*
* Example: { "JPEG", "TIFF", NULL }
*
* \returns a zero terminates list of all supported image formats
*/
static const char** GetSupportedFormats();
/** Set the color space of this image. The default value is
* ePdfColorSpace_DeviceRGB.
* \param eColorSpace one of ePdfColorSpace_DeviceGray, ePdfColorSpace_DeviceRGB and
* ePdfColorSpace_DeviceCMYK
*
* \see SetImageICCProfile to set an ICC profile instead of a simple colorspace
*/
void SetImageColorSpace( EPdfColorSpace eColorSpace );
/** Set an ICC profile for this image.
*
* \param pStream an input stream from which the ICC profiles data can be read
* \param lColorComponents the number of colorcomponents of the ICC profile
* \param eAlternateColorSpace an alternate colorspace to use if the ICC profile cannot be used
*
* \see SetImageColorSpace to set an colorspace instead of an ICC profile for this image
*/
void SetImageICCProfile( PdfInputStream* pStream, long lColorComponents,
EPdfColorSpace eAlternateColorSpace = ePdfColorSpace_DeviceRGB );
//EPdfColorSpace GetImageColorSpace() const;
/** Set a softmask for this image.
* \param pSoftmask a PdfImage pointer to the image, which is to be set as softmask, must be 8-Bit-Grayscale
*
*/
void SetImageSoftmask( const PdfImage* pSoftmask );
/** Get the width of the image when drawn in PDF units
* \returns the width in PDF units
*/
inline double GetWidth() const;
/** Get the height of the image when drawn in PDF units
* \returns the height in PDF units
*/
inline double GetHeight() const;
/** Set the actual image data from an input stream
*
* The image data will be flate compressed.
* If you want no compression or another filter to be applied
* use the overload of SetImageData which takes a TVecFilters
* as argument.
*
* \param nWidth width of the image in pixels
* \param nHeight height of the image in pixels
* \param nBitsPerComponent bits per color component of the image (depends on the image colorspace you have set
* but is 8 in most cases)
* \param pStream stream supplieding raw image data
*
* \see SetImageData
*/
void SetImageData( unsigned int nWidth, unsigned int nHeight,
unsigned int nBitsPerComponent, PdfInputStream* pStream );
/** Set the actual image data from an input stream
*
* \param nWidth width of the image in pixels
* \param nHeight height of the image in pixels
* \param nBitsPerComponent bits per color component of the image (depends on the image colorspace you have set
* but is 8 in most cases)
* \param pStream stream supplieding raw image data
* \param vecFilters these filters will be applied to compress the image data
*/
void SetImageData( unsigned int nWidth, unsigned int nHeight,
unsigned int nBitsPerComponent, PdfInputStream* pStream, const TVecFilters & vecFilters );
/** Load the image data from a file
* \param pszFilename
*/
void LoadFromFile( const char* pszFilename );
#ifdef PODOFO_HAVE_JPEG_LIB
/** Load the image data from a JPEG file
* \param pszFilename
*/
void LoadFromJpeg( const char* pszFilename );
#ifdef _WIN32
/** Load the image data from a JPEG file
* \param pszFilename
*
* This is an overloaded member function to allow working
* with unicode characters. On Unix systes you can also path
* UTF-8 to the const char* overload.
*/
void LoadFromJpeg( const wchar_t* pszFilename );
#endif // _WIN32
#endif // PODOFO_HAVE_JPEG_LIB
#ifdef PODOFO_HAVE_TIFF_LIB
/** Load the image data from a TIFF file
* \param pszFilename
*/
void LoadFromTiff( const char* pszFilename );
#endif // PODOFO_HAVE_TIFF_LIB
#ifdef PODOFO_HAVE_PNG_LIB
/** Load the image data from a PNG file
* \param pszFilename
*/
void LoadFromPng( const char* pszFilename );
#endif // PODOFO_HAVE_PNG_LIB
/** Set an color/chroma-key mask on an image.
* The masked color will not be painted, i.e. masked as being transparent.
*
* \param r red RGB value of color that should be masked
* \param g green RGB value of color that should be masked
* \param b blue RGB value of color that should be masked
* \param threshold colors are masked that are in the range [(r-threshold, r+threshold),(g-threshold, g+threshold),(b-threshold, b+threshold)]
*/
void SetImageChromaKeyMask(pdf_int64 r, pdf_int64 g, pdf_int64 b, pdf_int64 threshold = 0);
/**
* Apply an interpolation to the image if the source resolution
* is lower than the resolution of the output device.
* Default is false.
* \param bValue whether the image should be interpolated
*/
void SetInterpolate(bool bValue);
private:
/** Set the actual image data from an input stream.
* The data has to be encoded already and an appropriate
* filters key entry has to be set manually before!
*
* \param nWidth width of the image in pixels
* \param nHeight height of the image in pixels
* \param nBitsPerComponent bits per color component of the image (depends on the image colorspace you have set
* but is 8 in most cases)
* \param pStream stream supplieding raw image data
*/
void SetImageDataRaw( unsigned int nWidth, unsigned int nHeight,
unsigned int nBitsPerComponent, PdfInputStream* pStream );
/** Converts a EPdfColorSpace enum to a name key which can be used in a
* PDF dictionary.
* \param eColorSpace a valid colorspace
* \returns a valid key for this colorspace.
*/
static PdfName ColorspaceToName( EPdfColorSpace eColorSpace );
#ifdef PODOFO_HAVE_JPEG_LIB
void LoadFromJpegHandle( PdfFileInputStream* pInStream );
#endif // PODOFO_HAVE_JPEG_LIB
};
// -----------------------------------------------------
//
// -----------------------------------------------------
inline double PdfImage::GetWidth() const
{
return this->GetPageSize().GetWidth();
}
// -----------------------------------------------------
//
// -----------------------------------------------------
inline double PdfImage::GetHeight() const
{
return this->GetPageSize().GetHeight();
}
};
#endif // _PDF_IMAGE_H_
|