core/vil1/file_formats/vil1_gif.h

Go to the documentation of this file.
00001 // This is core/vil1/file_formats/vil1_gif.h
00002 #ifndef vil1_gif_h_
00003 #define vil1_gif_h_
00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00005 #pragma interface
00006 #endif
00007 //:
00008 // \file
00009 // \author  fsm
00010 //
00011 // This is an ad hoc hack. If you write a better one, you are most
00012 // welcome to replace mine with yours.
00013 //
00014 //\verbatim
00015 //  Modifications
00016 //  3 October 2001 Peter Vanroose - Implemented get_property("top_row_first")
00017 //\endverbatim
00018 
00019 class vil1_stream;
00020 #include <vcl_vector.h>
00021 #include <vil1/vil1_file_format.h>
00022 #include <vil1/vil1_image_impl.h>
00023 #include <vil1/vil1_image.h>
00024 
00025 bool vil1_gif_probe(vil1_stream *s);
00026 
00027 struct vil1_gif_file_format : public vil1_file_format
00028 {
00029   virtual char const* tag() const;
00030   virtual vil1_image_impl *make_input_image(vil1_stream* vs);
00031   virtual vil1_image_impl *make_output_image(vil1_stream*, int, int, int, int, int, vil1_component_format);
00032 };
00033 
00034 struct vil1_gif_color_map
00035 {
00036   int size;
00037   char *cmap;
00038   vil1_gif_color_map(int sz) : size(sz), cmap(new char [3*size]) { }
00039   ~vil1_gif_color_map() { delete [] cmap; cmap = 0; }
00040 };
00041 
00042 struct vil1_gif_image_record
00043 {
00044   int offset;
00045   int x0, y0;
00046   int w, h;
00047   vil1_gif_color_map *color_map;
00048   bool interlaced;
00049   int bits_per_pixel;
00050   int bitmap_start;
00051 };
00052 
00053 struct vil1_gif_loader_saver : public vil1_image_impl
00054 {
00055   vil1_gif_loader_saver(vil1_stream *);
00056 #if 0
00057   vil1_gif_loader_saver(vil1_stream *is,
00058                         int planes,
00059                         int width,
00060                         int height,
00061                         int components,
00062                         int bits_per_component,
00063                         vil1_component_format format);
00064 #endif
00065   ~vil1_gif_loader_saver();
00066 
00067   int planes() const { return images.size(); }
00068   int width() const { return screen_width_; }
00069   int height() const { return screen_height_; }
00070   int components() const { return is_grey ? 1 : 3; }
00071   int bits_per_component() const { return 8; }
00072   enum vil1_component_format component_format() const { return VIL1_COMPONENT_FORMAT_UNSIGNED_INT; }
00073 
00074   vil1_image get_plane(unsigned int p) const;
00075   bool get_section(void *buf, int x0, int y0, int width, int height) const;
00076   bool get_section(int image, void *buf, int x0, int y0, int width, int height) const;
00077   bool put_section(void const *, int, int, int, int);
00078   bool put_section(int, void const *, int, int, int, int) { return false; }
00079 
00080   char const *file_format() const;
00081   bool get_property(char const *tag, void *prop = 0) const;
00082 
00083  private:
00084   vil1_stream *s;
00085   int screen_width_;
00086   int screen_height_;
00087   bool is_grey; // set to true if all entries in the colour map are grey
00088 
00089   vil1_gif_color_map *global_color_map;
00090   int background_index;
00091 
00092   vcl_vector<void*> images;
00093 };
00094 
00095 struct vil1_gif_loader_saver_proxy : public vil1_image_impl
00096 {
00097   int image;
00098   vil1_gif_loader_saver *other;
00099   vil1_image up_ref_is_private;
00100 
00101   vil1_gif_loader_saver_proxy(int image_, vil1_gif_loader_saver *other_)
00102     : image(image_), other(other_) {
00103     // why doesn't this work?
00104     //up_ref_is_private(other);
00105   }
00106 
00107   ~vil1_gif_loader_saver_proxy() { }
00108 
00109   int planes() const { return 1; }
00110   int width() const { return other->width(); }
00111   int height() const { return other->height(); }
00112   int components() const { return other->components(); }
00113   int bits_per_component() const { return other->bits_per_component(); }
00114 
00115   enum vil1_component_format component_format() const { return other->component_format(); }
00116 
00117   bool get_section(void *buf, int x0, int y0, int w, int h) const
00118   { return other->get_section(image, buf, x0, y0, w, h); }
00119 
00120   bool put_section(void const *buf, int x0, int y0, int w, int h)
00121   { return other->put_section(image, buf, x0, y0, w, h); }
00122 
00123   char const *file_format() const { return other->file_format(); }
00124 };
00125 
00126 #endif // vil1_gif_h_

Generated on Sat Nov 22 05:08:28 2008 for core/vil1 by  doxygen 1.5.1