Source Code (Use browser search to find items of interest.)

Class Index

killustrator'ImageExport (./koffice/killustrator/filter/ImageExport.h:33)

class ImageExport : public ExportFilter {
public:
  ImageExport ();
  ~ImageExport ();
  
  bool setup (GDocument *doc, const char* fmt);
  bool exportToFile (GDocument *doc);
private:
  QString format;
};

killustrator'ImageExport::ImageExport() (./koffice/killustrator/filter/ImageExport.cc:39)

ImageExport::ImageExport () {
// #ifdef HAVE_QIMGIO
//   qInitImageIO ();
// #endif
  QImageIO::defineIOHandler ("GIF", "^GIF[0-9][0-9][a-z]", 0,
			     0, write_gif_image);
}


killustrator'ImageExport::~ImageExport() (./koffice/killustrator/filter/ImageExport.cc:47)

ImageExport::~ImageExport () {
}


killustrator'ImageExport::setup() (./koffice/killustrator/filter/ImageExport.cc:50)

bool ImageExport::setup (GDocument *, const char* fmt) {
  bool formatSupported = false;

  QStrList formats = QImageIO::outputFormats ();
  char* str = formats.first ();
  format = QString ();
  while (str) {
    if (strcasecmp (str, fmt) == 0) {
      format = fmt;
      format = format.upper ();
      formatSupported = true;
      break;
    }
    str = formats.next ();
  }
  return formatSupported;
}


killustrator'ImageExport::exportToFile() (./koffice/killustrator/filter/ImageExport.cc:68)

bool ImageExport::exportToFile (GDocument* doc) {
  if (format.isNull ())
    return false;

  unsigned int w, h;
  w = qRound (doc->getPaperWidth () * RESOLUTION / 72.0);
  h = qRound (doc->getPaperHeight () * RESOLUTION / 72.0);

  // prepare a pixmap for drawing
  QPixmap *buffer = new QPixmap (w, h);
  if (buffer == 0L)
    return false;

  buffer->fill (QT_PRFX::white);
  QPainter p;
  p.begin (buffer);
  p.setBackgroundColor (QT_PRFX::white);
  p.eraseRect (0, 0, w, h);
  p.scale (RESOLUTION / 72.0, RESOLUTION / 72.0);

  // draw the objects
  doc->drawContents (p);

  p.end ();

  // compute the bounding box
  Rect box = doc->boundingBoxForAllObjects ();
  // and copy the affected area to the new pixmap
  QPixmap *pixmap = new QPixmap (qRound (box.width ()),
				 qRound (box.height ()));
  if (pixmap == 0L)
    return false;
  bitBlt (pixmap, 0, 0, buffer, qRound (box.x ()), qRound (box.y ()),
          qRound (box.width ()), qRound (box.height ()));
  delete buffer;

  // now create an image
  QImage img  = pixmap->convertToImage ();
  img.setAlphaBuffer (true);
  delete pixmap;

  // and save the image in requested format
  return img.save (outputFileName (), (const char *) format);
}