Blender V2.61 - r43446

filetype.c

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