-
Notifications
You must be signed in to change notification settings - Fork 4
/
jpeg2eps.c
74 lines (64 loc) · 1.45 KB
/
jpeg2eps.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*
* jpeg2eps.c
* Copyright (C) 2000-2002 A.J. van Os; Released under GPL
*
* Description:
* Functions to translate jpeg pictures into eps
*
*/
#include <stdio.h>
#include "antiword.h"
#if defined(DEBUG)
static int iPicCounter = 0;
#endif /* DEBUG */
#if defined(DEBUG)
/*
* vCopy2File
*/
static void
vCopy2File(FILE *pFile, ULONG ulFileOffset, size_t tPictureLen)
{
FILE *pOutFile;
size_t tIndex;
int iTmp;
char szFilename[30];
if (!bSetDataOffset(pFile, ulFileOffset)) {
return;
}
sprintf(szFilename, "/tmp/pic/pic%04d.jpg", ++iPicCounter);
pOutFile = fopen(szFilename, "wb");
if (pOutFile == NULL) {
return;
}
for (tIndex = 0; tIndex < tPictureLen; tIndex++) {
iTmp = iNextByte(pFile);
if (putc(iTmp, pOutFile) == EOF) {
break;
}
}
(void)fclose(pOutFile);
} /* end of vCopy2File */
#endif /* DEBUG */
/*
* bTranslateJPEG - translate a JPEG picture
*
* This function translates a picture from jpeg to eps
*
* return TRUE when sucessful, otherwise FALSE
*/
BOOL
bTranslateJPEG(diagram_type *pDiag, FILE *pFile,
ULONG ulFileOffset, size_t tPictureLen, const imagedata_type *pImg)
{
#if defined(DEBUG)
vCopy2File(pFile, ulFileOffset, tPictureLen);
#endif /* DEBUG */
/* Seek to start position of JPEG data */
if (!bSetDataOffset(pFile, ulFileOffset)) {
return FALSE;
}
vImagePrologue(pDiag, pImg);
vASCII85EncodeFile(pFile, pDiag->pOutFile, tPictureLen);
vImageEpilogue(pDiag);
return TRUE;
} /* end of bTranslateJPEG */