From d6559c96a11e678f764971dbe05009bf054ef039 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Mon, 10 Jan 2011 10:50:57 +0000 Subject: [PATCH] 2011-01-10 11:50 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) * contrib/hbhpdf/3rd/libhpdf/hpdfimap.c * contrib/hbhpdf/3rd/libhpdf/libhpdf.dif ! Updated libharu code to work with libpng 1.5 Thanks to Tamas for the patch and Anthony Dovgal for the quick update on libharu code. * contrib/hbhpdf/3rd/libhpdf/libhpdf.hbp * Not needed anymore to suppress pedandic png warnings. --- harbour/ChangeLog | 12 +- harbour/contrib/hbhpdf/3rd/libhpdf/hpdfimap.c | 109 +++--- .../contrib/hbhpdf/3rd/libhpdf/libhpdf.dif | 347 +++++++++++++++++- .../contrib/hbhpdf/3rd/libhpdf/libhpdf.hbp | 2 - 4 files changed, 411 insertions(+), 59 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index a10a84e3d7..1d1f166a7f 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,16 @@ The license applies to all entries newer than 2009-04-28. */ +2011-01-10 11:50 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) + * contrib/hbhpdf/3rd/libhpdf/hpdfimap.c + * contrib/hbhpdf/3rd/libhpdf/libhpdf.dif + ! Updated libharu code to work with libpng 1.5 + Thanks to Tamas for the patch and Anthony Dovgal + for the quick update on libharu code. + + * contrib/hbhpdf/3rd/libhpdf/libhpdf.hbp + * Not needed anymore to suppress pedandic png warnings. + 2011-01-09 21:30 UTC+0200 Petr Chornyj (myorg63 at mail.ru) * ChangeLog ! Fixed previous entry @@ -26,7 +36,7 @@ + contrib/hbmxml/hbmxmlx.prg + Added .hbx and extern puller harness. Borrowed from hbexpat/Viktor Szakats. - + 2011-01-09 16:05 UTC+0200 Petr Chornyj (myorg63 at mail.ru) * contrib/hbmxml/tests/custom.prg * Minor changes diff --git a/harbour/contrib/hbhpdf/3rd/libhpdf/hpdfimap.c b/harbour/contrib/hbhpdf/3rd/libhpdf/hpdfimap.c index ab5ec47850..40ce3dd25b 100644 --- a/harbour/contrib/hbhpdf/3rd/libhpdf/hpdfimap.c +++ b/harbour/contrib/hbhpdf/3rd/libhpdf/hpdfimap.c @@ -109,14 +109,15 @@ ReadPngData_Interlaced (HPDF_Dict image, png_infop info_ptr) { png_uint_32 len = png_get_rowbytes(png_ptr, info_ptr); + png_uint_32 height = png_get_image_height(png_ptr, info_ptr); png_bytep* row_pointers = HPDF_GetMem (image->mmgr, - info_ptr->height * sizeof (png_bytep)); + height * sizeof (png_bytep)); if (row_pointers) { HPDF_UINT i; - HPDF_MemSet (row_pointers, 0, info_ptr->height * sizeof (png_bytep)); - for (i = 0; i < (HPDF_UINT)info_ptr->height; i++) { + HPDF_MemSet (row_pointers, 0, height * sizeof (png_bytep)); + for (i = 0; i < (HPDF_UINT)height; i++) { row_pointers[i] = HPDF_GetMem (image->mmgr, len); if (image->error->error_no != HPDF_OK) @@ -126,7 +127,7 @@ ReadPngData_Interlaced (HPDF_Dict image, if (image->error->error_no == HPDF_OK) { png_read_image(png_ptr, row_pointers); if (image->error->error_no == HPDF_OK) { /* add this line */ - for (i = 0; i < (HPDF_UINT)info_ptr->height; i++) { + for (i = 0; i < (HPDF_UINT)height; i++) { if (HPDF_Stream_Write (image->stream, row_pointers[i], len) != HPDF_OK) break; @@ -135,7 +136,7 @@ ReadPngData_Interlaced (HPDF_Dict image, } /* clean up */ - for (i = 0; i < (HPDF_UINT)info_ptr->height; i++) { + for (i = 0; i < (HPDF_UINT)height; i++) { HPDF_FreeMem (image->mmgr, row_pointers[i]); } @@ -151,12 +152,13 @@ ReadPngData (HPDF_Dict image, png_infop info_ptr) { png_uint_32 len = png_get_rowbytes(png_ptr, info_ptr); + png_uint_32 height = png_get_image_height(png_ptr, info_ptr); png_bytep buf_ptr = HPDF_GetMem (image->mmgr, len); if (buf_ptr) { HPDF_UINT i; - for (i = 0; i < (HPDF_UINT)info_ptr->height; i++) { + for (i = 0; i < (HPDF_UINT)height; i++) { png_read_rows(png_ptr, (png_byte**)&buf_ptr, NULL, 1); if (image->error->error_no != HPDF_OK) break; @@ -182,14 +184,16 @@ ReadTransparentPaletteData (HPDF_Dict image, HPDF_STATUS ret = HPDF_OK; HPDF_UINT i, j; png_bytep *row_ptr; + png_uint_32 height = png_get_image_height(png_ptr, info_ptr); + png_uint_32 width = png_get_image_width(png_ptr, info_ptr); - row_ptr = HPDF_GetMem (image->mmgr, info_ptr->height * sizeof(png_bytep)); + row_ptr = HPDF_GetMem (image->mmgr, height * sizeof(png_bytep)); if (!row_ptr) { return HPDF_FAILD_TO_ALLOC_MEM; } else { png_uint_32 len = png_get_rowbytes(png_ptr, info_ptr); - for (i = 0; i < (HPDF_UINT)info_ptr->height; i++) { + for (i = 0; i < (HPDF_UINT)height; i++) { row_ptr[i] = HPDF_GetMem(image->mmgr, len); if (!row_ptr[i]) { for (; i >= 0; i--) { @@ -207,19 +211,19 @@ ReadTransparentPaletteData (HPDF_Dict image, goto Error; } - for (j = 0; j < info_ptr->height; j++) { - for (i = 0; i < info_ptr->width; i++) { - smask_data[info_ptr->width * j + i] = (row_ptr[j][i] < num_trans) ? trans[row_ptr[j][i]] : 0xFF; + for (j = 0; j < height; j++) { + for (i = 0; i < width; i++) { + smask_data[width * j + i] = (row_ptr[j][i] < num_trans) ? trans[row_ptr[j][i]] : 0xFF; } - if (HPDF_Stream_Write (image->stream, row_ptr[j], info_ptr->width) != HPDF_OK) { + if (HPDF_Stream_Write (image->stream, row_ptr[j], width) != HPDF_OK) { ret = HPDF_FILE_IO_ERROR; goto Error; } } Error: - for (i = 0; i < (HPDF_UINT)info_ptr->height; i++) { + for (i = 0; i < (HPDF_UINT)height; i++) { HPDF_FreeMem (image->mmgr, row_ptr[i]); } @@ -238,6 +242,8 @@ ReadTransparentPngData (HPDF_Dict image, HPDF_UINT i, j; png_bytep *row_ptr, row; png_byte color_type; + png_uint_32 height = png_get_image_height(png_ptr, info_ptr); + png_uint_32 width = png_get_image_width(png_ptr, info_ptr); color_type = png_get_color_type(png_ptr, info_ptr); @@ -245,13 +251,13 @@ ReadTransparentPngData (HPDF_Dict image, return HPDF_INVALID_PNG_IMAGE; } - row_ptr = HPDF_GetMem (image->mmgr, info_ptr->height * sizeof(png_bytep)); + row_ptr = HPDF_GetMem (image->mmgr, height * sizeof(png_bytep)); if (!row_ptr) { return HPDF_FAILD_TO_ALLOC_MEM; } else { png_uint_32 len = png_get_rowbytes(png_ptr, info_ptr); - for (i = 0; i < (HPDF_UINT)info_ptr->height; i++) { + for (i = 0; i < (HPDF_UINT)height; i++) { row_ptr[i] = HPDF_GetMem(image->mmgr, len); if (!row_ptr[i]) { for (; i >= 0; i--) { @@ -271,12 +277,12 @@ ReadTransparentPngData (HPDF_Dict image, switch (color_type) { case PNG_COLOR_TYPE_RGB_ALPHA: - row_len = 3 * info_ptr->width * sizeof(png_byte); - for (j = 0; j < info_ptr->height; j++) { - for (i = 0; i < info_ptr->width; i++) { + row_len = 3 * width * sizeof(png_byte); + for (j = 0; j < height; j++) { + for (i = 0; i < width; i++) { row = row_ptr[j]; memmove(row + (3 * i), row + (4*i), 3); - smask_data[info_ptr->width * j + i] = row[4 * i + 3]; + smask_data[width * j + i] = row[4 * i + 3]; } if (HPDF_Stream_Write (image->stream, row, row_len) != HPDF_OK) { @@ -286,12 +292,12 @@ ReadTransparentPngData (HPDF_Dict image, } break; case PNG_COLOR_TYPE_GRAY_ALPHA: - row_len = info_ptr->width * sizeof(png_byte); - for (j = 0; j < info_ptr->height; j++) { - for (i = 0; i < info_ptr->width; i++) { + row_len = width * sizeof(png_byte); + for (j = 0; j < height; j++) { + for (i = 0; i < width; i++) { row = row_ptr[j]; row[i] = row[2 * i]; - smask_data[info_ptr->width * j + i] = row[2 * i + 1]; + smask_data[width * j + i] = row[2 * i + 1]; } if (HPDF_Stream_Write (image->stream, row, row_len) != HPDF_OK) { @@ -306,7 +312,7 @@ ReadTransparentPngData (HPDF_Dict image, } Error: - for (i = 0; i < (HPDF_UINT)info_ptr->height; i++) { + for (i = 0; i < (HPDF_UINT)height; i++) { HPDF_FreeMem (image->mmgr, row_ptr[i]); } @@ -415,7 +421,8 @@ LoadPngData (HPDF_Dict image, { HPDF_STATUS ret = HPDF_OK; - + png_uint_32 width, height; + int bit_depth, color_type; png_structp png_ptr = NULL; png_infop info_ptr = NULL; @@ -447,8 +454,10 @@ LoadPngData (HPDF_Dict image, goto Exit; } + png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, NULL, NULL, NULL); + /* 16bit images are not supported. */ - if (info_ptr->bit_depth == 16) { + if (bit_depth == 16) { png_set_strip_16(png_ptr); } @@ -458,7 +467,7 @@ LoadPngData (HPDF_Dict image, } /* check palette-based images for transparent areas and load them immediately if found */ - if (xref && PNG_COLOR_TYPE_PALETTE & info_ptr->color_type) { + if (xref && PNG_COLOR_TYPE_PALETTE & color_type) { png_bytep trans; int num_trans; HPDF_Dict smask; @@ -478,10 +487,10 @@ LoadPngData (HPDF_Dict image, smask->header.obj_class |= HPDF_OSUBCLASS_XOBJECT; ret = HPDF_Dict_AddName (smask, "Type", "XObject"); ret += HPDF_Dict_AddName (smask, "Subtype", "Image"); - ret += HPDF_Dict_AddNumber (smask, "Width", (HPDF_UINT)info_ptr->width); - ret += HPDF_Dict_AddNumber (smask, "Height", (HPDF_UINT)info_ptr->height); + ret += HPDF_Dict_AddNumber (smask, "Width", (HPDF_UINT)width); + ret += HPDF_Dict_AddNumber (smask, "Height", (HPDF_UINT)height); ret += HPDF_Dict_AddName (smask, "ColorSpace", "DeviceGray"); - ret += HPDF_Dict_AddNumber (smask, "BitsPerComponent", (HPDF_UINT)info_ptr->bit_depth); + ret += HPDF_Dict_AddNumber (smask, "BitsPerComponent", (HPDF_UINT)bit_depth); if (ret != HPDF_OK) { HPDF_Dict_Free(smask); @@ -489,7 +498,7 @@ LoadPngData (HPDF_Dict image, goto Exit; } - smask_data = HPDF_GetMem(image->mmgr, info_ptr->width * info_ptr->height); + smask_data = HPDF_GetMem(image->mmgr, width * height); if (!smask_data) { HPDF_Dict_Free(smask); ret = HPDF_FAILD_TO_ALLOC_MEM; @@ -503,7 +512,7 @@ LoadPngData (HPDF_Dict image, goto Exit; } - if (HPDF_Stream_Write(smask->stream, smask_data, info_ptr->width * info_ptr->height) != HPDF_OK) { + if (HPDF_Stream_Write(smask->stream, smask_data, width * height) != HPDF_OK) { HPDF_FreeMem(image->mmgr, smask_data); HPDF_Dict_Free(smask); ret = HPDF_FILE_IO_ERROR; @@ -513,9 +522,9 @@ LoadPngData (HPDF_Dict image, ret += CreatePallet(image, png_ptr, info_ptr); - ret += HPDF_Dict_AddNumber (image, "Width", (HPDF_UINT)info_ptr->width); - ret += HPDF_Dict_AddNumber (image, "Height", (HPDF_UINT)info_ptr->height); - ret += HPDF_Dict_AddNumber (image, "BitsPerComponent", (HPDF_UINT)info_ptr->bit_depth); + ret += HPDF_Dict_AddNumber (image, "Width", (HPDF_UINT)width); + ret += HPDF_Dict_AddNumber (image, "Height", (HPDF_UINT)height); + ret += HPDF_Dict_AddNumber (image, "BitsPerComponent", (HPDF_UINT)bit_depth); ret += HPDF_Dict_Add (image, "SMask", smask); png_destroy_read_struct(&png_ptr, &info_ptr, NULL); @@ -526,7 +535,7 @@ no_transparent_color_in_palette: /* read images with alpha channel right away we have to do this because image transparent mask must be added to the Xref */ - if (xref && PNG_COLOR_MASK_ALPHA & info_ptr->color_type) { + if (xref && PNG_COLOR_MASK_ALPHA & color_type) { HPDF_Dict smask; png_bytep smask_data; @@ -539,10 +548,10 @@ no_transparent_color_in_palette: smask->header.obj_class |= HPDF_OSUBCLASS_XOBJECT; ret = HPDF_Dict_AddName (smask, "Type", "XObject"); ret += HPDF_Dict_AddName (smask, "Subtype", "Image"); - ret += HPDF_Dict_AddNumber (smask, "Width", (HPDF_UINT)info_ptr->width); - ret += HPDF_Dict_AddNumber (smask, "Height", (HPDF_UINT)info_ptr->height); + ret += HPDF_Dict_AddNumber (smask, "Width", (HPDF_UINT)width); + ret += HPDF_Dict_AddNumber (smask, "Height", (HPDF_UINT)height); ret += HPDF_Dict_AddName (smask, "ColorSpace", "DeviceGray"); - ret += HPDF_Dict_AddNumber (smask, "BitsPerComponent", (HPDF_UINT)info_ptr->bit_depth); + ret += HPDF_Dict_AddNumber (smask, "BitsPerComponent", (HPDF_UINT)bit_depth); if (ret != HPDF_OK) { HPDF_Dict_Free(smask); @@ -550,7 +559,7 @@ no_transparent_color_in_palette: goto Exit; } - smask_data = HPDF_GetMem(image->mmgr, info_ptr->width * info_ptr->height); + smask_data = HPDF_GetMem(image->mmgr, width * height); if (!smask_data) { HPDF_Dict_Free(smask); ret = HPDF_FAILD_TO_ALLOC_MEM; @@ -564,7 +573,7 @@ no_transparent_color_in_palette: goto Exit; } - if (HPDF_Stream_Write(smask->stream, smask_data, info_ptr->width * info_ptr->height) != HPDF_OK) { + if (HPDF_Stream_Write(smask->stream, smask_data, width * height) != HPDF_OK) { HPDF_FreeMem(image->mmgr, smask_data); HPDF_Dict_Free(smask); ret = HPDF_FILE_IO_ERROR; @@ -572,14 +581,14 @@ no_transparent_color_in_palette: } HPDF_FreeMem(image->mmgr, smask_data); - if (info_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) { + if (color_type == PNG_COLOR_TYPE_GRAY_ALPHA) { ret += HPDF_Dict_AddName (image, "ColorSpace", "DeviceGray"); } else { ret += HPDF_Dict_AddName (image, "ColorSpace", "DeviceRGB"); } - ret += HPDF_Dict_AddNumber (image, "Width", (HPDF_UINT)info_ptr->width); - ret += HPDF_Dict_AddNumber (image, "Height", (HPDF_UINT)info_ptr->height); - ret += HPDF_Dict_AddNumber (image, "BitsPerComponent", (HPDF_UINT)info_ptr->bit_depth); + ret += HPDF_Dict_AddNumber (image, "Width", (HPDF_UINT)width); + ret += HPDF_Dict_AddNumber (image, "Height", (HPDF_UINT)height); + ret += HPDF_Dict_AddNumber (image, "BitsPerComponent", (HPDF_UINT)bit_depth); ret += HPDF_Dict_Add (image, "SMask", smask); png_destroy_read_struct(&png_ptr, &info_ptr, NULL); @@ -589,9 +598,9 @@ no_transparent_color_in_palette: /* if the image has color palette, copy the pallet of the image to * create color map. */ - if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) + if (color_type == PNG_COLOR_TYPE_PALETTE) ret = CreatePallet(image, png_ptr, info_ptr); - else if (info_ptr->color_type == PNG_COLOR_TYPE_GRAY) + else if (color_type == PNG_COLOR_TYPE_GRAY) ret = HPDF_Dict_AddName (image, "ColorSpace", "DeviceGray"); else ret = HPDF_Dict_AddName (image, "ColorSpace", "DeviceRGB"); @@ -617,16 +626,16 @@ no_transparent_color_in_palette: } /* setting the info of the image. */ - if (HPDF_Dict_AddNumber (image, "Width", (HPDF_UINT)info_ptr->width) + if (HPDF_Dict_AddNumber (image, "Width", (HPDF_UINT)width) != HPDF_OK) goto Exit; - if (HPDF_Dict_AddNumber (image, "Height", (HPDF_UINT)info_ptr->height) + if (HPDF_Dict_AddNumber (image, "Height", (HPDF_UINT)height) != HPDF_OK) goto Exit; if (HPDF_Dict_AddNumber (image, "BitsPerComponent", - (HPDF_UINT)info_ptr->bit_depth) != HPDF_OK) + (HPDF_UINT)bit_depth) != HPDF_OK) goto Exit; /* clean up */ diff --git a/harbour/contrib/hbhpdf/3rd/libhpdf/libhpdf.dif b/harbour/contrib/hbhpdf/3rd/libhpdf/libhpdf.dif index 7d5d6fa220..fc81c56db2 100644 --- a/harbour/contrib/hbhpdf/3rd/libhpdf/libhpdf.dif +++ b/harbour/contrib/hbhpdf/3rd/libhpdf/libhpdf.dif @@ -1,6 +1,6 @@ diff -urN libhpdf.orig/hpdf.h libhpdf/hpdf.h ---- libhpdf.orig/hpdf.h 2010-12-06 19:37:33.537341371 +0100 -+++ libhpdf/hpdf.h 2010-12-06 19:37:34.047343524 +0100 +--- libhpdf.orig/hpdf.h 2011-01-10 06:29:07.826240884 +0100 ++++ libhpdf/hpdf.h 2011-01-10 06:29:07.856243780 +0100 @@ -17,7 +17,7 @@ #ifndef _HPDF_H #define _HPDF_H @@ -19,9 +19,344 @@ diff -urN libhpdf.orig/hpdf.h libhpdf/hpdf.h HPDF_Page_CreateTextMarkupAnnot (HPDF_Page page, HPDF_Rect rect, const char *text, +diff -urN libhpdf.orig/hpdfimap.c libhpdf/hpdfimap.c +--- libhpdf.orig/hpdfimap.c 2011-01-10 06:29:06.436240956 +0100 ++++ libhpdf/hpdfimap.c 2011-01-10 06:29:06.436240956 +0100 +@@ -109,14 +109,15 @@ + png_infop info_ptr) + { + png_uint_32 len = png_get_rowbytes(png_ptr, info_ptr); ++ png_uint_32 height = png_get_image_height(png_ptr, info_ptr); + png_bytep* row_pointers = HPDF_GetMem (image->mmgr, +- info_ptr->height * sizeof (png_bytep)); ++ height * sizeof (png_bytep)); + + if (row_pointers) { + HPDF_UINT i; + +- HPDF_MemSet (row_pointers, 0, info_ptr->height * sizeof (png_bytep)); +- for (i = 0; i < (HPDF_UINT)info_ptr->height; i++) { ++ HPDF_MemSet (row_pointers, 0, height * sizeof (png_bytep)); ++ for (i = 0; i < (HPDF_UINT)height; i++) { + row_pointers[i] = HPDF_GetMem (image->mmgr, len); + + if (image->error->error_no != HPDF_OK) +@@ -126,7 +127,7 @@ + if (image->error->error_no == HPDF_OK) { + png_read_image(png_ptr, row_pointers); + if (image->error->error_no == HPDF_OK) { /* add this line */ +- for (i = 0; i < (HPDF_UINT)info_ptr->height; i++) { ++ for (i = 0; i < (HPDF_UINT)height; i++) { + if (HPDF_Stream_Write (image->stream, row_pointers[i], len) != + HPDF_OK) + break; +@@ -135,7 +136,7 @@ + } + + /* clean up */ +- for (i = 0; i < (HPDF_UINT)info_ptr->height; i++) { ++ for (i = 0; i < (HPDF_UINT)height; i++) { + HPDF_FreeMem (image->mmgr, row_pointers[i]); + } + +@@ -151,12 +152,13 @@ + png_infop info_ptr) + { + png_uint_32 len = png_get_rowbytes(png_ptr, info_ptr); ++ png_uint_32 height = png_get_image_height(png_ptr, info_ptr); + png_bytep buf_ptr = HPDF_GetMem (image->mmgr, len); + + if (buf_ptr) { + HPDF_UINT i; + +- for (i = 0; i < (HPDF_UINT)info_ptr->height; i++) { ++ for (i = 0; i < (HPDF_UINT)height; i++) { + png_read_rows(png_ptr, (png_byte**)&buf_ptr, NULL, 1); + if (image->error->error_no != HPDF_OK) + break; +@@ -182,14 +184,16 @@ + HPDF_STATUS ret = HPDF_OK; + HPDF_UINT i, j; + png_bytep *row_ptr; ++ png_uint_32 height = png_get_image_height(png_ptr, info_ptr); ++ png_uint_32 width = png_get_image_width(png_ptr, info_ptr); + +- row_ptr = HPDF_GetMem (image->mmgr, info_ptr->height * sizeof(png_bytep)); ++ row_ptr = HPDF_GetMem (image->mmgr, height * sizeof(png_bytep)); + if (!row_ptr) { + return HPDF_FAILD_TO_ALLOC_MEM; + } else { + png_uint_32 len = png_get_rowbytes(png_ptr, info_ptr); + +- for (i = 0; i < (HPDF_UINT)info_ptr->height; i++) { ++ for (i = 0; i < (HPDF_UINT)height; i++) { + row_ptr[i] = HPDF_GetMem(image->mmgr, len); + if (!row_ptr[i]) { + for (; i >= 0; i--) { +@@ -207,19 +211,19 @@ + goto Error; + } + +- for (j = 0; j < info_ptr->height; j++) { +- for (i = 0; i < info_ptr->width; i++) { +- smask_data[info_ptr->width * j + i] = (row_ptr[j][i] < num_trans) ? trans[row_ptr[j][i]] : 0xFF; ++ for (j = 0; j < height; j++) { ++ for (i = 0; i < width; i++) { ++ smask_data[width * j + i] = (row_ptr[j][i] < num_trans) ? trans[row_ptr[j][i]] : 0xFF; + } + +- if (HPDF_Stream_Write (image->stream, row_ptr[j], info_ptr->width) != HPDF_OK) { ++ if (HPDF_Stream_Write (image->stream, row_ptr[j], width) != HPDF_OK) { + ret = HPDF_FILE_IO_ERROR; + goto Error; + } + } + + Error: +- for (i = 0; i < (HPDF_UINT)info_ptr->height; i++) { ++ for (i = 0; i < (HPDF_UINT)height; i++) { + HPDF_FreeMem (image->mmgr, row_ptr[i]); + } + +@@ -238,6 +242,8 @@ + HPDF_UINT i, j; + png_bytep *row_ptr, row; + png_byte color_type; ++ png_uint_32 height = png_get_image_height(png_ptr, info_ptr); ++ png_uint_32 width = png_get_image_width(png_ptr, info_ptr); + + color_type = png_get_color_type(png_ptr, info_ptr); + +@@ -245,13 +251,13 @@ + return HPDF_INVALID_PNG_IMAGE; + } + +- row_ptr = HPDF_GetMem (image->mmgr, info_ptr->height * sizeof(png_bytep)); ++ row_ptr = HPDF_GetMem (image->mmgr, height * sizeof(png_bytep)); + if (!row_ptr) { + return HPDF_FAILD_TO_ALLOC_MEM; + } else { + png_uint_32 len = png_get_rowbytes(png_ptr, info_ptr); + +- for (i = 0; i < (HPDF_UINT)info_ptr->height; i++) { ++ for (i = 0; i < (HPDF_UINT)height; i++) { + row_ptr[i] = HPDF_GetMem(image->mmgr, len); + if (!row_ptr[i]) { + for (; i >= 0; i--) { +@@ -271,12 +277,12 @@ + + switch (color_type) { + case PNG_COLOR_TYPE_RGB_ALPHA: +- row_len = 3 * info_ptr->width * sizeof(png_byte); +- for (j = 0; j < info_ptr->height; j++) { +- for (i = 0; i < info_ptr->width; i++) { ++ row_len = 3 * width * sizeof(png_byte); ++ for (j = 0; j < height; j++) { ++ for (i = 0; i < width; i++) { + row = row_ptr[j]; + memmove(row + (3 * i), row + (4*i), 3); +- smask_data[info_ptr->width * j + i] = row[4 * i + 3]; ++ smask_data[width * j + i] = row[4 * i + 3]; + } + + if (HPDF_Stream_Write (image->stream, row, row_len) != HPDF_OK) { +@@ -286,12 +292,12 @@ + } + break; + case PNG_COLOR_TYPE_GRAY_ALPHA: +- row_len = info_ptr->width * sizeof(png_byte); +- for (j = 0; j < info_ptr->height; j++) { +- for (i = 0; i < info_ptr->width; i++) { ++ row_len = width * sizeof(png_byte); ++ for (j = 0; j < height; j++) { ++ for (i = 0; i < width; i++) { + row = row_ptr[j]; + row[i] = row[2 * i]; +- smask_data[info_ptr->width * j + i] = row[2 * i + 1]; ++ smask_data[width * j + i] = row[2 * i + 1]; + } + + if (HPDF_Stream_Write (image->stream, row, row_len) != HPDF_OK) { +@@ -306,7 +312,7 @@ + } + + Error: +- for (i = 0; i < (HPDF_UINT)info_ptr->height; i++) { ++ for (i = 0; i < (HPDF_UINT)height; i++) { + HPDF_FreeMem (image->mmgr, row_ptr[i]); + } + +@@ -415,7 +421,8 @@ + + { + HPDF_STATUS ret = HPDF_OK; +- ++ png_uint_32 width, height; ++ int bit_depth, color_type; + png_structp png_ptr = NULL; + png_infop info_ptr = NULL; + +@@ -447,8 +454,10 @@ + goto Exit; + } + ++ png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, NULL, NULL, NULL); ++ + /* 16bit images are not supported. */ +- if (info_ptr->bit_depth == 16) { ++ if (bit_depth == 16) { + png_set_strip_16(png_ptr); + } + +@@ -458,7 +467,7 @@ + } + + /* check palette-based images for transparent areas and load them immediately if found */ +- if (xref && PNG_COLOR_TYPE_PALETTE & info_ptr->color_type) { ++ if (xref && PNG_COLOR_TYPE_PALETTE & color_type) { + png_bytep trans; + int num_trans; + HPDF_Dict smask; +@@ -478,10 +487,10 @@ + smask->header.obj_class |= HPDF_OSUBCLASS_XOBJECT; + ret = HPDF_Dict_AddName (smask, "Type", "XObject"); + ret += HPDF_Dict_AddName (smask, "Subtype", "Image"); +- ret += HPDF_Dict_AddNumber (smask, "Width", (HPDF_UINT)info_ptr->width); +- ret += HPDF_Dict_AddNumber (smask, "Height", (HPDF_UINT)info_ptr->height); ++ ret += HPDF_Dict_AddNumber (smask, "Width", (HPDF_UINT)width); ++ ret += HPDF_Dict_AddNumber (smask, "Height", (HPDF_UINT)height); + ret += HPDF_Dict_AddName (smask, "ColorSpace", "DeviceGray"); +- ret += HPDF_Dict_AddNumber (smask, "BitsPerComponent", (HPDF_UINT)info_ptr->bit_depth); ++ ret += HPDF_Dict_AddNumber (smask, "BitsPerComponent", (HPDF_UINT)bit_depth); + + if (ret != HPDF_OK) { + HPDF_Dict_Free(smask); +@@ -489,7 +498,7 @@ + goto Exit; + } + +- smask_data = HPDF_GetMem(image->mmgr, info_ptr->width * info_ptr->height); ++ smask_data = HPDF_GetMem(image->mmgr, width * height); + if (!smask_data) { + HPDF_Dict_Free(smask); + ret = HPDF_FAILD_TO_ALLOC_MEM; +@@ -503,7 +512,7 @@ + goto Exit; + } + +- if (HPDF_Stream_Write(smask->stream, smask_data, info_ptr->width * info_ptr->height) != HPDF_OK) { ++ if (HPDF_Stream_Write(smask->stream, smask_data, width * height) != HPDF_OK) { + HPDF_FreeMem(image->mmgr, smask_data); + HPDF_Dict_Free(smask); + ret = HPDF_FILE_IO_ERROR; +@@ -513,9 +522,9 @@ + + + ret += CreatePallet(image, png_ptr, info_ptr); +- ret += HPDF_Dict_AddNumber (image, "Width", (HPDF_UINT)info_ptr->width); +- ret += HPDF_Dict_AddNumber (image, "Height", (HPDF_UINT)info_ptr->height); +- ret += HPDF_Dict_AddNumber (image, "BitsPerComponent", (HPDF_UINT)info_ptr->bit_depth); ++ ret += HPDF_Dict_AddNumber (image, "Width", (HPDF_UINT)width); ++ ret += HPDF_Dict_AddNumber (image, "Height", (HPDF_UINT)height); ++ ret += HPDF_Dict_AddNumber (image, "BitsPerComponent", (HPDF_UINT)bit_depth); + ret += HPDF_Dict_Add (image, "SMask", smask); + + png_destroy_read_struct(&png_ptr, &info_ptr, NULL); +@@ -526,7 +535,7 @@ + + /* read images with alpha channel right away + we have to do this because image transparent mask must be added to the Xref */ +- if (xref && PNG_COLOR_MASK_ALPHA & info_ptr->color_type) { ++ if (xref && PNG_COLOR_MASK_ALPHA & color_type) { + HPDF_Dict smask; + png_bytep smask_data; + +@@ -539,10 +548,10 @@ + smask->header.obj_class |= HPDF_OSUBCLASS_XOBJECT; + ret = HPDF_Dict_AddName (smask, "Type", "XObject"); + ret += HPDF_Dict_AddName (smask, "Subtype", "Image"); +- ret += HPDF_Dict_AddNumber (smask, "Width", (HPDF_UINT)info_ptr->width); +- ret += HPDF_Dict_AddNumber (smask, "Height", (HPDF_UINT)info_ptr->height); ++ ret += HPDF_Dict_AddNumber (smask, "Width", (HPDF_UINT)width); ++ ret += HPDF_Dict_AddNumber (smask, "Height", (HPDF_UINT)height); + ret += HPDF_Dict_AddName (smask, "ColorSpace", "DeviceGray"); +- ret += HPDF_Dict_AddNumber (smask, "BitsPerComponent", (HPDF_UINT)info_ptr->bit_depth); ++ ret += HPDF_Dict_AddNumber (smask, "BitsPerComponent", (HPDF_UINT)bit_depth); + + if (ret != HPDF_OK) { + HPDF_Dict_Free(smask); +@@ -550,7 +559,7 @@ + goto Exit; + } + +- smask_data = HPDF_GetMem(image->mmgr, info_ptr->width * info_ptr->height); ++ smask_data = HPDF_GetMem(image->mmgr, width * height); + if (!smask_data) { + HPDF_Dict_Free(smask); + ret = HPDF_FAILD_TO_ALLOC_MEM; +@@ -564,7 +573,7 @@ + goto Exit; + } + +- if (HPDF_Stream_Write(smask->stream, smask_data, info_ptr->width * info_ptr->height) != HPDF_OK) { ++ if (HPDF_Stream_Write(smask->stream, smask_data, width * height) != HPDF_OK) { + HPDF_FreeMem(image->mmgr, smask_data); + HPDF_Dict_Free(smask); + ret = HPDF_FILE_IO_ERROR; +@@ -572,14 +581,14 @@ + } + HPDF_FreeMem(image->mmgr, smask_data); + +- if (info_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) { ++ if (color_type == PNG_COLOR_TYPE_GRAY_ALPHA) { + ret += HPDF_Dict_AddName (image, "ColorSpace", "DeviceGray"); + } else { + ret += HPDF_Dict_AddName (image, "ColorSpace", "DeviceRGB"); + } +- ret += HPDF_Dict_AddNumber (image, "Width", (HPDF_UINT)info_ptr->width); +- ret += HPDF_Dict_AddNumber (image, "Height", (HPDF_UINT)info_ptr->height); +- ret += HPDF_Dict_AddNumber (image, "BitsPerComponent", (HPDF_UINT)info_ptr->bit_depth); ++ ret += HPDF_Dict_AddNumber (image, "Width", (HPDF_UINT)width); ++ ret += HPDF_Dict_AddNumber (image, "Height", (HPDF_UINT)height); ++ ret += HPDF_Dict_AddNumber (image, "BitsPerComponent", (HPDF_UINT)bit_depth); + ret += HPDF_Dict_Add (image, "SMask", smask); + + png_destroy_read_struct(&png_ptr, &info_ptr, NULL); +@@ -589,9 +598,9 @@ + /* if the image has color palette, copy the pallet of the image to + * create color map. + */ +- if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) ++ if (color_type == PNG_COLOR_TYPE_PALETTE) + ret = CreatePallet(image, png_ptr, info_ptr); +- else if (info_ptr->color_type == PNG_COLOR_TYPE_GRAY) ++ else if (color_type == PNG_COLOR_TYPE_GRAY) + ret = HPDF_Dict_AddName (image, "ColorSpace", "DeviceGray"); + else + ret = HPDF_Dict_AddName (image, "ColorSpace", "DeviceRGB"); +@@ -617,16 +626,16 @@ + } + + /* setting the info of the image. */ +- if (HPDF_Dict_AddNumber (image, "Width", (HPDF_UINT)info_ptr->width) ++ if (HPDF_Dict_AddNumber (image, "Width", (HPDF_UINT)width) + != HPDF_OK) + goto Exit; + +- if (HPDF_Dict_AddNumber (image, "Height", (HPDF_UINT)info_ptr->height) ++ if (HPDF_Dict_AddNumber (image, "Height", (HPDF_UINT)height) + != HPDF_OK) + goto Exit; + + if (HPDF_Dict_AddNumber (image, "BitsPerComponent", +- (HPDF_UINT)info_ptr->bit_depth) != HPDF_OK) ++ (HPDF_UINT)bit_depth) != HPDF_OK) + goto Exit; + + /* clean up */ diff -urN libhpdf.orig/hpdfpdfa.c libhpdf/hpdfpdfa.c ---- libhpdf.orig/hpdfpdfa.c 2010-12-06 19:37:32.597342286 +0100 -+++ libhpdf/hpdfpdfa.c 2010-12-06 19:37:34.047343524 +0100 +--- libhpdf.orig/hpdfpdfa.c 2011-01-10 06:29:06.646243627 +0100 ++++ libhpdf/hpdfpdfa.c 2011-01-10 06:29:06.676244568 +0100 @@ -116,12 +116,12 @@ HPDF_BYTE *currentTime; HPDF_BYTE idkey[HPDF_MD5_KEY_LEN]; @@ -37,8 +372,8 @@ diff -urN libhpdf.orig/hpdfpdfa.c libhpdf/hpdfpdfa.c if (!id) { id = HPDF_Array_New(pdf->mmgr); diff -urN libhpdf.orig/hpdfutil.h libhpdf/hpdfutil.h ---- libhpdf.orig/hpdfutil.h 2010-12-06 19:37:34.037342732 +0100 -+++ libhpdf/hpdfutil.h 2010-12-06 19:37:34.047343524 +0100 +--- libhpdf.orig/hpdfutil.h 2011-01-10 06:29:08.696240792 +0100 ++++ libhpdf/hpdfutil.h 2011-01-10 06:29:08.706244085 +0100 @@ -18,7 +18,7 @@ #ifndef _HPDF_UTILS_H #define _HPDF_UTILS_H diff --git a/harbour/contrib/hbhpdf/3rd/libhpdf/libhpdf.hbp b/harbour/contrib/hbhpdf/3rd/libhpdf/libhpdf.hbp index 7f5b7d4c5e..57d0eb90d6 100644 --- a/harbour/contrib/hbhpdf/3rd/libhpdf/libhpdf.hbp +++ b/harbour/contrib/hbhpdf/3rd/libhpdf/libhpdf.hbp @@ -28,8 +28,6 @@ -depincpath=zlib:/boot/develop/headers/3rdparty -depincpathlocal=zlib:../../../../src/3rd/zlib -# Suppress deprecated warnings until libharu gets updated for latest libpng --cflag=-DPNG_NO_PEDANTIC_WARNINGS -cflag=-DHPDF_DLL_MAKE_CDECL{allwin&hbdyn} -cflag=-U__COREDLL__{mingwarm}