summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Bursa <james@netsurf-browser.org>2003-06-30 15:57:08 +0000
committerJames Bursa <james@netsurf-browser.org>2003-06-30 15:57:08 +0000
commit4496d3cdbda65edafc72a81380e6f914ff40451f (patch)
treeb5ae6a2f481e10a72b28238801d78340c0f8d2bb
parent58267e14fde3fe1ead0579e5517602d1482bde97 (diff)
downloadnetsurf-4496d3cdbda65edafc72a81380e6f914ff40451f.tar.gz
netsurf-4496d3cdbda65edafc72a81380e6f914ff40451f.tar.bz2
[project @ 2003-06-30 15:57:08 by bursa]
Fix interlaced PNG display. svn path=/import/netsurf/; revision=192
-rw-r--r--content/content.h1
-rw-r--r--riscos/png.c30
2 files changed, 24 insertions, 7 deletions
diff --git a/content/content.h b/content/content.h
index 724e9305e..786013938 100644
--- a/content/content.h
+++ b/content/content.h
@@ -140,6 +140,7 @@ struct content
png_structp png;
png_infop info;
unsigned long rowbytes;
+ int interlace;
osspriteop_area *sprite_area;
char *sprite_image;
enum { PNG_PALETTE, PNG_DITHER, PNG_DEEP } type;
diff --git a/riscos/png.c b/riscos/png.c
index 8845fd02f..96d049b59 100644
--- a/riscos/png.c
+++ b/riscos/png.c
@@ -110,7 +110,7 @@ void info_callback(png_structp png, png_infop info)
png_get_PLTE(png, info, &png_palette, &palette_size);
if (interlace == PNG_INTERLACE_ADAM7)
- png_set_interlace_handling(png);
+ ; /*png_set_interlace_handling(png);*/
if (png_get_bKGD(png, info, &png_background))
png_set_background(png, png_background,
@@ -205,6 +205,7 @@ void info_callback(png_structp png, png_infop info)
png_read_update_info(png, 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;
@@ -214,11 +215,17 @@ void info_callback(png_structp png, png_infop info)
}
+static unsigned int interlace_start[8] = {0, 4, 0, 2, 0, 1, 0};
+static unsigned int interlace_step[8] = {8, 8, 4, 4, 2, 2, 1};
+static unsigned int interlace_row_start[8] = {0, 0, 4, 0, 2, 0, 1};
+static unsigned int interlace_row_step[8] = {8, 8, 8, 4, 4, 2, 2};
+
void row_callback(png_structp png, png_bytep new_row,
png_uint_32 row_num, int pass)
{
struct content *c = png_get_progressive_ptr(png);
- unsigned long i, rowbytes = c->data.png.rowbytes;
+ unsigned long i, j, rowbytes = c->data.png.rowbytes;
+ unsigned int start = 0, step = 1;
int red, green, blue, alpha;
char *row = c->data.png.sprite_image + row_num * ((c->width + 3) & ~3u);
os_colour_number col;
@@ -229,14 +236,23 @@ void row_callback(png_structp png, png_bytep new_row,
if (new_row == 0)
return;
+ if (c->data.png.interlace) {
+ start = interlace_start[pass];
+ step = interlace_step[pass];
+ row_num = interlace_row_start[pass] +
+ interlace_row_step[pass] * row_num;
+ row = c->data.png.sprite_image + row_num * ((c->width + 3) & ~3u);
+ }
+
if (c->data.png.type == PNG_PALETTE)
- png_progressive_combine_row(png, row, new_row);
+ for (j = 0, i = start; i < rowbytes; i += step)
+ row[i] = new_row[j++];
else if (c->data.png.type == PNG_DITHER) {
- for (i = 0; i * 3 != rowbytes; i++) {
- red = new_row[i * 3];
- green = new_row[i * 3 + 1];
- blue = new_row[i * 3 + 2];
+ for (j = 0, i = start; i * 3 < rowbytes; i += step) {
+ red = new_row[j++];
+ green = new_row[j++];
+ blue = new_row[j++];
row[i] = colour_table[(red >> 4) << 8 |
(green >> 4) << 4 |
(blue >> 4)];