summaryrefslogtreecommitdiff
path: root/riscos/png.c
diff options
context:
space:
mode:
Diffstat (limited to 'riscos/png.c')
-rw-r--r--riscos/png.c65
1 files changed, 63 insertions, 2 deletions
diff --git a/riscos/png.c b/riscos/png.c
index 63b9c651d..64a5d7e13 100644
--- a/riscos/png.c
+++ b/riscos/png.c
@@ -12,6 +12,7 @@
#include <stdlib.h>
#include <swis.h>
#include "libpng/png.h"
+#include "oslib/colourtrans.h"
#include "oslib/osspriteop.h"
#include "netsurf/utils/config.h"
#include "netsurf/content/content.h"
@@ -266,12 +267,17 @@ void nspng_destroy(struct content *c)
}
-void nspng_redraw(struct content *c, int x, int y,
+bool nspng_redraw(struct content *c, int x, int y,
int width, int height,
int clip_x0, int clip_y0, int clip_x1, int clip_y1,
float scale)
{
unsigned int tinct_options;
+ unsigned int size;
+ os_factors f;
+ osspriteop_trans_tab *table;
+ _kernel_oserror *e;
+ os_error *error;
/* If we have a gui_window then we work from there, if not we use the global
settings as we are drawing a thumbnail.
@@ -288,10 +294,65 @@ void nspng_redraw(struct content *c, int x, int y,
sprites not matching the required specifications are ignored. See the Tinct
documentation for further information.
*/
- _swix(Tinct_PlotScaledAlpha, _IN(2) | _IN(3) | _IN(4) | _IN(5) | _IN(6) | _IN(7),
+ if (!print_active) {
+ e = _swix(Tinct_PlotScaledAlpha, _INR(2,7),
((char *) c->data.png.sprite_area + c->data.png.sprite_area->first),
x, y - height,
width, height,
tinct_options);
+ if (e) {
+ LOG(("xtinct_plotscaled_alpha: 0x%x: %s", e->errnum, e->errmess));
+ return false;
+ }
+ }
+ else {
+ error = xcolourtrans_generate_table_for_sprite(
+ c->data.png.sprite_area,
+ (osspriteop_id)((char*)c->data.png.sprite_area +
+ c->data.png.sprite_area->first),
+ colourtrans_CURRENT_MODE,
+ colourtrans_CURRENT_PALETTE,
+ 0, colourtrans_GIVEN_SPRITE, 0, 0, &size);
+ if (error) {
+ LOG(("xcolourtrans_generate_table_for_sprite: 0x%x: %s", error->errnum, error->errmess));
+ return false;
+ }
+
+ table = calloc(size, sizeof(char));
+
+ error = xcolourtrans_generate_table_for_sprite(
+ c->data.png.sprite_area,
+ (osspriteop_id)((char*)c->data.png.sprite_area +
+ c->data.png.sprite_area->first),
+ colourtrans_CURRENT_MODE,
+ colourtrans_CURRENT_PALETTE,
+ table, colourtrans_GIVEN_SPRITE, 0, 0, 0);
+ if (error) {
+ LOG(("xcolourtrans_generate_table_for_sprite: 0x%x: %s", error->errnum, error->errmess));
+ return false;
+ }
+
+ f.xmul = width;
+ f.ymul = height;
+ f.xdiv = c->width * 2;
+ f.ydiv = c->height * 2;
+
+ error = xosspriteop_put_sprite_scaled(osspriteop_PTR,
+ c->data.png.sprite_area,
+ (osspriteop_id)((char*)c->data.png.sprite_area +
+ c->data.png.sprite_area->first),
+ x, (int)(y - height),
+ osspriteop_USE_MASK | osspriteop_USE_PALETTE,
+ &f, table);
+ if (error) {
+ LOG(("xosspriteop_put_sprite_scaled: 0x%x: %s", error->errnum, error->errmess));
+ return false;
+ }
+
+
+ free(table);
+ }
+
+ return true;
}
#endif