Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#87 Please support png 1.5.x

open
nobody
None
5
2011-03-29
2011-03-29
Ryo ONODERA
No

cinepaint 0.22-1 only supports libpng 1.4.x.
Lastest libpng is 1.5.x series.
Please support libpng 1.5.x.

Probably almost all issue is in plug-ins/png/png.c file.

Discussion

  • John Coppens
    John Coppens
    2012-06-15

    Yes! Please do support libpng 1.5. I tried to compile 1.3, the issue remains. Lots of errors in 'png.c'.
    I tried to correct them, but the differences are beyond my level of expertise (and google's).

     
  • Roman P.
    Roman P.
    2012-06-24

    Hi,

    Here is the patch to support libpng 1.5.x. Cannot attach a file so pasting it to the comment. Worked well for me with Cinepaint 1.3 as well as with 0.25. Actually I didn't test it too much, but I could open and save png file with it. Apply this patch to ./plug-ins/png.png.c
    -----------------------------------------------------
    408c408
    < if (setjmp (pp->jmpbuf))
    ---
    > if (setjmp (png_jmpbuf(pp)))
    451c451
    < if(info->bit_depth == 16)
    ---
    > if(png_get_bit_depth(pp,info) == 16)
    455c455
    < if (info->color_type == PNG_COLOR_TYPE_GRAY && info->bit_depth < 8) {
    ---
    > if (png_get_color_type(pp,info) == PNG_COLOR_TYPE_GRAY && png_get_bit_depth(pp,info) < 8) {
    459c459
    < if (info->color_type == PNG_COLOR_TYPE_PALETTE && info->bit_depth < 8) {
    ---
    > if (png_get_color_type(pp,info) == PNG_COLOR_TYPE_PALETTE && png_get_bit_depth(pp,info) < 8) {
    467,468c467,468
    < if (info->color_type != PNG_COLOR_TYPE_PALETTE &&
    < (info->valid & PNG_INFO_tRNS)) {
    ---
    > if (png_get_color_type(pp,info) != PNG_COLOR_TYPE_PALETTE &&
    > (png_get_valid(pp,info,PNG_INFO_tRNS))) {
    485c485
    < info->color_type == PNG_COLOR_TYPE_PALETTE)
    ---
    > png_get_color_type(pp,info) == PNG_COLOR_TYPE_PALETTE)
    508c508
    < if(info->bit_depth==16)
    ---
    > if(png_get_bit_depth(pp,info)==16)
    510c510
    < switch (info->color_type)
    ---
    > switch (png_get_color_type(pp,info))
    548c548
    < switch (info->color_type)
    ---
    > switch (png_get_color_type(pp,info))
    585c585
    < image = gimp_image_new(info->width, info->height, image_type);
    ---
    > image = gimp_image_new(png_get_image_width(pp,info), png_get_image_height(pp, info), image_type);
    598c598
    < layer = gimp_layer_new(image, _("Background"), info->width, info->height,
    ---
    > layer = gimp_layer_new(image, _("Background"), png_get_image_width(pp,info), png_get_image_height(pp, info),
    630c630
    < if (info->color_type & PNG_COLOR_MASK_PALETTE) {
    ---
    > if (png_get_color_type(pp,info) & PNG_COLOR_MASK_PALETTE) {
    632a633,636
    > {
    > png_colorp *palette;
    > int *num_palette;
    > png_get_PLTE(pp, info, palette, num_palette);
    637,638c641,643
    < gimp_image_set_cmap(image, (guchar *) (info->palette + empty),
    < info->num_palette - empty);
    ---
    >
    > gimp_image_set_cmap(image, (guchar *) (palette + empty),
    > num_palette - empty);
    640c645
    < gimp_image_set_cmap(image, (guchar *)info->palette, info->num_palette);
    ---
    > gimp_image_set_cmap(image, (guchar *)palette, num_palette);
    641a647
    > }
    662c668
    < pixel = g_new(guchar, tile_height * info->width * bpp);
    ---
    > pixel = g_new(guchar, tile_height * png_get_image_width(pp, info) * bpp);
    665c671
    < if(info->bit_depth==16)
    ---
    > if(png_get_bit_depth(pp,info)==16)
    668c674
    < pixels[i] = pixel + info->width * info->channels * i * 2;
    ---
    > pixels[i] = pixel + png_get_image_width(pp, info) * png_get_channels(pp, info) * i * 2;
    673c679
    < pixels[i] = pixel + info->width * info->channels * i;
    ---
    > pixels[i] = pixel + png_get_image_width(pp, info) * png_get_channels(pp, info) * i;
    683c689
    < begin < info->height;
    ---
    > begin < png_get_image_height(pp, info);
    686,687c692,693
    < if (end > info->height)
    < end = info->height;
    ---
    > if (end > png_get_image_height(pp, info))
    > end = png_get_image_height(pp, info);
    700c706
    < gimp_progress_update(((double)pass + (double)end / (double)info->height) /
    ---
    > gimp_progress_update(((double)pass + (double)end / (double)png_get_image_height(pp, info)) /
    705a712
    > {
    707,709c714,722
    < if (info->iccp_proflen > 0) {
    < gimp_image_set_icc_profile_by_mem (image, info->iccp_proflen,
    < info->iccp_profile,
    ---
    > png_charpp iccp_name;
    > int *compression_type;
    > png_bytepp profile;
    > png_uint_32 *proflen;
    >
    > png_get_iCCP(pp, info, iccp_name, compression_type, profile, proflen);
    > if (proflen > 0) {
    > gimp_image_set_icc_profile_by_mem (image, *proflen,
    > profile,
    711,713c724,725
    < printf ("%s:%d %s() set embedded profile \"%s\"\n",
    < __FILE__,__LINE__,__func__,
    < info->iccp_name);
    ---
    > printf ("%s:%d %s() set embedded profile \"%s\"\n",
    > __FILE__,__LINE__,__func__, (char *)iccp_name);
    714a727
    > }
    811a825,833
    >
    > png_uint_32 s_width;
    > png_uint_32 s_height;
    > int s_bit_depth;
    > int s_color_type;
    > int s_interlace_method;
    >
    >
    >
    827c849
    < if (setjmp (pp->jmpbuf))
    ---
    > if (setjmp (png_jmpbuf(pp)))
    866,868c888,890
    < info->width = drawable->width;
    < info->height = drawable->height;
    < info->interlace_type = pngvals.interlaced;
    ---
    > s_width = drawable->width;
    > s_height = drawable->height;
    > s_interlace_method = pngvals.interlaced;
    877,878c899,900
    < info->color_type = PNG_COLOR_TYPE_RGB;
    < info->bit_depth = 8;
    ---
    > s_color_type = PNG_COLOR_TYPE_RGB;
    > s_bit_depth = 8;
    882,883c904,905
    < info->color_type = PNG_COLOR_TYPE_RGB_ALPHA;
    < info->bit_depth = 8;
    ---
    > s_color_type = PNG_COLOR_TYPE_RGB_ALPHA;
    > s_bit_depth = 8;
    887,888c909,910
    < info->color_type = PNG_COLOR_TYPE_GRAY;
    < info->bit_depth = 8;
    ---
    > s_color_type = PNG_COLOR_TYPE_GRAY;
    > s_bit_depth = 8;
    892,893c914,915
    < info->color_type = PNG_COLOR_TYPE_GRAY_ALPHA;
    < info->bit_depth = 8;
    ---
    > s_color_type = PNG_COLOR_TYPE_GRAY_ALPHA;
    > s_bit_depth = 8;
    898,902c920,923
    < info->bit_depth = 8;
    < info->color_type = PNG_COLOR_TYPE_PALETTE;
    < info->valid |= PNG_INFO_PLTE;
    < info->palette= (png_colorp) gimp_image_get_cmap(image_ID, &num_colors);
    < info->num_palette= num_colors;
    ---
    > s_bit_depth = 8;
    > s_color_type = PNG_COLOR_TYPE_PALETTE;
    > png_set_invalid(pp,info,PNG_INFO_PLTE);
    > png_set_PLTE(pp, info, (png_colorp) gimp_image_get_cmap(image_ID, &num_colors), num_colors);
    906,907c927,928
    < info->bit_depth = 8;
    < info->color_type = PNG_COLOR_TYPE_PALETTE;
    ---
    > s_bit_depth = 8;
    > s_color_type = PNG_COLOR_TYPE_PALETTE;
    911,912c932,933
    < info->color_type = PNG_COLOR_TYPE_RGB;
    < info->bit_depth = 16;
    ---
    > s_color_type = PNG_COLOR_TYPE_RGB;
    > s_bit_depth = 16;
    916,917c937,938
    < info->color_type = PNG_COLOR_TYPE_RGB_ALPHA;
    < info->bit_depth = 16;
    ---
    > s_color_type = PNG_COLOR_TYPE_RGB_ALPHA;
    > s_bit_depth = 16;
    921,922c942,943
    < info->color_type = PNG_COLOR_TYPE_GRAY;
    < info->bit_depth = 16;
    ---
    > s_color_type = PNG_COLOR_TYPE_GRAY;
    > s_bit_depth = 16;
    926,927c947,948
    < info->color_type = PNG_COLOR_TYPE_GRAY_ALPHA;
    < info->bit_depth = 16;
    ---
    > s_color_type = PNG_COLOR_TYPE_GRAY_ALPHA;
    > s_bit_depth = 16;
    932,936c953,956
    < info->bit_depth = 16;
    < info->color_type = PNG_COLOR_TYPE_PALETTE;
    < info->valid |= PNG_INFO_PLTE;
    < info->palette= (png_colorp) gimp_image_get_cmap(image_ID, &num_colors);
    < info->num_palette= num_colors;
    ---
    > s_bit_depth = 16;
    > s_color_type = PNG_COLOR_TYPE_PALETTE;
    > png_set_invalid(pp,info,PNG_INFO_PLTE);
    > png_set_PLTE(pp, info, (png_colorp) gimp_image_get_cmap(image_ID, &num_colors), num_colors);
    940,941c960,961
    < info->bit_depth = 16;
    < info->color_type = PNG_COLOR_TYPE_PALETTE;
    ---
    > s_bit_depth = 16;
    > s_color_type = PNG_COLOR_TYPE_PALETTE;
    948a969,971
    > png_set_IHDR( pp, info, s_width, s_height, s_bit_depth, s_color_type,
    > s_interlace_method, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT );
    >
    952,953c975,976
    <
    < if (info->valid & PNG_INFO_PLTE) {
    ---
    > /*
    > if (png_get_valid(pp,info,PNG_INFO_PLTE)) {
    955c978
    < info->bit_depth= 1;
    ---
    > png_get_bit_depth(pp,info)= 1;
    957c980
    < info->bit_depth= 2;
    ---
    > png_get_bit_depth(pp,info)= 2;
    959,960c982,983
    < info->bit_depth= 4;
    < /* otherwise the default is fine */
    ---
    > png_get_bit_depth(pp,info)= 4;
    > // otherwise the default is fine
    962c985
    <
    ---
    > */
    967a991,994
    > png_charpp iccp_name;
    > int *compression_type;
    > png_bytepp profile;
    > png_uint_32 *proflen;
    970a998,1006
    >
    > /*
    > * PNG_EXPORT(159, void, png_set_iCCP,
    > * (png_structp png_ptr, png_infop info_ptr,
    > * png_const_charp name, int compression_type, png_const_bytep profile,
    > * png_uint_32 proflen));
    > * */
    >
    >
    973c1009,1010
    < 0, buffer, size);
    ---
    > 0, (png_const_bytep)buffer, size);
    > png_get_iCCP(pp, info, iccp_name, compression_type, profile, proflen);
    976c1013
    < info->iccp_name);
    ---
    > (char *)iccp_name);
    1042c1079
    < if (info->color_type == PNG_COLOR_TYPE_PALETTE && info->bit_depth < 8)
    ---
    > if (png_get_color_type(pp,info) == PNG_COLOR_TYPE_PALETTE && png_get_bit_depth(pp,info) < 8)
    1048c1085
    < if (info->bit_depth == 16)
    ---
    > if (png_get_bit_depth(pp,info) == 16)
    1080c1117
    < if (info->valid & PNG_INFO_tRNS) {
    ---
    > if (png_get_valid(pp,info, PNG_INFO_tRNS)) {
    1088c1125
    < } else if (info->valid & PNG_INFO_PLTE && bpp == 2) {
    ---
    > } else if (png_get_valid(pp,info,PNG_INFO_PLTE) && bpp == 2) {
    1100c1137
    < (double)info->height) / (double)num_passes);
    ---
    > (double)png_get_image_height(pp, info)) / (double)num_passes);
    1160c1197
    < info->valid |= PNG_INFO_PLTE;
    ---
    > png_set_invalid(pp,info,PNG_INFO_PLTE);