Logo Search packages:      
Sourcecode: codeblocks version File versions  Download package

pdfimage.h

Go to the documentation of this file.
///////////////////////////////////////////////////////////////////////////////
// Name:        pdfimage.h
// Purpose:     
// Author:      Ulrich Telle
// Modified by:
// Created:     2005-08-11
// Copyright:   (c) Ulrich Telle
// Licence:     wxWindows licence
///////////////////////////////////////////////////////////////////////////////

/// \file pdfimage.h Interface of the wxPdfImage class

#ifndef _PDFIMAGE_H_
#define _PDFIMAGE_H_

#include <wx/filesys.h>
#include <wx/image.h>

#include "wx/pdfdocdef.h"

// Forward declarations

class WXDLLIMPEXP_PDFDOC wxPdfDocument;

/// Class representing image objects. (For internal use only)
00026 class WXDLLIMPEXP_PDFDOC wxPdfImage
{
public:
  /// Constructor
  wxPdfImage(wxPdfDocument* document, int index, const wxString& name, const wxString& type);

  /// Constructor
  wxPdfImage(wxPdfDocument* document, int index, const wxString& name, const wxImage& image);

  /// Constructor
  wxPdfImage(wxPdfDocument* document, int index, const wxString& name, wxInputStream& stream, const wxString& mimeType);

  /// Destructor
  virtual ~wxPdfImage();

  /// Set image index
00042   void SetIndex(int index) { m_index = index; }

  /// Get image index
00045   int  GetIndex() { return m_index; }

  /// Set object index
00048   void SetObjIndex(int n) { m_n = n; }

  /// Get object index
00051   int  GetObjIndex() { return m_n; }

  /// Set mask flag
00054   void SetMaskImage(int maskImage) { m_maskImage = maskImage; }

  /// Check mask flag
00057   int GetMaskImage() { return m_maskImage; }

  /// Set image type
00060   void SetType(const wxString& type) { m_type = type; }

  /// Get image type
00063   wxString GetType() { return m_type; }

  /// Check whether image has to be handled as a form object
00066   bool IsFormObject() { return m_isFormObj; }

  /// Set image file name
00069   void SetName(const wxString& name) { m_name = name; }

  /// Get image file name
00072   wxString GetName() { return m_name; }

  /// Get image width in pixels
00075   int GetWidth() { return m_width; }

  /// Get image height in pixels
00078   int GetHeight() { return m_height; }

  /// Get image offset in X direction
00081   int GetX() { return m_x; }

  /// Get image offset in Y direction
00084   int GetY() { return m_y; }

  /// Get color space
00087   wxString GetColorSpace() { return m_cs; }

  /// Get bits per component
00090   int GetBitsPerComponent() { return m_bpc; }

  /// Get compression filter specification
00093   wxString GetF() { return m_f; }

  /// Get additional PDF parameter
00096   wxString GetParms() { return m_parms; }

  /// Get palette size
00099   int GetPaletteSize() { return m_palSize; }

  /// Get palette data
00102   char* GetPalette() { return m_pal; }

  /// Get transparency size
00105   int GetTransparencySize() { return m_trnsSize; }

  /// Get transparency data
00108   char* GetTransparency() { return m_trns; }

  /// Get image data size
00111   int GetDataSize() { return m_dataSize; }

  /// Get image data
00114   char* GetData() { return m_data; }

  /// Parse image file
  bool Parse();

protected:
  /// Extract info from a wxImage
  bool ConvertWxImage(const wxImage& image);

  /// Extract info from a JPEG file
  bool ParseJPG(wxInputStream* imageStream);

  /// Extract info from a PNG file
  bool ParsePNG(wxInputStream* imageStream);

  /// Extract info from a GIF file
  bool ParseGIF(wxInputStream* imageStream);

  /// Extract info from a WMF file
  bool ParseWMF(wxInputStream* imageStream);

  /// Read a 4-byte integer from file (big endian)
  int ReadIntBE(wxInputStream* imageStream);

  /// Read a 4-byte integer from file (little endian)
  int ReadIntLE(wxInputStream* imageStream);
  
  /// Read a 4-byte unsigned integer from file (big endian)
  unsigned int ReadUIntBE(wxInputStream* imageStream);

  /// Read a 4-byte unsigned integer from file (little endian)
  unsigned int ReadUIntLE(wxInputStream* imageStream);
  
  /// Read a 2-byte integer from file (big endian)
  short ReadShortBE(wxInputStream* imageStream);

  /// Read a 2-byte integer from file (little endian)
  short ReadShortLE(wxInputStream* imageStream);

  /// Read a unsigned 2-byte integer from file (big endian)
  unsigned short ReadUShortBE(wxInputStream* imageStream);

  /// Read a unsigned 2-byte integer from file (little endian)
  unsigned short ReadUShortLE(wxInputStream* imageStream);

  /// Get the file system for accessing image files
  static wxFileSystem* GetFileSystem();

protected:
00163   wxPdfDocument* m_document;  ///< Document this image belongs to
00164   int            m_index;     ///< Index number of this image
00165   int            m_n;         ///< Image object index
00166   wxString       m_type;      ///< Image type
00167   wxString       m_name;      ///< Image name
00168   int            m_maskImage; ///< Id of associated image mask

00170   int            m_width;     ///< Image width in pixels
00171   int            m_height;    ///< Image height in pixels
00172   wxString       m_cs;        ///< Colorspace
00173   char           m_bpc;       ///< Bits per color
00174   wxString       m_f;         ///< Compression method
00175   wxString       m_parms;     ///< Additional PDF parameters
00176   int            m_palSize;   ///< Size of palette
00177   char*          m_pal;       ///< Palette data
00178   int            m_trnsSize;  ///< Transparency color size
00179   char*          m_trns;      ///< Transparency color data
00180   int            m_dataSize;  ///< Image data size
00181   char*          m_data;      ///< Image data

00183   bool           m_isFormObj; ///< Flag whether image must be treated as form object
00184   int            m_x;         ///< Offset in X direction
00185   int            m_y;         ///< Offset in Y direction

00187   bool           m_fromWxImage;  ///< Flag whether image originated from wxImage
00188   bool           m_validWxImage; ///< Flag whether wxImage conversion went ok

00190   wxFSFile*      m_imageFile;    ///< File system file of image
00191   wxInputStream* m_imageStream;  ///< Stream containing the image data

00193   static wxFileSystem* ms_fileSystem; ///< File system for accessing image files
};

#endif

Generated by  Doxygen 1.6.0   Back to index