examples/PIPS/antiword/src/imgtrans.c

00001 /*
00002  * imgtrans.c
00003  * Copyright (C) 2000-2002 A.J. van Os; Released under GPL
00004  *
00005  * Description:
00006  * Generic functions to translate Word images
00007  */
00008 
00009 #include <stdio.h>
00010 #include "antiword.h"
00011 
00012 
00013 /*
00014  * bTranslateImage - translate the image
00015  *
00016  * This function reads the type of the given image and and gets it translated.
00017  *
00018  * return TRUE when sucessful, otherwise FALSE
00019  */
00020 BOOL
00021 bTranslateImage(diagram_type *pDiag, FILE *pFile, BOOL bMinimalInformation,
00022         ULONG ulFileOffsetImage, const imagedata_type *pImg)
00023 {
00024         options_type    tOptions;
00025 
00026         DBG_MSG("bTranslateImage");
00027 
00028         fail(pDiag == NULL);
00029         fail(pFile == NULL);
00030         fail(ulFileOffsetImage == FC_INVALID);
00031         fail(pImg == NULL);
00032         fail(pImg->iHorSizeScaled <= 0);
00033         fail(pImg->iVerSizeScaled <= 0);
00034 
00035         vGetOptions(&tOptions);
00036         fail(tOptions.eImageLevel == level_no_images);
00037 
00038         if (bMinimalInformation) {
00039                 return bAddDummyImage(pDiag, pImg);
00040         }
00041 
00042         switch (pImg->eImageType) {
00043         case imagetype_is_dib:
00044                 return bTranslateDIB(pDiag, pFile,
00045                                 ulFileOffsetImage + pImg->tPosition,
00046                                 pImg);
00047         case imagetype_is_jpeg:
00048                 return bTranslateJPEG(pDiag, pFile,
00049                                 ulFileOffsetImage + pImg->tPosition,
00050                                 pImg->tLength - pImg->tPosition,
00051                                 pImg);
00052         case imagetype_is_png:
00053                 if (tOptions.eImageLevel == level_ps_2) {
00054                         return bAddDummyImage(pDiag, pImg);
00055                 }
00056                 return bTranslatePNG(pDiag, pFile,
00057                                 ulFileOffsetImage + pImg->tPosition,
00058                                 pImg->tLength - pImg->tPosition,
00059                                 pImg);
00060         case imagetype_is_emf:
00061         case imagetype_is_wmf:
00062         case imagetype_is_pict:
00063         case imagetype_is_external:
00064                 /* FIXME */
00065                 return bAddDummyImage(pDiag, pImg);
00066         case imagetype_is_unknown:
00067         default:
00068                 DBG_DEC(pImg->eImageType);
00069                 return bAddDummyImage(pDiag, pImg);
00070         }
00071 } /* end of bTranslateImage */

Generated by  doxygen 1.6.2