Logo Search packages:      
Sourcecode: djvulibre version File versions

void DjVuToPS::print ( ByteStream str,
GP< DjVuImage dimg,
const GRect prn_rect,
const GRect img_rect,
int  override_dpi = -1 

Prints the specified {DjVuImage} dimg# into the {ByteStream} str#. The function will first scale the image to fit the img_rect#, then extract prn_rect# from the obtained bitmap and will output it in the PostScript format. The function generates a legal PostScript (or Encapsulated PostScript) file taking care of all comments conforming to Document Structure Conventions v. 3.0.

{ Warning:} The zoom factor specified in {Options} does not affect the amount of data stored into the PostScript file. It will be used by the PostScript code to additionally scale the image. We cannot pre-scale it here, because we do not know the future resolution of the printer. The img_rect# and prn_rect# alone define how much data will be sent to printer.

Using img_rect# one can upsample or downsample the image prior to sending it to the printer.

str {ByteStream} where PostScript output will be sent
dimg {DjVuImage} to print
img_rect Rectangle to which the {DjVuImage} will be scaled. Note that this parameters defines the amount of data that will actually be sent to the printer. The PostScript code can futher resize the image according to the zoom# parameter from the {Options} structure.
prn_rect Part of img_rect to send to printer.
override_dpi Optional parameter allowing you to override dpi setting that would otherwise be extracted from dimg#

Definition at line 2072 of file DjVuToPS.cpp.

References GRect::height(), GRect::intersect(), GRect::isempty(), GRectMapper::map(), GRectMapper::set_input(), GRectMapper::set_output(), GRect::width(), GRect::xmin, and GRect::ymin.

  DEBUG_MSG("DjVuToPS::print(): Printing DjVu page to a stream\n");
  GRect prn_rect;
  prn_rect.intersect(prn_rect_in, img_rect);
  DEBUG_MSG("prn_rect=(" << prn_rect.xmin << ", " << prn_rect.ymin << ", " <<
            prn_rect.width() << ", " << prn_rect.height() << ")\n");
  DEBUG_MSG("img_rect=(" << img_rect.xmin << ", " << img_rect.ymin << ", " <<
            img_rect.width() << ", " << img_rect.height() << ")\n");
  if (!dimg)
  if (prn_rect.isempty())
  if (img_rect.isempty())
  GRectMapper mapper;
  GRect full_rect(0, 0, dimg->get_width(), dimg->get_height());
  int image_dpi =  dimg->get_dpi();
  if (override_dpi>0) 
    image_dpi = override_dpi;
  if (image_dpi <= 0) 
    image_dpi = 300;
  store_doc_prolog(str, 1, (int)(image_dpi), &prn_rect);
  write(str,"%%%%Page: 1 1\n");
  store_page_setup(str, (int)(image_dpi), prn_rect);
  print_image(str, dimg, prn_rect, 0);

Generated by  Doxygen 1.6.0   Back to index