1 //
2 // C++ Interface: pictureLoader
3 //
4 // Description:
5 //
6 //
7 // Author: Yorn <yorn@gmx.net>, (C) 2009
8 //
9 // Copyright: See COPYING file that comes with this distribution
10 //
11 //
12 #ifndef PICTURELOADER_H
13 #define PICTURELOADER_H
14 
15 #include <string>
16 
17 #include "rgbPlane.h"
18 
19 #ifdef WITH_GD2LIB
20 #include <gd.h>
21 #endif
22 
23 #ifdef HAVE_LIBTHEORAENC
24 #include <theora/codec.h>
25 #endif
26 
27 /**
28 	@author Yorn <yorn@gmx.net>
29 */
30 class PictureLoader {
31 
32 protected:
33   enum SuffixType {
34     suffix_unknown,
35     suffix_jpg,
36     suffix_png,
37     suffix_gif
38   };
39 
40 #ifdef WITH_GD2LIB
41   static RGBPlane convertToRgbPlane(gdImagePtr im);
42   static SuffixType identifySuffix(const std::string& filename);
43 #endif
44 
45 public:
46 
47   PictureLoader();
48 
49   virtual ~PictureLoader();
50 
51 #ifdef WITH_GD2LIB
52   static bool load(RGBPlane& retPlane, const std::string& filename, uint32 width=0, uint32 height=0, bool useBiggest = true);
53   static bool save(RGBPlane& pic, const std::string& filename, uint32 width=0, uint32 height=0);
54 #endif
55 
56 #ifdef HAVE_LIBTHEORAENC
57   static void exportYCrCb_theora(RGBPlane& plane, th_ycbcr_buffer& buffer, int pixel_format=TH_PF_420);
58   static void exportYCrCb_444_theora(RGBPlane& picture, th_ycbcr_buffer& buffer);
59 
60   static RGBPlane importYCrCb_theora(const th_ycbcr_buffer& buffer, uint32 width, uint32 height, uint32 XOffset=0, uint32 YOffset=0, int pixel_format=TH_PF_420);
61 #endif
62 
63 
64 };
65 
66 #endif
67