core/vil/file_formats/vil_jpeg.h
Go to the documentation of this file.
00001 // This is core/vil/file_formats/vil_jpeg.h
00002 #ifndef vil_jpeg_file_format_h_
00003 #define vil_jpeg_file_format_h_
00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00005 #pragma interface
00006 #endif
00007 //:
00008 // \file
00009 // \author    fsm
00010 // \date 17 Feb 2000
00011 //
00012 // Adapted from geoff's code in ImageClasses/JPEGImage.*
00013 //
00014 // \verbatim
00015 //  Modifications:
00016 //  3 October 2001 Peter Vanroose - Implemented get_property("top_row_first")
00017 //     11 Oct 2002 Ian Scott - converted to vil
00018 //\endverbatim
00019 
00020 #include <vil/vil_file_format.h>
00021 #include <vil/vil_image_resource.h>
00022 
00023 // seeks to 0, then checks for magic number. returns true if found.
00024 bool vil_jpeg_file_probe(vil_stream *vs);
00025 
00026 //: Loader for JPEG files
00027 class vil_jpeg_file_format : public vil_file_format
00028 {
00029  public:
00030   virtual char const *tag() const;
00031   virtual vil_image_resource_sptr make_input_image(vil_stream *vs);
00032   virtual vil_image_resource_sptr make_output_image(vil_stream* vs,
00033                                                     unsigned nx,
00034                                                     unsigned ny,
00035                                                     unsigned nplanes,
00036                                                     enum vil_pixel_format);
00037 };
00038 
00039 //
00040 class vil_jpeg_compressor;
00041 class vil_jpeg_decompressor;
00042 
00043 //: generic_image implementation for JPEG files
00044 class vil_jpeg_image : public vil_image_resource
00045 {
00046  public:
00047   vil_jpeg_image(vil_stream *is);
00048   vil_jpeg_image (vil_stream* is, unsigned ni,
00049                   unsigned nj, unsigned nplanes, vil_pixel_format format);
00050   ~vil_jpeg_image();
00051 
00052   //: Dimensions:  planes x width x height x components
00053   virtual unsigned nplanes() const;
00054   virtual unsigned ni() const;
00055   virtual unsigned nj() const;
00056 
00057   virtual enum vil_pixel_format pixel_format() const;
00058 
00059   //: returns "jpeg"
00060   char const *file_format() const;
00061 
00062   //: Create a read/write view of a copy of this data.
00063   // \return 0 if unable to get view of correct size.
00064   virtual vil_image_view_base_sptr get_copy_view(unsigned i0, unsigned ni,
00065                                                  unsigned j0, unsigned nj) const;
00066 
00067   //: Put the data in this view back into the image source.
00068   virtual bool put_view(const vil_image_view_base& im, unsigned i0, unsigned j0);
00069 
00070   bool get_property(char const *tag, void *prop = 0) const;
00071 
00072   //: set the quality for compression
00073   void set_quality(int quality);
00074   
00075  private:
00076   vil_jpeg_compressor   *jc;
00077   vil_jpeg_decompressor *jd;
00078   vil_stream *stream;
00079   friend class vil_jpeg_file_format;
00080 };
00081 
00082 #endif // vil_jpeg_file_format_h_