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

int wxPdfDocument::ImageMask ( const wxString &  name,
const wxImage &  image 
) [virtual]

Prepares an image for use as an image mask The image is given by an wxImage-Object

Parameters:
nameName of the image.
imagewxImage object.
Returns:
id of the image mask, or 0 in case of an error

Definition at line 1623 of file pdfdoc.cpp.

References wxPdfImage::GetIndex(), m_PDFVersion, and wxPdfImage::Parse().

{
  int n = 0;
  if (img.Ok())
  {
    wxPdfImage* currentImage = NULL;
    // Put an image on the page
    wxPdfImageHashMap::iterator image = (*m_images).find(name);
    if (image == (*m_images).end())
    {
      wxImage tempImage;
      if (img.HasAlpha())
      {
        int x, y;
        int w = img.GetWidth();
        int h = img.GetHeight();
        tempImage = wxImage(w, h);
        unsigned char alpha;
        for (x = 0; x < w; x++)
        {
          for (y = 0; y < h; y++)
          {
            alpha = img.GetAlpha(x, y);
            tempImage.SetRGB(x, y, alpha, alpha, alpha);
          }
        }
        tempImage.SetOption(wxIMAGE_OPTION_PNG_FORMAT, wxPNG_TYPE_GREY_RED);
      }
      else
      {
        tempImage = img.Copy();
        tempImage.SetOption(wxIMAGE_OPTION_PNG_FORMAT, wxPNG_TYPE_GREY);
      }
      tempImage.SetMask(false);
      // First use of image, get info
      n = (*m_images).size() + 1;
      currentImage = new wxPdfImage(this, n, name, tempImage);
      if (!currentImage->Parse())
      {
        delete currentImage;
        return 0;
      }
      (*m_images)[name] = currentImage;
    }
    else
    {
      currentImage = image->second;
      n = currentImage->GetIndex();
    }
    if (m_PDFVersion < _T("1.4"))
    {
      m_PDFVersion = _T("1.4");
    }
  }
  return n;
}

Here is the call graph for this function:


Generated by  Doxygen 1.6.0   Back to index