diff -r f345bda72bc4 -r 43e37759235e Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/jpeg2sprt_8c_source.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/jpeg2sprt_8c_source.html Tue Mar 30 16:16:55 2010 +0100 @@ -0,0 +1,116 @@ + + +
+ +00001 /* +00002 * jpeg2sprt.c +00003 * Copyright (C) 2000-2002 A.J. van Os; Released under GPL +00004 * +00005 * Description: +00006 * Functions to translate jpeg pictures into sprites +00007 */ +00008 +00009 #include <stdio.h> +00010 #include "antiword.h" +00011 +00012 #if 0 /* defined(DEBUG) */ +00013 static int iPicCounter = 0; +00014 #endif /* DEBUG */ +00015 +00016 +00017 #if 0 /* defined(DEBUG) */ +00018 static void +00019 vCopy2File(UCHAR *pucJpeg, size_t tJpegSize) +00020 { +00021 FILE *pOutFile; +00022 size_t tIndex; +00023 char szFilename[30]; +00024 +00025 sprintf(szFilename, "<Wimp$ScrapDir>.jpeg%04d", ++iPicCounter); +00026 pOutFile = fopen(szFilename, "wb"); +00027 if (pOutFile == NULL) { +00028 return; +00029 } +00030 DBG_MSG(szFilename); +00031 for (tIndex = 0; tIndex < tJpegSize; tIndex++) { +00032 if (putc(pucJpeg[tIndex], pOutFile) == EOF) { +00033 break; +00034 } +00035 } +00036 (void)fclose(pOutFile); +00037 vSetFiletype(szFilename, FILETYPE_JPEG); +00038 } /* end of vCopy2File */ +00039 #endif /* DEBUG */ +00040 +00041 /* +00042 * bSave2Draw - save the JPEG picture to the Draw file +00043 * +00044 * This function puts a JPEG picture in a Draw file +00045 * +00046 * return TRUE when sucessful, otherwise FALSE +00047 */ +00048 BOOL +00049 bSave2Draw(diagram_type *pDiag, FILE *pFile, +00050 size_t tJpegSize, const imagedata_type *pImg) +00051 { +00052 UCHAR *pucJpeg, *pucTmp; +00053 size_t tLen; +00054 int iByte; +00055 +00056 pucJpeg = xmalloc(tJpegSize); +00057 for (pucTmp = pucJpeg, tLen = 0; tLen < tJpegSize; pucTmp++, tLen++) { +00058 iByte = iNextByte(pFile); +00059 if (iByte == EOF) { +00060 return FALSE; +00061 } +00062 *pucTmp = (UCHAR)iByte; +00063 } +00064 +00065 #if 0 /* defined(DEBUG) */ +00066 vCopy2File(pucJpeg, tJpegSize); +00067 #endif /* DEBUG */ +00068 +00069 /* Add the JPEG to the Draw file */ +00070 vImage2Diagram(pDiag, pImg, pucJpeg, tJpegSize); +00071 +00072 xfree(pucJpeg); +00073 return TRUE; +00074 } /* end of bSave2Draw */ +00075 +00076 /* +00077 * bTranslateJPEG - translate a JPEG picture +00078 * +00079 * This function translates a picture from jpeg to sprite +00080 * +00081 * return TRUE when sucessful, otherwise FALSE +00082 */ +00083 #if 0 +00084 BOOL +00085 bTranslateJPEG(diagram_type *pDiag, FILE *pFile, +00086 ULONG ulFileOffset, size_t tPictureLen, const imagedata_type *pImg) +00087 { +00088 /* Seek to start position of JPEG data */ +00089 if (!bSetDataOffset(pFile, ulFileOffset)) { +00090 return FALSE; +00091 } +00092 +00093 if (iGetRiscOsVersion() >= 360) { +00094 return bSave2Draw(pDiag, pFile, tPictureLen, pImg); +00095 } +00096 /* JPEG is not supported until RISC OS 3.6 */ +00097 return bAddDummyImage(pDiag, pImg); +00098 } /* end of bTranslateJPEG */ +00099 +00100 #endif/*0*/ +