head 1.5; access; symbols pkgsrc-2022Q1:1.4.0.90 pkgsrc-2022Q1-base:1.4 pkgsrc-2021Q4:1.4.0.88 pkgsrc-2021Q4-base:1.4 pkgsrc-2021Q3:1.4.0.86 pkgsrc-2021Q3-base:1.4 pkgsrc-2021Q2:1.4.0.84 pkgsrc-2021Q2-base:1.4 pkgsrc-2021Q1:1.4.0.82 pkgsrc-2021Q1-base:1.4 pkgsrc-2020Q4:1.4.0.80 pkgsrc-2020Q4-base:1.4 pkgsrc-2020Q3:1.4.0.78 pkgsrc-2020Q3-base:1.4 pkgsrc-2020Q2:1.4.0.74 pkgsrc-2020Q2-base:1.4 pkgsrc-2020Q1:1.4.0.54 pkgsrc-2020Q1-base:1.4 pkgsrc-2019Q4:1.4.0.76 pkgsrc-2019Q4-base:1.4 pkgsrc-2019Q3:1.4.0.72 pkgsrc-2019Q3-base:1.4 pkgsrc-2019Q2:1.4.0.70 pkgsrc-2019Q2-base:1.4 pkgsrc-2019Q1:1.4.0.68 pkgsrc-2019Q1-base:1.4 pkgsrc-2018Q4:1.4.0.66 pkgsrc-2018Q4-base:1.4 pkgsrc-2018Q3:1.4.0.64 pkgsrc-2018Q3-base:1.4 pkgsrc-2018Q2:1.4.0.62 pkgsrc-2018Q2-base:1.4 pkgsrc-2018Q1:1.4.0.60 pkgsrc-2018Q1-base:1.4 pkgsrc-2017Q4:1.4.0.58 pkgsrc-2017Q4-base:1.4 pkgsrc-2017Q3:1.4.0.56 pkgsrc-2017Q3-base:1.4 pkgsrc-2017Q2:1.4.0.52 pkgsrc-2017Q2-base:1.4 pkgsrc-2017Q1:1.4.0.50 pkgsrc-2017Q1-base:1.4 pkgsrc-2016Q4:1.4.0.48 pkgsrc-2016Q4-base:1.4 pkgsrc-2016Q3:1.4.0.46 pkgsrc-2016Q3-base:1.4 pkgsrc-2016Q2:1.4.0.44 pkgsrc-2016Q2-base:1.4 pkgsrc-2016Q1:1.4.0.42 pkgsrc-2016Q1-base:1.4 pkgsrc-2015Q4:1.4.0.40 pkgsrc-2015Q4-base:1.4 pkgsrc-2015Q3:1.4.0.38 pkgsrc-2015Q3-base:1.4 pkgsrc-2015Q2:1.4.0.36 pkgsrc-2015Q2-base:1.4 pkgsrc-2015Q1:1.4.0.34 pkgsrc-2015Q1-base:1.4 pkgsrc-2014Q4:1.4.0.32 pkgsrc-2014Q4-base:1.4 pkgsrc-2014Q3:1.4.0.30 pkgsrc-2014Q3-base:1.4 pkgsrc-2014Q2:1.4.0.28 pkgsrc-2014Q2-base:1.4 pkgsrc-2014Q1:1.4.0.26 pkgsrc-2014Q1-base:1.4 pkgsrc-2013Q4:1.4.0.24 pkgsrc-2013Q4-base:1.4 pkgsrc-2013Q3:1.4.0.22 pkgsrc-2013Q3-base:1.4 pkgsrc-2013Q2:1.4.0.20 pkgsrc-2013Q2-base:1.4 pkgsrc-2013Q1:1.4.0.18 pkgsrc-2013Q1-base:1.4 pkgsrc-2012Q4:1.4.0.16 pkgsrc-2012Q4-base:1.4 pkgsrc-2012Q3:1.4.0.14 pkgsrc-2012Q3-base:1.4 pkgsrc-2012Q2:1.4.0.12 pkgsrc-2012Q2-base:1.4 pkgsrc-2012Q1:1.4.0.10 pkgsrc-2012Q1-base:1.4 pkgsrc-2011Q4:1.4.0.8 pkgsrc-2011Q4-base:1.4 pkgsrc-2011Q3:1.4.0.6 pkgsrc-2011Q3-base:1.4 pkgsrc-2011Q2:1.4.0.4 pkgsrc-2011Q2-base:1.4 pkgsrc-2011Q1:1.4.0.2 pkgsrc-2011Q1-base:1.4 pkgsrc-2010Q4:1.2.0.6 pkgsrc-2010Q4-base:1.2 pkgsrc-2010Q3:1.2.0.4 pkgsrc-2010Q3-base:1.2 pkgsrc-2010Q2:1.2.0.2 pkgsrc-2010Q2-base:1.2 pkgsrc-2010Q1:1.1.0.42 pkgsrc-2010Q1-base:1.1 pkgsrc-2009Q4:1.1.0.40 pkgsrc-2009Q4-base:1.1 pkgsrc-2009Q3:1.1.0.38 pkgsrc-2009Q3-base:1.1 pkgsrc-2009Q2:1.1.0.36 pkgsrc-2009Q2-base:1.1 pkgsrc-2009Q1:1.1.0.34 pkgsrc-2009Q1-base:1.1 pkgsrc-2008Q4:1.1.0.32 pkgsrc-2008Q4-base:1.1 pkgsrc-2008Q3:1.1.0.30 pkgsrc-2008Q3-base:1.1 cube-native-xorg:1.1.0.28 cube-native-xorg-base:1.1 pkgsrc-2008Q2:1.1.0.26 pkgsrc-2008Q2-base:1.1 cwrapper:1.1.0.24 pkgsrc-2008Q1:1.1.0.22 pkgsrc-2008Q1-base:1.1 pkgsrc-2007Q4:1.1.0.20 pkgsrc-2007Q4-base:1.1 pkgsrc-2007Q3:1.1.0.18 pkgsrc-2007Q3-base:1.1 pkgsrc-2007Q2:1.1.0.16 pkgsrc-2007Q2-base:1.1 pkgsrc-2007Q1:1.1.0.14 pkgsrc-2007Q1-base:1.1 pkgsrc-2006Q4:1.1.0.12 pkgsrc-2006Q4-base:1.1 pkgsrc-2006Q3:1.1.0.10 pkgsrc-2006Q3-base:1.1 pkgsrc-2006Q2:1.1.0.8 pkgsrc-2006Q2-base:1.1 pkgsrc-2006Q1:1.1.0.6 pkgsrc-2006Q1-base:1.1 pkgsrc-2005Q4:1.1.0.4 pkgsrc-2005Q4-base:1.1 pkgsrc-2005Q3:1.1.0.2 pkgsrc-2005Q3-base:1.1; locks; strict; comment @# @; 1.5 date 2022.05.19.13.32.48; author nia; state dead; branches; next 1.4; commitid j5w3Gr8F8cBWwFED; 1.4 date 2011.02.12.11.40.41; author wiz; state Exp; branches; next 1.3; 1.3 date 2011.02.07.22.08.42; author wiz; state Exp; branches; next 1.2; 1.2 date 2010.06.14.09.55.04; author wiz; state Exp; branches; next 1.1; 1.1 date 2005.07.18.00.46.18; author kristerw; state Exp; branches; next ; desc @@ 1.5 log @ted, related dictionaries: update to 2.23 (Ted 2.23 February 4, 2013) * Stability fixes. * Many-many annoying bugs fixed. * Some steps to support the few missing features such as absolutely positioned objects and shapes. * Preparations for bidirectional text support (Ted 2.22 April 4, 2012) * Thorough brush-up of the internals. * Undo/Redo/Recovery * Many-many annoying bugs fixed. * Some steps to support the few missing features such as absolutely positioned objects and shapes. @ text @$NetBSD: patch-ag,v 1.4 2011/02/12 11:40:41 wiz Exp $ Fix for png-1.5. Version from upstream. --- bitmap/bmpng.c.orig 2009-10-16 15:20:57.000000000 +0000 +++ bitmap/bmpng.c @@@@ -20,23 +20,32 @@@@ /* */ /************************************************************************/ -static int bpPngiToBitmap( const png_info * pngi, +static int bpPngiToBitmap( const png_structp pngp, + png_info * pngi, BitmapDescription * bd ) { unsigned int col; + png_uint_32 res_x, res_y; + int unit_type= 0; - bd->bdPixelsWide= pngi->width; - bd->bdPixelsHigh= pngi->height; + bd->bdPixelsWide= png_get_image_width( pngp, pngi ); + bd->bdPixelsHigh= png_get_image_height( pngp, pngi ); bd->bdHasAlpha= 0; - switch( pngi->color_type ) + switch( png_get_color_type( pngp, pngi ) ) { case PNG_COLOR_TYPE_PALETTE: + { + int num_palette; + png_colorp palette; + + png_get_PLTE( pngp, pngi, &palette, &num_palette ); + bd->bdColorEncoding= BMcoRGB8PALETTE; - bd->bdColorCount= pngi->num_palette; + bd->bdColorCount= num_palette; bd->bdBitsPerSample= 8; bd->bdSamplesPerPixel= 3; - bd->bdBitsPerPixel= pngi->bit_depth; + bd->bdBitsPerPixel= png_get_bit_depth( pngp, pngi ); bd->bdRGB8Palette= (RGB8Color *) malloc( bd->bdColorCount* sizeof(RGB8Color) ); @@@@ -46,47 +55,51 @@@@ static int bpPngiToBitmap( const png_inf for ( col= 0; col < bd->bdColorCount; col++ ) { - bd->bdRGB8Palette[col].rgb8Red= pngi->palette[col].red; - bd->bdRGB8Palette[col].rgb8Green= pngi->palette[col].green; - bd->bdRGB8Palette[col].rgb8Blue= pngi->palette[col].blue; + bd->bdRGB8Palette[col].rgb8Red= palette[col].red; + bd->bdRGB8Palette[col].rgb8Green= palette[col].green; + bd->bdRGB8Palette[col].rgb8Blue= palette[col].blue; bd->bdRGB8Palette[col].rgb8Alpha= 0; } + } break; case PNG_COLOR_TYPE_RGB: bd->bdColorEncoding= BMcoRGB; - bd->bdBitsPerSample= pngi->bit_depth; - bd->bdSamplesPerPixel= pngi->channels; - bd->bdBitsPerPixel= pngi->pixel_depth; + bd->bdBitsPerSample= png_get_bit_depth( pngp, pngi ); + bd->bdSamplesPerPixel= png_get_channels( pngp, pngi ); + bd->bdBitsPerPixel= bd->bdSamplesPerPixel* bd->bdBitsPerSample; break; case PNG_COLOR_TYPE_GRAY: bd->bdColorEncoding= BMcoWHITEBLACK; - bd->bdBitsPerSample= pngi->bit_depth; - bd->bdSamplesPerPixel= pngi->channels; - bd->bdBitsPerPixel= pngi->pixel_depth; + bd->bdBitsPerSample= png_get_bit_depth( pngp, pngi ); + bd->bdSamplesPerPixel= png_get_channels( pngp, pngi ); + bd->bdBitsPerPixel= bd->bdSamplesPerPixel* bd->bdBitsPerSample; break; case PNG_COLOR_TYPE_RGB_ALPHA: bd->bdHasAlpha= 1; bd->bdColorEncoding= BMcoRGB; - bd->bdBitsPerSample= pngi->bit_depth; - bd->bdSamplesPerPixel= pngi->channels; - bd->bdBitsPerPixel= pngi->pixel_depth; + bd->bdBitsPerSample= png_get_bit_depth( pngp, pngi ); + bd->bdSamplesPerPixel= png_get_channels( pngp, pngi ); + bd->bdBitsPerPixel= bd->bdSamplesPerPixel* bd->bdBitsPerSample; break; case PNG_COLOR_TYPE_GRAY_ALPHA: bd->bdHasAlpha= 1; - LDEB(pngi->color_type); return -1; + LDEB(png_get_color_type( pngp, pngi )); return -1; default: - LDEB(pngi->color_type); return -1; + LDEB(png_get_color_type( pngp, pngi )); return -1; } - bd->bdBytesPerRow= pngi->rowbytes; + bd->bdBytesPerRow= png_get_rowbytes( pngp, pngi ); bd->bdBufferLength= bd->bdBytesPerRow* bd->bdPixelsHigh; - switch( pngi->phys_unit_type ) + if ( ! png_get_pHYs( pngp, pngi, &res_x, &res_y, &unit_type ) ) + { unit_type= PNG_RESOLUTION_UNKNOWN; } + + switch( unit_type ) { case PNG_RESOLUTION_UNKNOWN: bd->bdUnit= BMunPIXEL; @@@@ -96,12 +109,12 @@@@ static int bpPngiToBitmap( const png_inf case PNG_RESOLUTION_METER: bd->bdUnit= BMunM; - bd->bdXResolution= pngi->x_pixels_per_unit; - bd->bdYResolution= pngi->y_pixels_per_unit; + bd->bdXResolution= res_x; + bd->bdYResolution= res_y; break; default: - LDEB(pngi->phys_unit_type); + LDEB(unit_type); return -1; } @@@@ -119,11 +132,11 @@@@ static int bmPngReadContents( png_info * unsigned char * buffer; numberOfPasses= 1; - if ( pngi->interlace_type ) + if ( png_get_interlace_type( png, pngi ) ) { numberOfPasses= png_set_interlace_handling( png ); } - if ( pngi->color_type == PNG_COLOR_TYPE_RGB && - pngi->bit_depth == 16 ) + if ( png_get_color_type( png, pngi ) == PNG_COLOR_TYPE_RGB && + png_get_bit_depth( png, pngi ) == 16 ) { const unsigned short one= 1; const unsigned char * testEndian= (const unsigned char *)&one; @@@@ -133,9 +146,6 @@@@ static int bmPngReadContents( png_info * } png_start_read_image( png ); - /* - png_read_update_info( png, pngi ); - */ buffer= (unsigned char *)malloc( bd->bdBufferLength ); if ( ! buffer ) @@@@ -236,9 +246,9 @@@@ int bmPngReadPng( BitmapDescription * bd png_read_info( pngp, pngip ); - if ( bpPngiToBitmap( pngip, bd ) ) + if ( bpPngiToBitmap( pngp, pngip, bd ) ) { - LLLDEB(pngip->color_type,bd->bdColorCount,bd->bdRGB8Palette); + LLDEB(bd->bdColorCount,bd->bdRGB8Palette); png_destroy_read_struct( &pngp, &pngip, (png_infop *)0 ); return -1; } @@@@ -282,44 +292,43 @@@@ int bmCanWritePngFile( const BitmapDescr static int bpPngiFromBitmap( png_structp png, png_info * pngi, + png_colorp * pPalette, const BitmapDescription * bd ) { - png_info_init( pngi ); - pngi->width= bd->bdPixelsWide; - pngi->height= bd->bdPixelsHigh; + int bit_depth; + int color_type; + png_color_8 sig_bit; switch( bd->bdUnit ) { case BMunM: - pngi->phys_unit_type= PNG_RESOLUTION_METER; - pngi->x_pixels_per_unit= bd->bdXResolution; - pngi->y_pixels_per_unit= bd->bdYResolution; - pngi->valid |= PNG_INFO_pHYs; + png_set_pHYs( png, pngi, + bd->bdXResolution, + bd->bdYResolution, + PNG_RESOLUTION_METER); break; case BMunINCH: - pngi->phys_unit_type= PNG_RESOLUTION_METER; - pngi->x_pixels_per_unit= (int)( 39.37* bd->bdXResolution ); - pngi->y_pixels_per_unit= (int)( 39.37* bd->bdYResolution ); - pngi->valid |= PNG_INFO_pHYs; + png_set_pHYs( png, pngi, + (int)( 39.37* bd->bdXResolution ), + (int)( 39.37* bd->bdYResolution ), + PNG_RESOLUTION_METER); break; case BMunPOINT: - pngi->phys_unit_type= PNG_RESOLUTION_METER; - pngi->x_pixels_per_unit= POINTS_PER_M* bd->bdXResolution; - pngi->y_pixels_per_unit= POINTS_PER_M* bd->bdYResolution; - pngi->valid |= PNG_INFO_pHYs; + png_set_pHYs( png, pngi, + POINTS_PER_M* bd->bdXResolution, + POINTS_PER_M* bd->bdYResolution, + PNG_RESOLUTION_METER); break; case BMunPIXEL: - pngi->phys_unit_type= PNG_RESOLUTION_UNKNOWN; - pngi->x_pixels_per_unit= 1; - pngi->y_pixels_per_unit= 1; + png_set_pHYs(png, pngi, 1, 1, PNG_RESOLUTION_UNKNOWN); break; default: LDEB(bd->bdUnit); - pngi->phys_unit_type= PNG_RESOLUTION_UNKNOWN; + png_set_pHYs(png, pngi, 1, 1, PNG_RESOLUTION_UNKNOWN); break; } @@@@ -329,41 +338,48 @@@@ static int bpPngiFromBitmap( png_structp case BMcoBLACKWHITE: case BMcoWHITEBLACK: - pngi->bit_depth= bd->bdBitsPerPixel; + bit_depth= bd->bdBitsPerPixel; if ( bd->bdHasAlpha ) - { pngi->color_type= PNG_COLOR_TYPE_GRAY_ALPHA; } - else{ pngi->color_type= PNG_COLOR_TYPE_GRAY; } - pngi->sig_bit.gray= bd->bdBitsPerSample; + { color_type= PNG_COLOR_TYPE_GRAY_ALPHA; } + else{ color_type= PNG_COLOR_TYPE_GRAY; } + sig_bit.gray= bd->bdBitsPerSample; break; case BMcoRGB: - pngi->bit_depth= bd->bdBitsPerSample; + bit_depth= bd->bdBitsPerSample; if ( bd->bdHasAlpha ) - { pngi->color_type= PNG_COLOR_TYPE_RGB_ALPHA; } - else{ pngi->color_type= PNG_COLOR_TYPE_RGB; } - pngi->sig_bit.red= bd->bdBitsPerSample; - pngi->sig_bit.green= bd->bdBitsPerSample; - pngi->sig_bit.blue= bd->bdBitsPerSample; + { color_type= PNG_COLOR_TYPE_RGB_ALPHA; } + else{ color_type= PNG_COLOR_TYPE_RGB; } + sig_bit.red= bd->bdBitsPerSample; + sig_bit.green= bd->bdBitsPerSample; + sig_bit.blue= bd->bdBitsPerSample; break; case BMcoRGB8PALETTE: - pngi->bit_depth= bd->bdBitsPerPixel; - pngi->color_type= PNG_COLOR_TYPE_PALETTE; + bit_depth= bd->bdBitsPerPixel; + color_type= PNG_COLOR_TYPE_PALETTE; - pngi->valid |= PNG_INFO_PLTE; - pngi->palette= (png_color *)malloc( 256* sizeof( png_color ) ); - if ( ! pngi->palette ) - { XDEB(pngi->palette); return -1; } - pngi->num_palette= bd->bdColorCount; - pngi->sig_bit.red= bd->bdBitsPerSample; - pngi->sig_bit.green= bd->bdBitsPerSample; - pngi->sig_bit.blue= bd->bdBitsPerSample; - for ( i= 0; i < pngi->num_palette; i++ ) + if ( bd->bdColorCount > PNG_MAX_PALETTE_LENGTH ) { - pngi->palette[i].red= bd->bdRGB8Palette[i].rgb8Red; - pngi->palette[i].green= bd->bdRGB8Palette[i].rgb8Green; - pngi->palette[i].blue= bd->bdRGB8Palette[i].rgb8Blue; + LLDEB(bd->bdColorCount,PNG_MAX_PALETTE_LENGTH); + return -1; } + + *pPalette= (png_color *)malloc( PNG_MAX_PALETTE_LENGTH* + sizeof( png_color ) ); + if ( ! *pPalette ) + { XDEB(*pPalette); return -1; } + sig_bit.red= bd->bdBitsPerSample; + sig_bit.green= bd->bdBitsPerSample; + sig_bit.blue= bd->bdBitsPerSample; + for ( i= 0; i < bd->bdColorCount; i++ ) + { + (*pPalette)[i].red= bd->bdRGB8Palette[i].rgb8Red; + (*pPalette)[i].green= bd->bdRGB8Palette[i].rgb8Green; + (*pPalette)[i].blue= bd->bdRGB8Palette[i].rgb8Blue; + } + + png_set_PLTE( png, pngi, (*pPalette), bd->bdColorCount ); break; default: @@@@ -371,7 +387,13 @@@@ static int bpPngiFromBitmap( png_structp return -1; } - pngi->interlace_type= 0; + png_set_sBIT( png, pngi, &sig_bit ); + png_set_IHDR( png, pngi, + bd->bdPixelsWide, bd->bdPixelsHigh, + bit_depth, color_type, + PNG_INTERLACE_NONE, + PNG_COMPRESSION_TYPE_BASE, + PNG_FILTER_TYPE_BASE ); return 0; } @@@@ -395,8 +417,8 @@@@ static void bmPngWriteContents( png_stru } } - if ( pngi->color_type == PNG_COLOR_TYPE_RGB && - bd->bdBitsPerSample == 16 ) + if ( png_get_color_type( png, pngi ) == PNG_COLOR_TYPE_RGB && + bd->bdBitsPerSample == 16 ) { const unsigned short one= 1; const unsigned char * testEndian= (const unsigned char *)&one; @@@@ -431,9 +453,9 @@@@ static void bmPngWriteContents( png_stru from= scratch; } - if ( pngi->color_type == PNG_COLOR_TYPE_RGB && - bd->bdBitsPerSample == 16 && - scratch ) + if ( png_get_color_type( png, pngi ) == PNG_COLOR_TYPE_RGB && + bd->bdBitsPerSample == 16 && + scratch ) { int col; const BmUint16 * fr= (const BmUint16 *)from; @@@@ -453,10 +475,6 @@@@ static void bmPngWriteContents( png_stru png_write_end( png, pngi ); - if ( bd->bdColorEncoding == BMcoRGB8PALETTE && - pngi->palette ) - { free( pngi->palette ); } - if ( scratch ) { free( scratch ); } @@@@ -510,50 +528,43 @@@@ int bmPngWritePng( const BitmapDescript const unsigned char * buffer, SimpleOutputStream * sos ) { + int rval= 0; png_structp pngp= (png_structp)0; png_infop pngip= (png_infop)0; + png_colorp palette= (png_colorp)0; pngp = png_create_write_struct( PNG_LIBPNG_VER_STRING, (void *)0, (png_error_ptr)0, (png_error_ptr)0 ); if ( ! pngp ) - { LDEB(1); return -1; } + { XDEB(pngp); rval= -1; goto ready; } pngip = png_create_info_struct( pngp ); if ( ! pngip ) - { - LDEB(1); - png_destroy_write_struct( &pngp, (png_infop *)0 ); - return -1; - } + { XDEB(pngip); rval= -1; goto ready; } + + /* + As the info struct is built by libpng this is not needed: + (The call will disappear from libpng in version 1.4) + png_info_init( pngi ); + */ if ( setjmp( png_jmpbuf( pngp ) ) ) - { - LDEB(1); - png_destroy_write_struct( &pngp, &pngip ); - /* Crashes: - if ( bd->bdColorEncoding == BMcoRGB8PALETTE && - pngip->palette ) - { free( pngip->palette ); } - */ - return -1; - } + { LDEB(1); rval= -1; goto ready; } png_init_io( pngp, (FILE *)0 ); png_set_write_fn( pngp, (void *)sos, bmPngWriteBytes, bmPngFlushBytes ); - if ( bpPngiFromBitmap( pngp, pngip, bd ) ) - { - LDEB(bd->bdColorEncoding); - png_destroy_write_struct( &pngp, &pngip ); - return -1; - } - - /* - png_write_info( pngp, pngip ); - */ + if ( bpPngiFromBitmap( pngp, pngip, &palette, bd ) ) + { LDEB(bd->bdColorEncoding); rval= -1; goto ready; } bmPngWriteContents( pngp, pngip, buffer, bd ); + ready: + + if ( palette ) + { free( palette ); } + png_destroy_write_struct( &pngp, &pngip ); - return 0; + + return rval; } @ 1.4 log @Use upstream version of png-1.5 fix. @ text @d1 1 a1 1 $NetBSD: patch-ag,v 1.3 2011/02/07 22:08:42 wiz Exp $ @ 1.3 log @Fix build with png-1.5. @ text @d1 1 a1 1 $NetBSD: patch-ag,v 1.2 2010/06/14 09:55:04 wiz Exp $ d3 1 a3 1 Fix for png-1.5. d7 1 a7 1 @@@@ -20,23 +20,29 @@@@ d12 2 a13 2 +static int bpPngiToBitmap( const png_structp png, + const png_info * pngi, d17 2 a18 4 + png_colorp palette; + int num_palette; + png_uint_32 res_x, res_y; + int unit_type; d22 2 a23 2 + bd->bdPixelsWide= png_get_image_width(png, pngi); + bd->bdPixelsHigh= png_get_image_height(png, pngi); d27 1 a27 2 + png_get_PLTE( png, pngi, &palette, &num_palette ); + switch( png_get_color_type( png, pngi ) ) d30 6 d42 1 a42 1 + bd->bdBitsPerPixel= png_get_bit_depth( png, pngi ); d46 1 a46 1 @@@@ -46,47 +52,48 @@@@ static int bpPngiToBitmap( const png_inf d58 1 d66 3 a68 3 + bd->bdBitsPerSample= png_get_bit_depth( png, pngi ); + bd->bdSamplesPerPixel= png_get_channels( png, pngi ); + bd->bdBitsPerPixel= ( png_get_rowbytes( png, pngi ) + 7 ) / png_get_image_width( png, pngi ); d76 3 a78 3 + bd->bdBitsPerSample= png_get_bit_depth( png, pngi ); + bd->bdSamplesPerPixel= png_get_channels( png, pngi ); + bd->bdBitsPerPixel= ( png_get_rowbytes( png, pngi ) + 7 ) / png_get_image_width( png, pngi ); d87 3 a89 3 + bd->bdBitsPerSample= png_get_bit_depth( png, pngi ); + bd->bdSamplesPerPixel= png_get_channels( png, pngi ); + bd->bdBitsPerPixel= ( png_get_rowbytes( png, pngi ) + 7 ) / png_get_image_width( png, pngi ); d95 1 a95 1 + LDEB(png_get_color_type( png, pngi )); return -1; d99 1 a99 1 + LDEB(png_get_color_type( png, pngi )); return -1; d103 1 a103 1 + bd->bdBytesPerRow= png_get_rowbytes( png, pngi ); d107 3 a109 1 + png_get_pHYs( png, pngi, &res_x, &res_y, &unit_type); d114 1 a114 1 @@@@ -96,12 +103,12 @@@@ static int bpPngiToBitmap( const png_inf d130 1 a130 1 @@@@ -119,11 +126,11 @@@@ static int bmPngReadContents( png_info * d141 1 a141 1 + png_get_bit_depth( png, pngi ) == 16 ) d145 11 a155 1 @@@@ -236,9 +243,9 @@@@ int bmPngReadPng( BitmapDescription * bd d163 1 a163 1 + LLLDEB(png_get_color_type( pngp, pngip ),bd->bdColorCount,bd->bdRGB8Palette); d167 3 a169 1 @@@@ -284,94 +291,91 @@@@ static int bpPngiFromBitmap( png_structp d171 1 d177 3 a179 1 + int bit_depth, color_type, interlace_type; d188 4 a191 1 + png_set_pHYs(png, pngi, bd->bdXResolution, bd->bdYResolution, PNG_RESOLUTION_METER); d199 4 a202 1 + png_set_pHYs(png, pngi, (int)( 39.37* bd->bdXResolution ), (int)( 39.37* bd->bdYResolution), PNG_RESOLUTION_METER); d210 4 a213 1 + png_set_pHYs(png, pngi, (int)( POINTS_PER_M* bd->bdXResolution ), (int)( POINTS_PER_M* bd->bdYResolution), PNG_RESOLUTION_METER); d226 1 a226 1 + png_set_pHYs(png, pngi, 0, 0, PNG_RESOLUTION_UNKNOWN); d230 1 a230 5 + { + png_color_8 sig_bit; switch( bd->bdColorEncoding ) { int i; d241 1 a241 1 + else{ color_type= PNG_COLOR_TYPE_GRAY; } d255 1 a255 1 + else{ color_type= PNG_COLOR_TYPE_RGB; } d264 2 a265 3 + { + png_colorp palette; + int num_palette; d276 1 a276 11 + bit_depth= bd->bdBitsPerPixel; + color_type= PNG_COLOR_TYPE_PALETTE; + + palette= (png_color *)malloc( 256* sizeof( png_color ) ); + if ( ! palette ) + { XDEB(palette); return -1; } + num_palette= bd->bdColorCount; + sig_bit.red= bd->bdBitsPerSample; + sig_bit.green= bd->bdBitsPerSample; + sig_bit.blue= bd->bdBitsPerSample; + for ( i= 0; i < num_palette; i++ ) d281 2 a282 3 + palette[i].red= bd->bdRGB8Palette[i].rgb8Red; + palette[i].green= bd->bdRGB8Palette[i].rgb8Green; + palette[i].blue= bd->bdRGB8Palette[i].rgb8Blue; d284 16 a299 2 + png_set_PLTE( png, pngi, palette, num_palette ); + } d303 1 a303 1 LDEB(bd->bdColorEncoding); a305 4 + png_set_sBIT( png, pngi, &sig_bit); + } + png_set_IHDR( png, pngi, bd->bdPixelsWide, bd->bdPixelsHigh, bit_depth, + color_type, 0, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); d308 7 d318 1 a318 1 @@@@ -395,7 +399,7 @@@@ static void bmPngWriteContents( png_stru d323 1 d325 1 a325 1 bd->bdBitsPerSample == 16 ) d328 2 a329 1 @@@@ -431,7 +435,7 @@@@ static void bmPngWriteContents( png_stru d334 2 d337 2 a338 2 bd->bdBitsPerSample == 16 && scratch ) d340 3 a342 1 @@@@ -453,9 +457,15 @@@@ static void bmPngWriteContents( png_stru d349 27 a375 4 + if ( bd->bdColorEncoding == BMcoRGB8PALETTE ) + { + png_colorp palette; + int num_palette; d377 36 a412 4 + png_get_PLTE( png, pngi, &palette, &num_palette ); + if (palette) + { free( palette ); } + } d414 10 a423 2 if ( scratch ) { free( scratch ); } @ 1.2 log @Update to 2.21: Changes since 2.17 not found. 2.17: Changes: This release finishes the numbered lists. All tools have a 'Close' button now. The configurable resources mechanism now works without X11 for command line calls. There is preliminary support for 'shapes', the newer Word figures mechanism. There is support for the Euro sign if the font supports it. With some configuration, Ted can now use most fonts configured in GhostScript. It uses more CSS and fewer tables in HTML. Many annoying bugs were fixed. @ text @d1 1 a1 1 $NetBSD$ d3 1 a3 1 Fix for png-1.4.2. d7 145 a151 1 @@@@ -284,7 +284,6 @@@@ static int bpPngiFromBitmap( png_structp d156 165 a320 2 pngi->width= bd->bdPixelsWide; pngi->height= bd->bdPixelsHigh; d322 2 @ 1.1 log @Do not include . @ text @d3 11 a13 7 --- appUtil/psTtf.c.orig Mon Jul 18 02:43:21 2005 +++ appUtil/psTtf.c Mon Jul 18 02:43:28 2005 @@@@ -1,7 +1,6 @@@@ # include # include # include -# include a14 2 # define y0 math_y0 # define y1 math_y1 @