Commit d91dd69a authored by Kristian Høgsberg's avatar Kristian Høgsberg

2005-04-05 Kristian Høgsberg <krh@redhat.com>

        * NEWS: Attempt to sum up changes since 0.1.2.

        * configure.ac: Bump release to 0.2.0, add AC_DEFINEs for cairo
        and splash availability.

        * poppler/CairoFontEngine.cc: Disable hinting.

        * glib/poppler-page.cc (poppler_page_render_to_pixbuf): Choose
        either splash or cairo rendering, based on configure choice.
        (cairo_render_to_pixbuf): New function to render using the cairo
        backend.
        (splash_render_to_pixbuf): Split out the splash code to this
        function.
parent b62b0cec
2005-04-05 Kristian Høgsberg <krh@redhat.com>
* NEWS: Attempt to sum up changes since 0.1.2.
* configure.ac: Bump release to 0.2.0, add AC_DEFINEs for cairo
and splash availability.
* poppler/CairoFontEngine.cc: Disable hinting.
* glib/poppler-page.cc (poppler_page_render_to_pixbuf): Choose
either splash or cairo rendering, based on configure choice.
(cairo_render_to_pixbuf): New function to render using the cairo
backend.
(splash_render_to_pixbuf): Split out the splash code to this
function.
2005-04-04 Kristian Høgsberg <krh@redhat.com>
* ChangeLog: Add this entry to test commit mailer script.
......
Release 0.2.0 (Not out yet...)
Release 0.2.0 (Tue Apr 5 12:32:10 EDT 2005)
- Add glib wrapper for poppler
- Add glib wrapper for poppler, which will use cairo rendering
if available
- Support for page labels
- configure and build fixes.
Release 0.1.2 (Wed Mar 9 10:45:58 EST 2005)
......
dnl Based on Xpdf configure.in and evince configure.ac
AC_PREREQ(2.59)
AC_INIT(poppler, 0.1.2)
AC_INIT(poppler, 0.2.0)
AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION)
AM_CONFIG_HEADER(config.h)
AM_CONFIG_HEADER(poppler/poppler-config.h)
......@@ -142,6 +142,10 @@ if test x$enable_splash_output = xyes; then
PKG_CHECK_MODULES(SPLASH, fontconfig)
fi
AM_CONDITIONAL(BUILD_SPLASH_OUTPUT, test x$enable_splash_output = xyes)
AH_TEMPLATE([HAVE_SPLASH], [Use splash for rendering.])
if test x$enable_splash_output = xyes; then
AC_DEFINE(HAVE_SPLASH)
fi
AC_ARG_ENABLE(cairo-output,
AC_HELP_STRING([--disable-cairo-output],
......@@ -149,14 +153,18 @@ AC_ARG_ENABLE(cairo-output,
enable_cairo_output=$enableval,
enable_cairo_output="try")
if test x$enable_cairo_output = xyes; then
PKG_CHECK_MODULES(CAIRO, cairo = 0.4)
PKG_CHECK_MODULES(CAIRO, cairo = 0.4.0)
elif test x$enable_cairo_output = xtry; then
PKG_CHECK_MODULES(CAIRO, cairo = 0.4,
PKG_CHECK_MODULES(CAIRO, cairo = 0.4.0,
[enable_cairo_output="yes"],
[enable_cairo_output="no"])
fi
AM_CONDITIONAL(BUILD_CAIRO_OUTPUT, test x$enable_cairo_output = xyes)
AM_CONDITIONAL(BUILD_CAIRO_OUTPUT, test x$enable_cairo_output = xyes)
AH_TEMPLATE([HAVE_CAIRO], [Use cairo for rendering.])
if test x$enable_cairo_output = xyes; then
AC_DEFINE(HAVE_CAIRO)
fi
AC_ARG_ENABLE(poppler-glib,
AC_HELP_STRING([--disable-poppler-glib],
......
if BUILD_CAIRO_OUTPUT
cairo_includes = \
$(CAIRO_CFLAGS)
cairo_libs = \
$(CAIRO_LIBS)
endif
INCLUDES = \
-I$(top_srcdir) \
-I$(top_srcdir)/poppler \
$(cairo_includes) \
$(POPPLER_GLIB_CFLAGS) \
$(FREETYPE_CFLAGS) \
$(cairo_includes) \
-DDATADIR=\""$(datadir)"\"
poppler_glib_includedir = $(includedir)/poppler/glib
......@@ -23,7 +34,8 @@ libpoppler_glib_la_SOURCES = \
libpoppler_glib_la_LIBADD = \
$(POPPLER_GLIB_LIBS) \
$(FREETYPE_LIBS)
$(FREETYPE_LIBS) \
$(cairo_libs)
noinst_PROGRAMS = test-poppler-glib
......@@ -34,4 +46,5 @@ test_poppler_glib_LDADD = \
$(top_builddir)/poppler/libpoppler.la \
libpoppler-glib.la \
$(POPPLER_GLIB_LIBS) \
$(FREETYPE_LIBS)
$(FREETYPE_LIBS) \
$(cairo_libs)
......@@ -16,6 +16,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <math.h>
#include <goo/GooList.h>
......@@ -26,9 +27,16 @@
#include <ErrorCodes.h>
#include <UnicodeMap.h>
#include <GfxState.h>
#include <SplashOutputDev.h>
#include <TextOutputDev.h>
#if defined (HAVE_CAIRO)
#include <CairoOutputDevImage.h>
#endif
#if defined (HAVE_SPLASH)
#include <SplashOutputDev.h>
#endif
#include "poppler.h"
#include "poppler-private.h"
......@@ -88,31 +96,75 @@ poppler_page_get_index (PopplerPage *page)
return page->index;
}
/**
* poppler_page_render_to_pixbuf:
* @page: the page to render from
* @src_x: x coordinate of upper left corner
* @src_y: y coordinate of upper left corner
* @src_width: width of rectangle to render
* @src_height: height of rectangle to render
* @ppp: pixels per point
* @pixbuf: pixbuf to render into
* @dest_x: x coordinate of offset into destination
* @dest_y: y cooridnate of offset into destination
*
* First scale the document to match the specified pixels per point,
* then render the rectangle given by the upper left corner at
* (src_x, src_y) and src_width and src_height. The rectangle is
* rendered into the specified pixmap with the upper left corner
* placed at (dest_x, dest_y).
**/
void
poppler_page_render_to_pixbuf (PopplerPage *page,
int src_x, int src_y,
int src_width, int src_height,
double scale,
GdkPixbuf *pixbuf,
int dest_x, int dest_y)
#if defined (HAVE_CAIRO)
static void
cairo_render_to_pixbuf (PopplerPage *page,
int src_x, int src_y,
int src_width, int src_height,
double scale,
GdkPixbuf *pixbuf,
int dest_x, int dest_y)
{
CairoOutputDevImage *output_dev;
int cairo_width, cairo_height, cairo_rowstride;
int pixbuf_rowstride, pixbuf_n_channels;
guchar *pixbuf_data, *cairo_data, *dst;
int x, y;
output_dev = new CairoOutputDevImage ();
output_dev->startDoc(page->document->doc->getXRef ());
page->page->displaySlice(output_dev, 72.0 * scale, 72.0 * scale,
0, /* Rotate */
gTrue, /* Crop */
src_x, src_y,
src_width, src_height,
NULL, /* links */
page->document->doc->getCatalog ());
output_dev->getBitmap (&cairo_data,
&cairo_width, &cairo_height, &cairo_rowstride);
pixbuf_data = gdk_pixbuf_get_pixels (pixbuf);
pixbuf_rowstride = gdk_pixbuf_get_rowstride (pixbuf);
pixbuf_n_channels = gdk_pixbuf_get_n_channels (pixbuf);
if (dest_x + cairo_width > gdk_pixbuf_get_width (pixbuf))
cairo_width = gdk_pixbuf_get_width (pixbuf) - dest_x;
if (dest_y + cairo_height > gdk_pixbuf_get_height (pixbuf))
cairo_height = gdk_pixbuf_get_height (pixbuf) - dest_y;
for (y = 0; y < cairo_height; y++)
{
unsigned int *src;
src = (unsigned int *) (cairo_data + y * cairo_rowstride);
dst = pixbuf_data + (dest_y + y) * pixbuf_rowstride +
dest_x * pixbuf_n_channels;
for (x = 0; x < cairo_width; x++)
{
dst[0] = (*src >> 16) & 0xff;
dst[1] = (*src >> 8) & 0xff;
dst[2] = (*src >> 0) & 0xff;
dst += pixbuf_n_channels;
src++;
}
}
delete output_dev;
}
#elif defined (HAVE_SPLASH)
static void
splash_render_to_pixbuf (PopplerPage *page,
int src_x, int src_y,
int src_width, int src_height,
double scale,
GdkPixbuf *pixbuf,
int dest_x, int dest_y)
{
SplashOutputDev *output_dev;
SplashColor white;
......@@ -124,10 +176,6 @@ poppler_page_render_to_pixbuf (PopplerPage *page,
guchar *pixbuf_data, *dst;
int x, y;
g_return_if_fail (POPPLER_IS_PAGE (page));
g_return_if_fail (scale > 0.0);
g_return_if_fail (pixbuf != NULL);
white.rgb8 = splashMakeRGB8 (0xff, 0xff, 0xff);
output_dev = new SplashOutputDev(splashModeRGB8, gFalse, white);
......@@ -178,6 +226,50 @@ poppler_page_render_to_pixbuf (PopplerPage *page,
delete output_dev;
}
#endif
/**
* poppler_page_render_to_pixbuf:
* @page: the page to render from
* @src_x: x coordinate of upper left corner
* @src_y: y coordinate of upper left corner
* @src_width: width of rectangle to render
* @src_height: height of rectangle to render
* @ppp: pixels per point
* @pixbuf: pixbuf to render into
* @dest_x: x coordinate of offset into destination
* @dest_y: y cooridnate of offset into destination
*
* First scale the document to match the specified pixels per point,
* then render the rectangle given by the upper left corner at
* (src_x, src_y) and src_width and src_height. The rectangle is
* rendered into the specified pixmap with the upper left corner
* placed at (dest_x, dest_y).
**/
void
poppler_page_render_to_pixbuf (PopplerPage *page,
int src_x, int src_y,
int src_width, int src_height,
double scale,
GdkPixbuf *pixbuf,
int dest_x, int dest_y)
{
g_return_if_fail (POPPLER_IS_PAGE (page));
g_return_if_fail (scale > 0.0);
g_return_if_fail (pixbuf != NULL);
#if defined(HAVE_CAIRO)
cairo_render_to_pixbuf (page, src_x, src_y, src_width, src_height,
scale, pixbuf, dest_x, dest_y);
#elif defined(HAVE_SPLASH)
splash_render_to_pixbuf (page, src_x, src_y, src_width, src_height,
scale, pixbuf, dest_x, dest_y);
#else
#error No rendering backend available
#endif
}
static void
destroy_thumb_data (guchar *pixels, gpointer data)
{
......
......@@ -252,7 +252,7 @@ CairoFont::matches(Ref &other) {
cairo_font_t *
CairoFont::getFont(cairo_matrix_t *font_scale) {
return cairo_ft_font_create_for_ft_face (face, FT_LOAD_DEFAULT, font_scale);
return cairo_ft_font_create_for_ft_face (face, FT_LOAD_NO_HINTING, font_scale);
}
unsigned long
......
......@@ -64,24 +64,18 @@ CairoOutputDevImage::createCairo(GfxState *state) {
}
SplashBitmap *CairoOutputDevImage::getBitmap() {
void CairoOutputDevImage::getBitmap(unsigned char **data,
int *width, int *height,
int *rowstride) {
SplashBitmap *bitmap;
int w, h;
unsigned char *src;
unsigned int *dest;
bitmap = new SplashBitmap (pixels_w, pixels_h, splashModeRGB8);
for (h = 0; h < pixels_h; h++) {
src = pixels + 4*pixels_w * h;
dest = (unsigned int *)
((unsigned char *)bitmap->getDataPtr().rgb8 + bitmap->getRowSize()*h);
for (w = 0; w < pixels_w; w++) {
*dest++ = splashMakeRGB8 (src[2], src[1], src[0]);
src += 4;
}
}
return bitmap;
*data = pixels;
*width = pixels_w;
*height = pixels_h;
*rowstride = 4 * pixels_w;
}
......@@ -33,7 +33,8 @@ public:
virtual void createCairo(GfxState *state);
SplashBitmap *getBitmap();
void getBitmap(unsigned char **data,
int *width, int *height, int *rowstride);
private:
unsigned char *pixels;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment