summaryrefslogtreecommitdiff
path: root/network/mosaic-ck/mosaic_png_fix.diff
diff options
context:
space:
mode:
authorB. Watson <yalhcru@gmail.com>2016-10-28 23:35:33 +0700
committerWilly Sudiarto Raharjo <willysr@slackbuilds.org>2016-10-28 23:36:03 +0700
commit5254595706a3c2ba807a0f405075457698e73d29 (patch)
tree610cbc57e946388db7ff165920b1949e4a0e0019 /network/mosaic-ck/mosaic_png_fix.diff
parent07d84c0c1fbe4d45527dd0131cf8ba65cdf3c225 (diff)
downloadslackbuilds-5254595706a3c2ba807a0f405075457698e73d29.tar.gz
network/mosaic-ck: Added (Cameron Kaiser's fork of NCSA Mosaic).
Signed-off-by: Willy Sudiarto Raharjo <willysr@slackbuilds.org>
Diffstat (limited to 'network/mosaic-ck/mosaic_png_fix.diff')
-rw-r--r--network/mosaic-ck/mosaic_png_fix.diff310
1 files changed, 310 insertions, 0 deletions
diff --git a/network/mosaic-ck/mosaic_png_fix.diff b/network/mosaic-ck/mosaic_png_fix.diff
new file mode 100644
index 0000000000..322f203d77
--- /dev/null
+++ b/network/mosaic-ck/mosaic_png_fix.diff
@@ -0,0 +1,310 @@
+diff -Naur mosaic-ck/src/readPNG.c mosaic-ck.patched/src/readPNG.c
+--- mosaic-ck/src/readPNG.c 2009-04-25 14:26:02.000000000 -0400
++++ mosaic-ck.patched/src/readPNG.c 2016-10-28 03:24:50.970270499 -0400
+@@ -1,5 +1,3 @@
+-/* Changes for Mosaic-CK (C)2009 Cameron Kaiser */
+-
+ /****************************************************************************
+ * NCSA Mosaic for the X Window System *
+ * Software Development Group *
+@@ -96,7 +94,15 @@
+ png_struct *png_ptr;
+ png_info *info_ptr;
+
+- double screen_gamma;
++ png_uint_32 raw_width, raw_height, rowbytes;
++ int bit_depth, color_type, interlace_type, compression_type, filter_type;
++
++ png_uint_32 have_palette;
++ png_colorp palette;
++ int num_palette;
++ png_uint_16p hist = NULL;
++
++ double gamma, screen_gamma;
+
+ png_byte *png_pixels=NULL, **row_pointers=NULL;
+ int i, j;
+@@ -117,9 +123,9 @@
+ if(ret != 8)
+ return 0;
+
+- ret = png_check_sig(buf, 8);
++ ret = png_sig_cmp(buf, 0, 8);
+
+- if(!ret)
++ if(ret)
+ return(0);
+ }
+
+@@ -128,18 +134,20 @@
+ rewind(infile);
+
+ /* allocate the structures */
++ /*png_ptr = (png_struct *)malloc(sizeof(png_struct));*/
+ png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
+ if(!png_ptr)
+ return 0;
+
+- info_ptr = (png_info *)malloc(sizeof(png_info));
++ /* initialize the structures */
++ info_ptr = png_create_info_struct(png_ptr);
+ if(!info_ptr) {
+- png_destroy_read_struct(&png_ptr, NULL, NULL);
++ /*free(png_ptr);*/
+ return 0;
+ }
+
+ /* Establish the setjmp return context for png_error to use. */
+- if (setjmp(png_ptr->jmpbuf)) {
++ if (setjmp(png_jmpbuf(png_ptr))) {
+
+ #ifndef DISABLE_TRACE
+ if (srcTrace) {
+@@ -147,19 +155,26 @@
+ }
+ #endif
+
++ /*png_read_destroy(png_ptr, info_ptr, (png_info *)0); */
+ png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
+
+ if(png_pixels != NULL)
+ free((char *)png_pixels);
+ if(row_pointers != NULL)
+ free((png_byte **)row_pointers);
+- png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
++
++ /*free((char *)png_ptr);*/
++ free((char *)info_ptr);
+
+ return 0;
+ }
+
+- /* initialize the structure */
+- png_info_init(info_ptr);
++#ifdef SAM_NO
++ /* SWP -- Hopefully to fix cores on bad PNG files */
++ png_set_message_fn(png_ptr,png_get_msg_ptr(png_ptr),NULL,NULL);
++#endif
++
++ /*png_read_init(png_ptr);*/
+
+ /* set up the input control */
+ png_init_io(png_ptr, infile);
+@@ -169,20 +184,26 @@
+
+ /* setup other stuff using the fields of png_info. */
+
+- *width = (int)png_ptr->width;
+- *height = (int)png_ptr->height;
++ png_get_IHDR(png_ptr, info_ptr, &raw_width, &raw_height, &bit_depth,
++ &color_type, &interlace_type, &compression_type,
++ &filter_type);
++ rowbytes = png_get_rowbytes(png_ptr, info_ptr);
++ have_palette = png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette);
++
++ *width = (int)raw_width;
++ *height = (int)raw_height;
+
+ #ifndef DISABLE_TRACE
+ if (srcTrace) {
+- fprintf(stderr,"\n\nBEFORE\nheight = %d\n", (int)png_ptr->width);
+- fprintf(stderr,"width = %d\n", (int)png_ptr->height);
+- fprintf(stderr,"bit depth = %d\n", info_ptr->bit_depth);
+- fprintf(stderr,"color type = %d\n", info_ptr->color_type);
+- fprintf(stderr,"compression type = %d\n", info_ptr->compression_type);
+- fprintf(stderr,"filter type = %d\n", info_ptr->filter_type);
+- fprintf(stderr,"interlace type = %d\n", info_ptr->interlace_type);
+- fprintf(stderr,"num colors = %d\n",info_ptr->num_palette);
+- fprintf(stderr,"rowbytes = %d\n", info_ptr->rowbytes);
++ fprintf(stderr,"\n\nBEFORE\nwidth = %d\n", *width);
++ fprintf(stderr,"height = %d\n", *height);
++ fprintf(stderr,"bit depth = %d\n", bit_depth);
++ fprintf(stderr,"color type = %d\n", color_type);
++ fprintf(stderr,"compression type = %d\n", compression_type);
++ fprintf(stderr,"filter type = %d\n", filter_type);
++ fprintf(stderr,"interlace type = %d\n", interlace_type);
++ fprintf(stderr,"num colors = %d\n", num_palette);
++ fprintf(stderr,"rowbytes = %d\n", rowbytes);
+ }
+ #endif
+
+@@ -205,16 +226,16 @@
+ #endif
+
+ /* strip pixels in 16-bit images down to 8 bits */
+- if (info_ptr->bit_depth == 16)
++ if (bit_depth == 16)
+ png_set_strip_16(png_ptr);
+
+
+ /* If it is a color image then check if it has a palette. If not
+ then dither the image to 256 colors, and make up a palette */
+- if (info_ptr->color_type==PNG_COLOR_TYPE_RGB ||
+- info_ptr->color_type==PNG_COLOR_TYPE_RGB_ALPHA) {
++ if (color_type==PNG_COLOR_TYPE_RGB ||
++ color_type==PNG_COLOR_TYPE_RGB_ALPHA) {
+
+- if(! (info_ptr->valid & PNG_INFO_PLTE)) {
++ if(!have_palette) {
+
+ #ifndef DISABLE_TRACE
+ if (srcTrace) {
+@@ -232,9 +253,7 @@
+
+ /* this should probably be dithering to
+ Rdata.colors_per_inlined_image colors */
+- png_set_dither(png_ptr, std_color_cube,
+- 216,
+- 216, NULL, 1);
++ png_set_quantize(png_ptr, std_color_cube, 216, 216, NULL, 1);
+
+ } else {
+ #ifndef DISABLE_TRACE
+@@ -243,10 +262,9 @@
+ }
+ #endif
+
+- png_set_dither(png_ptr, info_ptr->palette,
+- info_ptr->num_palette,
+- get_pref_int(eCOLORS_PER_INLINED_IMAGE),
+- info_ptr->hist, 1);
++ png_get_hIST(png_ptr, info_ptr, &hist);
++ png_set_quantize(png_ptr, palette, num_palette,
++ get_pref_int(eCOLORS_PER_INLINED_IMAGE), hist, 1);
+
+ }
+ }
+@@ -255,14 +273,14 @@
+ small as they can. This expands pixels to 1 pixel per byte, and
+ if a transparency value is supplied, an alpha channel is
+ built.*/
+- if (info_ptr->bit_depth < 8)
++ if (bit_depth < 8)
+ png_set_packing(png_ptr);
+
+
+ /* have libpng handle the gamma conversion */
+
+ if (get_pref_boolean(eUSE_SCREEN_GAMMA)) { /*SWP*/
+- if (info_ptr->bit_depth != 16) { /* temporary .. glennrp */
++ if (bit_depth != 16) { /* temporary .. glennrp */
+ screen_gamma=(double)(get_pref_float(eSCREEN_GAMMA));
+
+ #ifndef DISABLE_TRACE
+@@ -270,13 +288,13 @@
+ fprintf(stderr,"screen gamma=%f\n",screen_gamma);
+ }
+ #endif
+- if (info_ptr->valid & PNG_INFO_gAMA) {
++ if (png_get_gAMA(png_ptr, info_ptr, &gamma)) {
+ #ifndef DISABLE_TRACE
+ if (srcTrace) {
+- printf("setting gamma=%f\n",info_ptr->gamma);
++ printf("setting gamma=%f\n", gamma);
+ }
+ #endif
+- png_set_gamma(png_ptr, screen_gamma, (double)info_ptr->gamma);
++ png_set_gamma(png_ptr, screen_gamma, gamma);
+ }
+ else {
+ #ifndef DISABLE_TRACE
+@@ -289,34 +307,39 @@
+ }
+ }
+
+- if (info_ptr->interlace_type)
++ if (interlace_type)
+ png_set_interlace_handling(png_ptr);
+
+ png_read_update_info(png_ptr, info_ptr);
+
++ png_get_IHDR(png_ptr, info_ptr, &raw_width, &raw_height, &bit_depth,
++ &color_type, &interlace_type, &compression_type,
++ &filter_type);
++ rowbytes = png_get_rowbytes(png_ptr, info_ptr);
++ have_palette = png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette);
++
+ #ifndef DISABLE_TRACE
+ if (srcTrace) {
+- fprintf(stderr,"\n\nAFTER\nheight = %d\n", (int)png_ptr->width);
+- fprintf(stderr,"width = %d\n", (int)png_ptr->height);
+- fprintf(stderr,"bit depth = %d\n", info_ptr->bit_depth);
+- fprintf(stderr,"color type = %d\n", info_ptr->color_type);
+- fprintf(stderr,"compression type = %d\n", info_ptr->compression_type);
+- fprintf(stderr,"filter type = %d\n", info_ptr->filter_type);
+- fprintf(stderr,"interlace type = %d\n", info_ptr->interlace_type);
+- fprintf(stderr,"num colors = %d\n",info_ptr->num_palette);
+- fprintf(stderr,"rowbytes = %d\n", info_ptr->rowbytes);
++ fprintf(stderr,"\n\nAFTER\nwidth = %d\n", *width);
++ fprintf(stderr,"height = %d\n", *height);
++ fprintf(stderr,"bit depth = %d\n", bit_depth);
++ fprintf(stderr,"color type = %d\n", color_type);
++ fprintf(stderr,"compression type = %d\n", compression_type);
++ fprintf(stderr,"filter type = %d\n", filter_type);
++ fprintf(stderr,"interlace type = %d\n", interlace_type);
++ fprintf(stderr,"num colors = %d\n",num_palette);
++ fprintf(stderr,"rowbytes = %d\n", rowbytes);
+ }
+ #endif
+
+ /* allocate the pixel grid which we will need to send to
+ png_read_image(). */
+- png_pixels = (png_byte *)malloc(info_ptr->rowbytes *
+- (*height) * sizeof(png_byte));
++ png_pixels = (png_byte *)malloc(rowbytes * (*height) * sizeof(png_byte));
+
+
+ row_pointers = (png_byte **) malloc((*height) * sizeof(png_byte *));
+ for (i=0; i < *height; i++)
+- row_pointers[i]=png_pixels+(info_ptr->rowbytes*i);
++ row_pointers[i]=png_pixels+(rowbytes*i);
+
+
+ /* FINALLY - read the darn thing. */
+@@ -325,13 +348,13 @@
+
+ /* now that we have the (transformed to 8-bit RGB) image, we have
+ to copy the resulting palette to our colormap. */
+- if (info_ptr->color_type & PNG_COLOR_MASK_COLOR) {
+- if (info_ptr->valid & PNG_INFO_PLTE) {
++ if (color_type & PNG_COLOR_MASK_COLOR) {
++ if (have_palette) {
+
+- for (i=0; i < info_ptr->num_palette; i++) {
+- colrs[i].red = info_ptr->palette[i].red << 8;
+- colrs[i].green = info_ptr->palette[i].green << 8;
+- colrs[i].blue = info_ptr->palette[i].blue << 8;
++ for (i=0; i < num_palette; i++) {
++ colrs[i].red = palette[i].red << 8;
++ colrs[i].green = palette[i].green << 8;
++ colrs[i].blue = palette[i].blue << 8;
+ colrs[i].pixel = i;
+ colrs[i].flags = DoRed|DoGreen|DoBlue;
+ }
+@@ -366,7 +389,7 @@
+
+ /* if there is an alpha channel, we have to get rid of it in the
+ pixmap, since I don't do anything with it yet */
+- if (info_ptr->color_type & PNG_COLOR_MASK_ALPHA) {
++ if (color_type & PNG_COLOR_MASK_ALPHA) {
+
+ #ifndef DISABLE_TRACE
+ if (srcTrace) {
+@@ -405,10 +428,14 @@
+ free((png_byte **)row_pointers);
+
+ /* clean up after the read, and free any memory allocated */
++ /*png_read_destroy(png_ptr, info_ptr, (png_info *)0);*/
++ png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
++
+
+- /* free the structure */
+- png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
+-
++ /* free the structures */
++ /*free((char *)png_ptr);*/
++ free((char *)info_ptr);
++
+ return pixmap;
+ }
+