From 7897a98a4c7475e116f406ab173139c959d6dfb6 Mon Sep 17 00:00:00 2001 From: James Bursa Date: Wed, 25 Feb 2004 15:12:58 +0000 Subject: [project @ 2004-02-25 15:12:57 by bursa] Implement scaling; rewrite desktop/browser; add riscos/thumbnail; rewrite history. svn path=/import/netsurf/; revision=566 --- riscos/thumbnail.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 riscos/thumbnail.c (limited to 'riscos/thumbnail.c') diff --git a/riscos/thumbnail.c b/riscos/thumbnail.c new file mode 100644 index 000000000..2f5b8d868 --- /dev/null +++ b/riscos/thumbnail.c @@ -0,0 +1,68 @@ +/* + * This file is part of NetSurf, http://netsurf.sourceforge.net/ + * Licensed under the GNU General Public License, + * http://www.opensource.org/licenses/gpl-license + * Copyright 2004 James Bursa + */ + +/** \file + * Page thumbnail creation (implementation). + * + * Thumbnails are created by redirecting output to a sprite and rendering the + * page at a small scale. + */ + +#include "oslib/colourtrans.h" +#include "oslib/osspriteop.h" +#include "netsurf/content/content.h" +#include "netsurf/riscos/thumbnail.h" +#include "netsurf/utils/log.h" + + +/** + * Create a thumbnail of a page. + * + * \param content content structure to thumbnail + * \param area sprite area containing thumbnail sprite + * \param sprite pointer to sprite + * \param width sprite width / pixels + * \param height sprite height / pixels + * + * The thumbnail is rendered in the given sprite. + */ + +void thumbnail_create(struct content *content, osspriteop_area *area, + osspriteop_header *sprite, int width, int height) +{ + float scale; + os_error *error; + + scale = (float) width / (float) content->width; + + /* switch output to sprite */ + error = xosspriteop_switch_output_to_sprite(osspriteop_PTR, area, + (osspriteop_id) sprite, 0, 0, 0, 0, 0); + if (error) { + LOG(("xosspriteop_switch_output_to_sprite failed: %s", + error->errmess)); + return; + } + + /* clear background to white */ + colourtrans_set_gcol(os_COLOUR_WHITE, colourtrans_SET_BG, + os_ACTION_OVERWRITE, 0); + os_clg(); + + /* render content */ + content_redraw(content, 0, height * 2, width * 2, height * 2, + 0, 0, width * 2, height * 2, scale); + + /* switch output back to screen */ + error = xosspriteop_switch_output_to_sprite(osspriteop_PTR, area, + 0, 0, 0, 0, 0, 0); + if (error) { + LOG(("xosspriteop_switch_output_to_sprite failed: %s", + error->errmess)); + return; + } +} -- cgit v1.2.3