You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

113 lines
4.7 KiB

  1. --- a/libtiff/tif_dir.c
  2. +++ b/libtiff/tif_dir.c
  3. @@ -1067,6 +1067,9 @@ _TIFFVGetField(TIFF* tif, uint32 tag, va
  4. if (td->td_samplesperpixel - td->td_extrasamples > 1) {
  5. *va_arg(ap, uint16**) = td->td_transferfunction[1];
  6. *va_arg(ap, uint16**) = td->td_transferfunction[2];
  7. + } else {
  8. + *va_arg(ap, uint16**) = NULL;
  9. + *va_arg(ap, uint16**) = NULL;
  10. }
  11. break;
  12. case TIFFTAG_REFERENCEBLACKWHITE:
  13. --- a/tools/tiff2pdf.c
  14. +++ b/tools/tiff2pdf.c
  15. @@ -237,7 +237,7 @@ typedef struct {
  16. float tiff_whitechromaticities[2];
  17. float tiff_primarychromaticities[6];
  18. float tiff_referenceblackwhite[2];
  19. - float* tiff_transferfunction[3];
  20. + uint16* tiff_transferfunction[3];
  21. int pdf_image_interpolate; /* 0 (default) : do not interpolate,
  22. 1 : interpolate */
  23. uint16 tiff_transferfunctioncount;
  24. @@ -1047,6 +1047,8 @@ void t2p_read_tiff_init(T2P* t2p, TIFF*
  25. uint16 pagen=0;
  26. uint16 paged=0;
  27. uint16 xuint16=0;
  28. + uint16 tiff_transferfunctioncount=0;
  29. + uint16* tiff_transferfunction[3];
  30. directorycount=TIFFNumberOfDirectories(input);
  31. t2p->tiff_pages = (T2P_PAGE*) _TIFFmalloc(TIFFSafeMultiply(tmsize_t,directorycount,sizeof(T2P_PAGE)));
  32. @@ -1147,26 +1149,48 @@ void t2p_read_tiff_init(T2P* t2p, TIFF*
  33. }
  34. #endif
  35. if (TIFFGetField(input, TIFFTAG_TRANSFERFUNCTION,
  36. - &(t2p->tiff_transferfunction[0]),
  37. - &(t2p->tiff_transferfunction[1]),
  38. - &(t2p->tiff_transferfunction[2]))) {
  39. - if((t2p->tiff_transferfunction[1] != (float*) NULL) &&
  40. - (t2p->tiff_transferfunction[2] != (float*) NULL) &&
  41. - (t2p->tiff_transferfunction[1] !=
  42. - t2p->tiff_transferfunction[0])) {
  43. - t2p->tiff_transferfunctioncount = 3;
  44. - t2p->tiff_pages[i].page_extra += 4;
  45. - t2p->pdf_xrefcount += 4;
  46. - } else {
  47. - t2p->tiff_transferfunctioncount = 1;
  48. - t2p->tiff_pages[i].page_extra += 2;
  49. - t2p->pdf_xrefcount += 2;
  50. - }
  51. - if(t2p->pdf_minorversion < 2)
  52. - t2p->pdf_minorversion = 2;
  53. + &(tiff_transferfunction[0]),
  54. + &(tiff_transferfunction[1]),
  55. + &(tiff_transferfunction[2]))) {
  56. +
  57. + if((tiff_transferfunction[1] != (uint16*) NULL) &&
  58. + (tiff_transferfunction[2] != (uint16*) NULL)
  59. + ) {
  60. + tiff_transferfunctioncount=3;
  61. + } else {
  62. + tiff_transferfunctioncount=1;
  63. + }
  64. } else {
  65. - t2p->tiff_transferfunctioncount=0;
  66. + tiff_transferfunctioncount=0;
  67. }
  68. +
  69. + if (i > 0){
  70. + if (tiff_transferfunctioncount != t2p->tiff_transferfunctioncount){
  71. + TIFFError(
  72. + TIFF2PDF_MODULE,
  73. + "Different transfer function on page %d",
  74. + i);
  75. + t2p->t2p_error = T2P_ERR_ERROR;
  76. + return;
  77. + }
  78. + }
  79. +
  80. + t2p->tiff_transferfunctioncount = tiff_transferfunctioncount;
  81. + t2p->tiff_transferfunction[0] = tiff_transferfunction[0];
  82. + t2p->tiff_transferfunction[1] = tiff_transferfunction[1];
  83. + t2p->tiff_transferfunction[2] = tiff_transferfunction[2];
  84. + if(tiff_transferfunctioncount == 3){
  85. + t2p->tiff_pages[i].page_extra += 4;
  86. + t2p->pdf_xrefcount += 4;
  87. + if(t2p->pdf_minorversion < 2)
  88. + t2p->pdf_minorversion = 2;
  89. + } else if (tiff_transferfunctioncount == 1){
  90. + t2p->tiff_pages[i].page_extra += 2;
  91. + t2p->pdf_xrefcount += 2;
  92. + if(t2p->pdf_minorversion < 2)
  93. + t2p->pdf_minorversion = 2;
  94. + }
  95. +
  96. if( TIFFGetField(
  97. input,
  98. TIFFTAG_ICCPROFILE,
  99. @@ -1827,10 +1851,9 @@ void t2p_read_tiff_data(T2P* t2p, TIFF*
  100. &(t2p->tiff_transferfunction[0]),
  101. &(t2p->tiff_transferfunction[1]),
  102. &(t2p->tiff_transferfunction[2]))) {
  103. - if((t2p->tiff_transferfunction[1] != (float*) NULL) &&
  104. - (t2p->tiff_transferfunction[2] != (float*) NULL) &&
  105. - (t2p->tiff_transferfunction[1] !=
  106. - t2p->tiff_transferfunction[0])) {
  107. + if((t2p->tiff_transferfunction[1] != (uint16*) NULL) &&
  108. + (t2p->tiff_transferfunction[2] != (uint16*) NULL)
  109. + ) {
  110. t2p->tiff_transferfunctioncount=3;
  111. } else {
  112. t2p->tiff_transferfunctioncount=1;