Blender  V2.59
filetype.c
Go to the documentation of this file.
00001 /*
00002  * $Id: filetype.c 35362 2011-03-05 10:29:10Z campbellbarton $
00003  *
00004  * ***** BEGIN GPL LICENSE BLOCK *****
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License
00008  * as published by the Free Software Foundation; either version 2
00009  * of the License, or (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software Foundation,
00018  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00019  *
00020  * Contributor(s): Blender Foundation, 2010.
00021  *
00022  * ***** END GPL LICENSE BLOCK *****
00023  */
00024 
00030 #include <stddef.h>
00031 #include "IMB_imbuf.h"
00032 #include "IMB_imbuf_types.h"
00033 #include "IMB_filetype.h"
00034 
00035 #ifdef WITH_OPENEXR
00036 #include "openexr/openexr_api.h"
00037 #endif
00038 
00039 #ifdef WITH_DDS
00040 #include "dds/dds_api.h"
00041 #endif
00042 
00043 #ifdef WITH_QUICKTIME
00044 #include "quicktime_import.h"
00045 #endif
00046 
00047 #include "imbuf.h"
00048 
00049 static int imb_ftype_default(ImFileType *type, ImBuf *ibuf) { return (ibuf->ftype & type->filetype); }
00050 #if defined(__APPLE__) && defined(IMBUF_COCOA)
00051 static int imb_ftype_cocoa(ImFileType *type, ImBuf *ibuf) { return (ibuf->ftype & TIF); }
00052 #endif
00053 static int imb_ftype_iris(ImFileType *type, ImBuf *ibuf) { (void)type; return (ibuf->ftype == IMAGIC); }
00054 #ifdef WITH_QUICKTIME
00055 static int imb_ftype_quicktime(ImFileType *type, ImBuf *ibuf) { return 0; } // XXX
00056 #endif
00057 
00058 #ifdef WITH_QUICKTIME
00059 void quicktime_init(void);
00060 void quicktime_exit(void);
00061 #endif
00062 
00063 ImFileType IMB_FILE_TYPES[]= {
00064         {NULL, NULL, imb_is_a_jpeg, imb_ftype_default, imb_load_jpeg, imb_savejpeg, NULL, 0, JPG},
00065         {NULL, NULL, imb_is_a_png, imb_ftype_default, imb_loadpng, imb_savepng, NULL, 0, PNG},
00066         {NULL, NULL, imb_is_a_bmp, imb_ftype_default, imb_bmp_decode, imb_savebmp, NULL, 0, BMP},
00067         {NULL, NULL, imb_is_a_targa, imb_ftype_default, imb_loadtarga, imb_savetarga, NULL, 0, TGA},
00068         {NULL, NULL, imb_is_a_iris, imb_ftype_iris, imb_loadiris, imb_saveiris, NULL, 0, IMAGIC},
00069 #ifdef WITH_CINEON
00070         {NULL, NULL, imb_is_dpx, imb_ftype_default, imb_loaddpx, imb_save_dpx, NULL, IM_FTYPE_FLOAT, DPX},
00071         {NULL, NULL, imb_is_cineon, imb_ftype_default, imb_loadcineon, imb_savecineon, NULL, IM_FTYPE_FLOAT, CINEON},
00072 #endif
00073 #ifdef WITH_TIFF
00074         {imb_inittiff, NULL, imb_is_a_tiff, imb_ftype_default, imb_loadtiff, imb_savetiff, imb_loadtiletiff, 0, TIF},
00075 #elif defined(__APPLE__) && defined(IMBUF_COCOA)
00076         {NULL, NULL, imb_is_a_cocoa, imb_ftype_cocoa, imb_imb_cocoaLoadImage, imb_savecocoa, NULL, 0, TIF},
00077 #endif
00078 #ifdef WITH_HDR
00079         {NULL, NULL, imb_is_a_hdr, imb_ftype_default, imb_loadhdr, imb_savehdr, NULL, IM_FTYPE_FLOAT, RADHDR},
00080 #endif
00081 #ifdef WITH_OPENEXR
00082         {NULL, NULL, imb_is_a_openexr, imb_ftype_default, imb_load_openexr, imb_save_openexr, NULL, IM_FTYPE_FLOAT, OPENEXR},
00083 #endif
00084 #ifdef WITH_OPENJPEG
00085         {NULL, NULL, imb_is_a_jp2, imb_ftype_default, imb_jp2_decode, imb_savejp2, NULL, IM_FTYPE_FLOAT, JP2},
00086 #endif
00087 #ifdef WITH_DDS
00088         {NULL, NULL, imb_is_a_dds, imb_ftype_default, imb_load_dds, NULL, NULL, 0, DDS},
00089 #endif
00090 #ifdef WITH_QUICKTIME
00091         {quicktime_init, quicktime_exit, imb_is_a_quicktime, imb_ftype_quicktime, imb_quicktime_decode, NULL, NULL, 0, QUICKTIME},
00092 #endif  
00093         {NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0}};
00094         
00095 void imb_filetypes_init(void)
00096 {
00097         ImFileType *type;
00098 
00099         for(type=IMB_FILE_TYPES; type->is_a; type++)
00100                 if(type->init)
00101                         type->init();
00102 }
00103 
00104 void imb_filetypes_exit(void)
00105 {
00106         ImFileType *type;
00107 
00108         for(type=IMB_FILE_TYPES; type->is_a; type++)
00109                 if(type->exit)
00110                         type->exit();
00111 }
00112