*** empty log message ***

This commit is contained in:
Andrey Kiselev 2010-06-30 16:04:50 +00:00
parent 5a48f5167f
commit 5122fdb3e0
2 changed files with 15 additions and 27 deletions

View File

@ -1,5 +1,8 @@
2010-06-30 Andrey Kiselev <dron@ak4719.spb.edu> 2010-06-30 Andrey Kiselev <dron@ak4719.spb.edu>
* tools/tiff2pdf.c: Better generation of ID field in
t2p_write_pdf_trailer(). Get rid of GCC aliasing warnings.
* tools/tiff2pdf.c: Fixed computation of the tile buffer size when * tools/tiff2pdf.c: Fixed computation of the tile buffer size when
converting JPEG encoded tiles. converting JPEG encoded tiles.

View File

@ -1,4 +1,4 @@
/* $Id: tiff2pdf.c,v 1.56 2010-06-30 15:41:49 dron Exp $ /* $Id: tiff2pdf.c,v 1.57 2010-06-30 16:04:50 dron Exp $
* *
* tiff2pdf - converts a TIFF image to a PDF document * tiff2pdf - converts a TIFF image to a PDF document
* *
@ -197,7 +197,8 @@ typedef struct {
uint32 pdf_palettecs; uint32 pdf_palettecs;
uint16 pdf_fitwindow; uint16 pdf_fitwindow;
uint32 pdf_startxref; uint32 pdf_startxref;
unsigned char* pdf_fileid; #define TIFF2PDF_FILEID_SIZE 33
char pdf_fileid[TIFF2PDF_FILEID_SIZE];
#define TIFF2PDF_DATETIME_SIZE 17 #define TIFF2PDF_DATETIME_SIZE 17
char pdf_datetime[TIFF2PDF_DATETIME_SIZE]; char pdf_datetime[TIFF2PDF_DATETIME_SIZE];
#define TIFF2PDF_CREATOR_SIZE 512 #define TIFF2PDF_CREATOR_SIZE 512
@ -933,9 +934,6 @@ void t2p_free(T2P* t2p)
if(t2p->pdf_palette != NULL){ if(t2p->pdf_palette != NULL){
_TIFFfree( (tdata_t) t2p->pdf_palette); _TIFFfree( (tdata_t) t2p->pdf_palette);
} }
if(t2p->pdf_fileid != NULL){
_TIFFfree( (tdata_t) t2p->pdf_fileid);
}
#ifdef OJPEG_SUPPORT #ifdef OJPEG_SUPPORT
if(t2p->pdf_ojpegdata != NULL){ if(t2p->pdf_ojpegdata != NULL){
_TIFFfree( (tdata_t) t2p->pdf_ojpegdata); _TIFFfree( (tdata_t) t2p->pdf_ojpegdata);
@ -5054,27 +5052,12 @@ tsize_t t2p_write_pdf_trailer(T2P* t2p, TIFF* output)
tsize_t written = 0; tsize_t written = 0;
char buffer[32]; char buffer[32];
int buflen = 0; int buflen = 0;
char fileidbuf[16]; size_t i = 0;
int i = 0;
for (i = 0; i < sizeof(t2p->pdf_fileid); i += 8)
snprintf(t2p->pdf_fileid + i, 9, "%.8X", rand());
t2p->pdf_fileid[sizeof(t2p->pdf_fileid) - 1] = '\0';
((int*)fileidbuf)[0] = rand();
((int*)fileidbuf)[1] = rand();
((int*)fileidbuf)[2] = rand();
((int*)fileidbuf)[3] = rand();
t2p->pdf_fileid = (unsigned char*)_TIFFmalloc(33);
if(t2p->pdf_fileid == NULL) {
TIFFError(
TIFF2PDF_MODULE,
"Can't allocate %u bytes of memory for t2p_write_pdf_trailer",
33 );
t2p->t2p_error = T2P_ERR_ERROR;
return(0);
}
_TIFFmemset(t2p->pdf_fileid, 0x00, 33);
for (i = 0; i < 16; i++) {
sprintf((char *)t2p->pdf_fileid + 2 * i,
"%.2hhX", fileidbuf[i]);
}
written += t2pWriteFile(output, (tdata_t) "trailer\n<<\n/Size ", 17); written += t2pWriteFile(output, (tdata_t) "trailer\n<<\n/Size ", 17);
buflen = sprintf(buffer, "%lu", (unsigned long)(t2p->pdf_xrefcount+1)); buflen = sprintf(buffer, "%lu", (unsigned long)(t2p->pdf_xrefcount+1));
written += t2pWriteFile(output, (tdata_t) buffer, buflen); written += t2pWriteFile(output, (tdata_t) buffer, buflen);
@ -5088,9 +5071,11 @@ tsize_t t2p_write_pdf_trailer(T2P* t2p, TIFF* output)
written += t2pWriteFile(output, (tdata_t) buffer, buflen); written += t2pWriteFile(output, (tdata_t) buffer, buflen);
_TIFFmemset(buffer, 0x00, 32); _TIFFmemset(buffer, 0x00, 32);
written += t2pWriteFile(output, (tdata_t) " 0 R \n/ID[<", 11); written += t2pWriteFile(output, (tdata_t) " 0 R \n/ID[<", 11);
written += t2pWriteFile(output, (tdata_t) t2p->pdf_fileid, 32); written += t2pWriteFile(output, (tdata_t) t2p->pdf_fileid,
sizeof(t2p->pdf_fileid) - 1);
written += t2pWriteFile(output, (tdata_t) "><", 2); written += t2pWriteFile(output, (tdata_t) "><", 2);
written += t2pWriteFile(output, (tdata_t) t2p->pdf_fileid, 32); written += t2pWriteFile(output, (tdata_t) t2p->pdf_fileid,
sizeof(t2p->pdf_fileid) - 1);
written += t2pWriteFile(output, (tdata_t) ">]\n>>\nstartxref\n", 16); written += t2pWriteFile(output, (tdata_t) ">]\n>>\nstartxref\n", 16);
buflen=sprintf(buffer, "%lu", (unsigned long)t2p->pdf_startxref); buflen=sprintf(buffer, "%lu", (unsigned long)t2p->pdf_startxref);
written += t2pWriteFile(output, (tdata_t) buffer, buflen); written += t2pWriteFile(output, (tdata_t) buffer, buflen);