diff options
author | Antoine Brodin <antoine@FreeBSD.org> | 2014-12-25 14:02:37 +0000 |
---|---|---|
committer | Antoine Brodin <antoine@FreeBSD.org> | 2014-12-25 14:02:37 +0000 |
commit | 2a83ec45e0ec3f4e2dd51678de6dbd9394f16c36 (patch) | |
tree | 3c243f4db96a512d83880f78e59d2270d507a4a3 /news | |
parent | d35737261d875094e80203fa627ea5ed3273d05e (diff) | |
download | ports-2a83ec45e0ec3f4e2dd51678de6dbd9394f16c36.tar.gz ports-2a83ec45e0ec3f4e2dd51678de6dbd9394f16c36.zip |
Notes
Diffstat (limited to 'news')
-rw-r--r-- | news/knews/Makefile | 2 | ||||
-rw-r--r-- | news/knews/files/patch-Imakefile | 2 | ||||
-rw-r--r-- | news/knews/files/patch-png.c | 139 |
3 files changed, 66 insertions, 77 deletions
diff --git a/news/knews/Makefile b/news/knews/Makefile index f5cb7b517813..1ea33e54d2dd 100644 --- a/news/knews/Makefile +++ b/news/knews/Makefile @@ -12,7 +12,7 @@ MAINTAINER= dinoex@FreeBSD.org COMMENT= Threaded nntp newsreader for X LIB_DEPENDS= libjpeg.so:${PORTSDIR}/graphics/jpeg \ - libpng15.so:${PORTSDIR}/graphics/png \ + libpng.so:${PORTSDIR}/graphics/png \ libcompface.so:${PORTSDIR}/mail/faces RUN_DEPENDS= newsp:${PORTSDIR}/print/mp-letter diff --git a/news/knews/files/patch-Imakefile b/news/knews/files/patch-Imakefile index 926c9ba08eaa..ef0e3abf8e54 100644 --- a/news/knews/files/patch-Imakefile +++ b/news/knews/files/patch-Imakefile @@ -5,7 +5,7 @@ #endif -INCLUDES = -I../Widgets $(REGEXP_INCLUDES) $(KNEWS_INCLUDES) -+INCLUDES = -I../Widgets $(REGEXP_INCLUDES) $(KNEWS_INCLUDES) -I${LOCALBASE}/include/libpng15 ++INCLUDES = -I../Widgets $(REGEXP_INCLUDES) $(KNEWS_INCLUDES) -I${LOCALBASE}/include + LOCAL_LIBRARIES = \ diff --git a/news/knews/files/patch-png.c b/news/knews/files/patch-png.c index 22eed8a7c1c3..75a99eecfc2f 100644 --- a/news/knews/files/patch-png.c +++ b/news/knews/files/patch-png.c @@ -1,147 +1,133 @@ ---- src/png.c.orig 1998-11-21 15:55:13.000000000 +0100 -+++ src/png.c 2012-05-06 13:39:28.000000000 +0200 -@@ -20,6 +20,7 @@ - #else +$NetBSD: patch-bd,v 1.3 2011/01/15 19:16:00 tron Exp $ + +Fix build with png-1.5. + +--- src/png.c.orig 1998-11-21 14:55:13.000000000 +0000 ++++ src/png.c 2011-01-15 19:09:09.000000000 +0000 +@@ -78,8 +78,8 @@ - #include <png.h> -+#include <pngpriv.h> - #include <setjmp.h> - - static unsigned int p_cmap_inited = False; -@@ -76,10 +77,16 @@ - return fp; - } - -+static Pixmap rep_fail(const char *e) { -+ ArtTextAddLine(main_widgets.text, e, ascii_font->body_font, -+ global.alert_pixel); -+ return None; -+} -+ Pixmap do_png(char *data, long len, long *wp, long *hp) { - png_struct p_str; - png_info p_info; -+ png_structp png_ptr; -+ png_infop info_ptr; ++ png_struct *p_str = NULL; ++ png_info *p_info = NULL; Pixmap pixmap; FILE *volatile vol_fp = NULL; void *volatile vol_pic = NULL; -@@ -92,13 +99,21 @@ - - init_png_cmap(); - -- if (!(vol_fp = dump_for_png(data, len))) { -- ArtTextAddLine(main_widgets.text, "[knews: temp file error.]", -- ascii_font->body_font, global.alert_pixel); -- return None; -+ if (!(vol_fp = dump_for_png(data, len))) -+ return rep_fail("[knews: temp file error.]"); -+ -+ png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, -+ NULL, NULL, NULL); -+ if (!png_ptr) -+ return rep_fail("[knews: can't allocate PNG structure.]"); -+ info_ptr = png_create_info_struct(png_ptr); -+ if (!info_ptr) { -+ png_destroy_read_struct(&png_ptr, -+ (png_infopp)NULL, (png_infopp)NULL); -+ return rep_fail("[knews: can't PNG info structure.]"); +@@ -98,7 +98,11 @@ + return None; } - if (setjmp(p_str.jmpbuf)) -+ if (setjmp(png_jmpbuf(png_ptr))) ++ if ((p_str = (png_struct *) png_create_read_struct(PNG_LIBPNG_VER_STRING, ++ NULL, NULL, NULL))) ++ p_info = (png_info *) png_create_info_struct(p_str); ++ ++ if (p_str && p_info && setjmp(png_jmpbuf(p_str))) ArtTextAddLine(main_widgets.text, "[knews: png error.]", ascii_font->body_font, global.alert_pixel); else { -@@ -108,58 +123,55 @@ +@@ -107,59 +111,63 @@ + int did; unsigned int per_line = 0; unsigned int i, j, pass; ++ png_color_16p background; ++ png_byte color_type; ++ png_colorp palette; ++ int num_palette; ++ ++ png_init_io(p_str, vol_fp); ++ png_read_info(p_str, p_info); ++ ++ vol_w = w = png_get_image_width(p_str, p_info); ++ vol_h = h = png_get_image_height(p_str, p_info); ++ ++ if (png_get_bit_depth(p_str, p_info) == 16) ++ png_set_strip_16(p_str); ++ else if (png_get_bit_depth(p_str, p_info) < 8) ++ png_set_packing(p_str); - png_read_init(&p_str); - png_info_init(&p_info); - - png_init_io(&p_str, vol_fp); - png_read_info(&p_str, &p_info); -+ png_init_io(png_ptr, vol_fp); -+ png_read_info(png_ptr, info_ptr); - +- - vol_w = w = p_info.width; - vol_h = h = p_info.height; -+ vol_w = w = info_ptr->width; -+ vol_h = h = info_ptr->height; - +- - if (p_info.bit_depth == 16) - png_set_strip_16(&p_str); - else if (p_info.bit_depth < 8) - png_set_packing(&p_str); -+ if (info_ptr->bit_depth == 16) -+ png_set_strip_16(png_ptr); -+ else if (info_ptr->bit_depth < 8) -+ png_set_packing(png_ptr); - +- - if (p_info.valid & PNG_INFO_bKGD) - png_set_background(&p_str, &p_info.background, -+ if (info_ptr->valid & PNG_INFO_bKGD) -+ png_set_background(png_ptr, &info_ptr->background, ++ if (png_get_bKGD(p_str, p_info, &background) & PNG_INFO_bKGD) ++ png_set_background(p_str, background, PNG_BACKGROUND_GAMMA_FILE, True, 1.0); else { static png_color_16 bg = {0, }; - png_set_background(&p_str, &bg, -+ png_set_background(png_ptr, &bg, ++ png_set_background(p_str, &bg, PNG_BACKGROUND_GAMMA_SCREEN, False, 1.0); } per_line = w; - if (!(p_info.color_type & PNG_COLOR_MASK_COLOR)) { /* grey image */ -+ if (!(info_ptr->color_type & PNG_COLOR_MASK_COLOR)) { /* grey image */ ++ color_type = png_get_color_type(p_str, p_info); ++ if (!(color_type & PNG_COLOR_MASK_COLOR)) { /* grey image */ grey = True; - png_set_expand(&p_str); -+ png_set_expand(png_ptr); ++ png_set_expand(p_str); } else if (!p_cmap) { /* true color visual */ - if (p_info.color_type == PNG_COLOR_TYPE_PALETTE) - png_set_expand(&p_str); -+ if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) -+ png_set_expand(png_ptr); ++ if (color_type == PNG_COLOR_TYPE_PALETTE) ++ png_set_expand(p_str); per_line *= 3; - } else if (p_info.color_type & PNG_COLOR_MASK_PALETTE) { -+ } else if (info_ptr->color_type & PNG_COLOR_MASK_PALETTE) { ++ } else if (color_type & PNG_COLOR_MASK_PALETTE && ++ png_get_PLTE(p_str, p_info, ++ &palette, &num_palette) & PNG_INFO_PLTE) { CMAP_ENTRY *pal; int i, pn; - pn = p_info.num_palette; -+ pn = info_ptr->num_palette; ++ pn = num_palette; pal = (CMAP_ENTRY *)XtMalloc(pn * sizeof *pal); for (i = 0 ; i < pn ; i++) { - pal[i].r = p_info.palette[i].red; - pal[i].g = p_info.palette[i].green; - pal[i].b = p_info.palette[i].blue; -+ pal[i].r = info_ptr->palette[i].red; -+ pal[i].g = info_ptr->palette[i].green; -+ pal[i].b = info_ptr->palette[i].blue; ++ pal[i].r = palette[i].red; ++ pal[i].g = palette[i].green; ++ pal[i].b = palette[i].blue; } vol_pal = pal; vol_pn = pn; } else { - png_set_dither(&p_str, p_cmap, cmap_size, -+ png_set_quantize(png_ptr, p_cmap, cmap_size, - cmap_size, NULL, True); +- cmap_size, NULL, True); ++ png_set_quantize(p_str, p_cmap, cmap_size, ++ cmap_size, NULL, True); } - pass = png_set_interlace_handling(&p_str); - png_start_read_image(&p_str); -+ pass = png_set_interlace_handling(png_ptr); -+ png_start_read_image(png_ptr); ++ pass = png_set_interlace_handling(p_str); ++ png_start_read_image(p_str); vol_pic = pic = (unsigned char *)XtMalloc(h * per_line); -@@ -167,14 +179,14 @@ +@@ -167,14 +175,14 @@ for (i = 0 ; i < pass ; i++) { row = pic; for (j = 0 ; j < h ; j++) { - png_read_row(&p_str, NULL, row); -+ png_read_row(png_ptr, NULL, row); ++ png_read_row(p_str, NULL, row); if (!did) vol_did = did = True; row += per_line; @@ -149,16 +135,19 @@ } - png_read_end(&p_str, NULL); -+ png_read_end(png_ptr, NULL); ++ png_read_end(p_str, NULL); } if (!vol_did) -@@ -204,7 +216,7 @@ +@@ -204,7 +212,10 @@ } } - png_read_destroy(&p_str, &p_info, NULL); -+ png_read_destroy(png_ptr, info_ptr, NULL); ++ if (p_info) ++ png_destroy_read_struct(&p_str, &p_info, NULL); ++ else ++ png_destroy_read_struct(&p_str, NULL, NULL); fclose((FILE *)vol_fp); XtFree((char *)vol_pic); XtFree((char *)vol_pal); |