/** * @param pdf: the pdf widget to get the orientation of * @param hscale: horizontal scale of the current page * @param vscale: vertical scale of the current page * @return Returns no value. * @brief get the horizontal scale @p hscale and the vertical scale * @p vscale of the document @p pdf. If @p pdf is NULL, their values are 1.0 */ void ewl_pdf_scale_get(Ewl_Pdf *pdf, double *hscale, double *vscale) { DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR(pdf); DCHECK_TYPE(pdf, EWL_PDF_TYPE); if (!pdf->pdf_page) { if (hscale) *hscale = 1.0; if (vscale) *vscale = 1.0; DRETURN(DLEVEL_STABLE); } epdf_page_scale_get(pdf->pdf_page, hscale, vscale); DLEAVE_FUNCTION(DLEVEL_STABLE); }
/** * @param pdf: the pdf to change the scale * @param hscale: the horizontal scale * @param vscale: the vertical scale * @return Returns no value. * @brief Set the scale of the document * * Sets the horizontal scale @p hscale and the vertical scale @p vscale * of the document @p pdf */ void ewl_pdf_scale_set(Ewl_Pdf *pdf, double hscale, double vscale) { double hs; double vs; DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR(pdf); DCHECK_TYPE(pdf, EWL_PDF_TYPE); if (!pdf->pdf_page) DRETURN(DLEVEL_STABLE); epdf_page_scale_get(pdf->pdf_page, &hs, &vs); if ((hs == hscale) && (vs == vscale)) DRETURN(DLEVEL_STABLE); pdf->dirty = 1; epdf_page_scale_set(pdf->pdf_page, hscale, vscale); ewl_widget_configure(EWL_WIDGET(pdf)); DLEAVE_FUNCTION(DLEVEL_STABLE); }
void epdf_page_render (Epdf_Page *page, Evas_Object *o) { SplashOutputDev *output_dev; SplashColor white; SplashColorPtr color_ptr; Epdf_Document *doc; unsigned int *m = NULL; double hscale; double vscale; int rotate; int width; int height; double t1,t2; t1 = ecore_time_get(); white[0] = 255; white[1] = 255; white[2] = 255; white[3] = 255; if (!page->page || !page->page->isOk ()) return; doc = page->doc; output_dev = new SplashOutputDev(splashModeXBGR8, 4, gFalse, white); output_dev->startDoc(doc->pdfdoc->getXRef ()); switch (page->orientation) { case EPDF_PAGE_ORIENTATION_LANDSCAPE: rotate = 90; break; case EPDF_PAGE_ORIENTATION_UPSIDEDOWN: rotate = 180; break; case EPDF_PAGE_ORIENTATION_SEASCAPE: rotate = 270; break; case EPDF_PAGE_ORIENTATION_PORTRAIT: default: rotate = 0; break; } epdf_page_scale_get (page, &hscale, &vscale); page->page->display (output_dev, 72.0 * hscale, 72.0 * vscale, rotate, false, false, false, doc->pdfdoc->getCatalog ()); color_ptr = output_dev->getBitmap ()->getDataPtr (); width = output_dev->getBitmap()->getWidth(); height = output_dev->getBitmap()->getHeight(); evas_object_image_size_set(o, width, height); evas_object_image_fill_set(o, 0, 0, width, height); m = (unsigned int *)evas_object_image_data_get(o, 1); if (!m) goto sortie; memcpy (m, color_ptr, height * width * 4); evas_object_image_data_set(o, m); evas_object_image_data_update_add(o, 0, 0, width, height); evas_object_resize(o, width, height); // evas_object_image_alpha_set (o, 0); sortie: delete output_dev; t2 = ecore_time_get(); printf ("time poppler: %f\n", t2-t1); }