diff options
-rw-r--r-- | image/jpeg.c | 7 | ||||
-rw-r--r-- | image/png.c (renamed from riscos/png.c) | 67 | ||||
-rw-r--r-- | image/png.h (renamed from riscos/png.h) | 12 | ||||
-rw-r--r-- | riscos/bitmap.c | 6 | ||||
-rw-r--r-- | riscos/bitmap.h | 17 | ||||
-rw-r--r-- | riscos/htmlredraw.c | 17 | ||||
-rw-r--r-- | riscos/save_draw.c | 26 |
7 files changed, 72 insertions, 80 deletions
diff --git a/image/jpeg.c b/image/jpeg.c index 85711bd2e..47a8f4b5e 100644 --- a/image/jpeg.c +++ b/image/jpeg.c @@ -122,7 +122,12 @@ bool nsjpeg_convert(struct content *c, int w, int h) scanlines[0][i * 4 + 2] = b; scanlines[0][i * 4 + 3] = 0xff; } - +#else + /* make fully opaque for alpha plotting + * (is there a better way?) */ + for (int i = width - 1; 0 <= i; i--) { + scanlines[0][i * 4 + 3] = 0xff; + } #endif } while (cinfo.output_scanline != cinfo.output_height); diff --git a/riscos/png.c b/image/png.c index 8d6ae8265..5fa4d9af7 100644 --- a/riscos/png.c +++ b/image/png.c @@ -11,13 +11,10 @@ #include <string.h> #include <stdlib.h> #include "libpng/png.h" -#include "oslib/osspriteop.h" #include "netsurf/utils/config.h" #include "netsurf/content/content.h" -#include "netsurf/riscos/gui.h" -#include "netsurf/riscos/image.h" -#include "netsurf/riscos/options.h" -#include "netsurf/riscos/png.h" +#include "netsurf/image/bitmap.h" +#include "netsurf/image/png.h" #include "netsurf/utils/log.h" #include "netsurf/utils/messages.h" #include "netsurf/utils/utils.h" @@ -35,7 +32,6 @@ bool nspng_create(struct content *c, const char *params[]) { union content_msg_data msg_data; - c->data.png.sprite_area = 0; c->data.png.png = png_create_read_struct(PNG_LIBPNG_VER_STRING, 0, 0, 0); if (!c->data.png.png) { @@ -105,11 +101,10 @@ void info_callback(png_structp png, png_infop info) { int bit_depth, color_type, interlace, intent; double gamma; - unsigned int rowbytes, sprite_size; + unsigned int rowbytes; unsigned long width, height; struct content *c = png_get_progressive_ptr(png); - osspriteop_area *sprite_area; - osspriteop_header *sprite; + union content_msg_data msg_data; /* Read the PNG details */ @@ -118,32 +113,13 @@ void info_callback(png_structp png, png_infop info) /* Claim the required memory for the converted PNG */ - sprite_size = sizeof(*sprite_area) + sizeof(*sprite) + (height * width * 4); - sprite_area = xcalloc(sprite_size, 1); - - /* Fill in the sprite area header information - */ - sprite_area->size = sprite_size; - sprite_area->sprite_count = 1; - sprite_area->first = sizeof(*sprite_area); - sprite_area->used = sprite_size; - - /* Fill in the sprite header information - */ - sprite = (osspriteop_header *) (sprite_area + 1); - sprite->size = sprite_size - sizeof(*sprite_area); - memset(sprite->name, 0x00, 12); - strcpy(sprite->name, "png"); - sprite->width = width - 1; - sprite->height = height - 1; - sprite->left_bit = 0; - sprite->right_bit = 31; - sprite->mask = sprite->image = sizeof(*sprite); - sprite->mode = (os_mode) 0x301680b5; - - /* Store the sprite area - */ - c->data.png.sprite_area = sprite_area; + c->bitmap = bitmap_create(width, height); + if (!c->bitmap) { + msg_data.error = messages_get("NoMemory"); + content_broadcast(c, CONTENT_MSG_ERROR, msg_data); + LOG(("Insufficient memory to create canvas.")); + return; + } /* Set up our transformations */ @@ -178,7 +154,6 @@ void info_callback(png_structp png, png_infop info) c->data.png.rowbytes = rowbytes = png_get_rowbytes(png, info); c->data.png.interlace = (interlace == PNG_INTERLACE_ADAM7); - c->data.png.sprite_image = ((char *) sprite) + sprite->image; c->width = width; c->height = height; @@ -198,7 +173,8 @@ void row_callback(png_structp png, png_bytep new_row, struct content *c = png_get_progressive_ptr(png); unsigned long i, j, rowbytes = c->data.png.rowbytes; unsigned int start, step; - char *row = c->data.png.sprite_image + row_num * (c->width * 4); + char *row = bitmap_get_buffer(c->bitmap) + + bitmap_get_rowstride(c->bitmap) * row_num; /* Abort if we've not got any data */ @@ -215,7 +191,8 @@ void row_callback(png_structp png, png_bytep new_row, /* Copy the data to our current row taking into consideration interlacing */ - row = c->data.png.sprite_image + row_num * (c->width * 4); + row = bitmap_get_buffer(c->bitmap) + + bitmap_get_rowstride(c->bitmap) * row_num; for (j = 0, i = start; i < rowbytes; i += step) { row[i++] = new_row[j++]; row[i++] = new_row[j++]; @@ -262,17 +239,7 @@ bool nspng_convert(struct content *c, int width, int height) void nspng_destroy(struct content *c) { free(c->title); - free(c->data.png.sprite_area); -} - - -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 long background_colour) -{ - return image_redraw(c->data.png.sprite_area, x, y, width, height, - c->width * 2, c->height * 2, background_colour, - false, false, IMAGE_PLOT_TINCT_ALPHA); + if (c->bitmap) + bitmap_destroy(c->bitmap); } #endif diff --git a/riscos/png.h b/image/png.h index b9cc784c0..5cf0eb3c1 100644 --- a/riscos/png.h +++ b/image/png.h @@ -5,11 +5,10 @@ * Copyright 2003 James Bursa <bursa@users.sourceforge.net> */ -#ifndef _NETSURF_RISCOS_PNG_H_ -#define _NETSURF_RISCOS_PNG_H_ +#ifndef _NETSURF_IMAGE_PNG_H_ +#define _NETSURF_IMAGE_PNG_H_ #include "libpng/png.h" -#include "oslib/osspriteop.h" struct content; @@ -18,16 +17,11 @@ struct content_png_data { png_infop info; unsigned long rowbytes; int interlace; - osspriteop_area *sprite_area; - char *sprite_image; }; bool nspng_create(struct content *c, const char *params[]); bool nspng_process_data(struct content *c, char *data, unsigned int size); bool nspng_convert(struct content *c, int width, int height); void nspng_destroy(struct content *c); -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 long background_colour); + #endif diff --git a/riscos/bitmap.c b/riscos/bitmap.c index 2b705b8d4..892aed3b6 100644 --- a/riscos/bitmap.c +++ b/riscos/bitmap.c @@ -18,16 +18,12 @@ #include "oslib/osspriteop.h"
#include "netsurf/content/content.h"
#include "netsurf/image/bitmap.h"
+#include "netsurf/riscos/bitmap.h"
#include "netsurf/riscos/image.h"
#include "netsurf/utils/log.h"
#include "netsurf/utils/utils.h"
-struct bitmap {
- osspriteop_area sprite_area;
-};
-
-
/**
* Create a bitmap.
*
diff --git a/riscos/bitmap.h b/riscos/bitmap.h new file mode 100644 index 000000000..4c8545cb4 --- /dev/null +++ b/riscos/bitmap.h @@ -0,0 +1,17 @@ +/* + * 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 <bursa@users.sourceforge.net> + */ + +#ifndef _NETSURF_RISCOS_BITMAP_H_ +#define _NETSURF_RISCOS_BITMAP_H_ + +struct osspriteop_area; + +struct bitmap { + osspriteop_area sprite_area; +}; + +#endif diff --git a/riscos/htmlredraw.c b/riscos/htmlredraw.c index 20d50fb5f..6dfc0b220 100644 --- a/riscos/htmlredraw.c +++ b/riscos/htmlredraw.c @@ -25,6 +25,7 @@ #include "netsurf/render/font.h" #include "netsurf/render/form.h" #include "netsurf/render/html.h" +#include "netsurf/riscos/bitmap.h" #include "netsurf/riscos/gui.h" #include "netsurf/riscos/image.h" #include "netsurf/riscos/options.h" @@ -1010,38 +1011,38 @@ bool html_redraw_background(int xi, int yi, int width, int height, /* and plot the image */ switch (box->background->type) { #ifdef WITH_PNG - case CONTENT_PNG:/* - image_redraw(box->background->data.png.sprite_area, + case CONTENT_PNG: + image_redraw(&box->background->bitmap->sprite_area, x, y, image_width, image_height, box->background->width * 2, box->background->height * 2, background_colour, repeat_x, repeat_y, - IMAGE_PLOT_TINCT_ALPHA);*/ + IMAGE_PLOT_TINCT_ALPHA); break; #endif #ifdef WITH_MNG case CONTENT_JNG: case CONTENT_MNG: - /*image_redraw(box->background->data.mng.sprite_area, + image_redraw(&box->background->bitmap->sprite_area, x, y, image_width, image_height, box->background->width * 2, box->background->height * 2, background_colour, repeat_x, repeat_y, - IMAGE_PLOT_TINCT_ALPHA);*/ + IMAGE_PLOT_TINCT_ALPHA); break; #endif #ifdef WITH_JPEG - case CONTENT_JPEG:/* - image_redraw(box->background->data.jpeg.sprite_area, + case CONTENT_JPEG: + image_redraw(&box->background->bitmap->sprite_area, x, y, image_width, image_height, box->background->width * 2, box->background->height * 2, background_colour, repeat_x, repeat_y, IMAGE_PLOT_TINCT_OPAQUE); - */break; + break; #endif #ifdef WITH_GIF case CONTENT_GIF: diff --git a/riscos/save_draw.c b/riscos/save_draw.c index e00ad3350..297cc34d2 100644 --- a/riscos/save_draw.c +++ b/riscos/save_draw.c @@ -25,6 +25,7 @@ #include "netsurf/render/font.h" #include "netsurf/render/form.h" #include "netsurf/render/layout.h" +#include "netsurf/riscos/bitmap.h" #include "netsurf/riscos/save_draw.h" #include "netsurf/utils/log.h" #include "netsurf/utils/utils.h" @@ -595,7 +596,9 @@ static bool add_box(struct box *box, colour cbc, int x, int y) if (box->object) { switch (box->object->type) { +#ifdef WITH_JPEG case CONTENT_JPEG: +#endif #ifdef WITH_PNG case CONTENT_PNG: #endif @@ -603,7 +606,9 @@ static bool add_box(struct box *box, colour cbc, int x, int y) case CONTENT_JNG: case CONTENT_MNG: #endif +#ifdef WITH_GIF case CONTENT_GIF: +#endif #ifdef WITH_SPRITE case CONTENT_SPRITE: #endif @@ -702,24 +707,27 @@ static bool add_graphic(struct content *content, struct box *box, /* cast-tastic... */ switch (content->type) { +#ifdef WITH_JPEG case CONTENT_JPEG: - return true; - /*sprite_length = ((osspriteop_header*)((char*)content->data.jpeg.sprite_area+content->data.jpeg.sprite_area->first))->size;*/ + sprite_length = ((osspriteop_header*)((char*)&content->bitmap->sprite_area+content->bitmap->sprite_area.first))->size; break; +#endif #ifdef WITH_PNG case CONTENT_PNG: - /*sprite_length = ((osspriteop_header*)((char*)content->data.png.sprite_area+content->data.png.sprite_area->first))->size;*/ + sprite_length = ((osspriteop_header*)((char*)&content->bitmap->sprite_area+content->bitmap->sprite_area.first))->size; break; #endif #ifdef WITH_MNG case CONTENT_JNG: case CONTENT_MNG: - /*sprite_length = ((osspriteop_header*)((char*)content->data.mng.sprite_area+content->data.mng.sprite_area->first))->size;*/ + sprite_length = ((osspriteop_header*)((char*)&content->bitmap->sprite_area+content->bitmap->sprite_area.first))->size; break; #endif +#ifdef WITH_GIF case CONTENT_GIF: sprite_length = ((osspriteop_header*)((char*)content->data.gif.gif->frame_image+content->data.gif.gif->frame_image->first))->size; break; +#endif #ifdef WITH_SPRITE case CONTENT_SPRITE: sprite_length = ((osspriteop_header*)((char*)content->data.sprite.data+(((osspriteop_area*)content->data.sprite.data)->first)))->size; @@ -742,23 +750,27 @@ static bool add_graphic(struct content *content, struct box *box, ds->bbox.y1 = y; switch (content->type) { +#ifdef WITH_JPEG case CONTENT_JPEG: - /*memcpy((char*)ds+16, (char*)content->data.jpeg.sprite_area+content->data.jpeg.sprite_area->first, (unsigned)sprite_length);*/ + memcpy((char*)ds+16, (char*)&content->bitmap->sprite_area+content->bitmap->sprite_area.first, (unsigned)sprite_length); break; +#endif #ifdef WITH_PNG case CONTENT_PNG: - /*memcpy((char*)ds+16, (char*)content->data.png.sprite_area+content->data.png.sprite_area->first, (unsigned)sprite_length);*/ + memcpy((char*)ds+16, (char*)&content->bitmap->sprite_area+content->bitmap->sprite_area.first, (unsigned)sprite_length); break; #endif #ifdef WITH_MNG case CONTENT_JNG: case CONTENT_MNG: - /*memcpy((char*)ds+16, (char*)content->data.mng.sprite_area+content->data.mng.sprite_area->first, (unsigned)sprite_length);*/ + memcpy((char*)ds+16, (char*)&content->bitmap->sprite_area+content->bitmap->sprite_area.first, (unsigned)sprite_length); break; #endif +#ifdef WITH_GIF case CONTENT_GIF: memcpy((char*)ds+16, (char*)content->data.gif.gif->frame_image+content->data.gif.gif->frame_image->first, (unsigned)sprite_length); break; +#endif #ifdef WITH_SPRITE case CONTENT_SPRITE: memcpy((char*)ds+16, (char*)content->data.sprite.data+((osspriteop_area*)content->data.sprite.data)->first, (unsigned)sprite_length); |