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

bool wxPdfDocument::Image ( const wxString &  file,
double  x,
double  y,
double  w = 0,
double  h = 0,
const wxString &  mimeType = wxEmptyString,
const wxPdfLink link = wxPdfLink(-1),
int  maskImage = 0 
) [virtual]

Puts an image in the page.

The upper-left corner must be given. The dimensions can be specified in different ways:

  • explicit width and height (expressed in user unit)
  • one explicit dimension, the other being calculated automatically in order to keep the original proportions
  • no explicit dimension, in which case the image is put at 72 dpi

Supported formats are JPEG, PNG, GIF and WMF. For JPEG, all flavors are allowed:

  • gray scales,
  • true colors (24 bits),
  • CMYK (32 bits)

For PNG, the following flavors are allowed:

  • gray scales on at most 8 bits (256 levels)
  • indexed colors
  • true colors (24 bits)

but the following options are not supported:

  • Interlacing
  • Alpha channel

If a transparent color is defined, it will be taken into account (but will be only interpreted by Acrobat 4 and above).

For GIF, all flavors the wsWidgets GIF decoder is able to handle are supported

For WMF: WMF files contain vector data described in terms of Windows Graphics Device Interface (GDI) commands. There are approximately 80 different GDI commands allowed for in the WMF standard. This method interprets only a small subset of these, but is sufficient to display most WMF images. Please feel free to add further functionality.

The format can be specified explicitly or inferred from the file extension.

It is possible to put a link on the image.

Remark: if an image is used several times, only one copy will be embedded in the file.

Parameters:
fileName of the file containing the image.
xAbscissa of the upper-left corner.
yOrdinate of the upper-left corner.
wWidth of the image in the page. If not specified or equal to zero, it is automatically calculated.
hHeight of the image in the page. If not specified or equal to zero, it is automatically calculated.
mimeTypeImage format. Possible values are: image/jpeg, image/png, image/gif, image/wmf. If not specified, the type is inferred from the file extension.
linkURL or identifier returned by AddLink().
maskImageId of an image mask created previously by ImageMask().
See also:
AddLink()

Definition at line 1436 of file pdfdoc.cpp.

References wxPdfImage::GetMaskImage(), OutImage(), wxPdfImage::Parse(), and wxPdfImage::SetMaskImage().

Referenced by Image(), RotatedImage(), and WriteXmlCell().

{
  wxPdfImage* currentImage = NULL;
  // Put an image on the page
  wxPdfImageHashMap::iterator image = (*m_images).find(file);
  if (image == (*m_images).end())
  {
    // First use of image, get info
    int i = (*m_images).size() + 1;
    currentImage = new wxPdfImage(this, i, file, type);
    if (!currentImage->Parse())
    {
      bool isValid = false;
      delete currentImage;

      if (wxImage::FindHandler(wxBITMAP_TYPE_PNG) == NULL)
      {
        wxImage::AddHandler(new wxPNGHandler());
      }
      wxImage tempImage;
      tempImage.LoadFile(file);
      if (tempImage.Ok())
      {
        isValid = Image(file, tempImage, x, y, w, h, link, maskImage);
      }
      return isValid;
    }
    if (maskImage > 0)
    {
      currentImage->SetMaskImage(maskImage);
    }
    (*m_images)[file] = currentImage;
  }
  else
  {
    currentImage = image->second;
    if (maskImage > 0 && currentImage->GetMaskImage() != maskImage)
    {
      currentImage->SetMaskImage(maskImage);
    }
  }
  OutImage(currentImage, x, y, w, h, link);
  return true;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index