summaryrefslogtreecommitdiff
path: root/sys/src/cmd/aux/antiword/jpeg2eps.c
diff options
context:
space:
mode:
authorTaru Karttunen <taruti@taruti.net>2011-03-30 15:46:40 +0300
committerTaru Karttunen <taruti@taruti.net>2011-03-30 15:46:40 +0300
commite5888a1ffdae813d7575f5fb02275c6bb07e5199 (patch)
treed8d51eac403f07814b9e936eed0c9a79195e2450 /sys/src/cmd/aux/antiword/jpeg2eps.c
Import sources from 2011-03-30 iso image
Diffstat (limited to 'sys/src/cmd/aux/antiword/jpeg2eps.c')
-rwxr-xr-xsys/src/cmd/aux/antiword/jpeg2eps.c74
1 files changed, 74 insertions, 0 deletions
diff --git a/sys/src/cmd/aux/antiword/jpeg2eps.c b/sys/src/cmd/aux/antiword/jpeg2eps.c
new file mode 100755
index 000000000..ee438cec4
--- /dev/null
+++ b/sys/src/cmd/aux/antiword/jpeg2eps.c
@@ -0,0 +1,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 */