Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

# Representations/Perception/JPEGImage.h

Go to the documentation of this file.

    00001 /**
    00002  * @file JPEGImage.h
    00003  *
    00004  * Declaration of class JPEGImage
    00005  */
    00006
    00007 #ifndef __JPEGImage_h_
    00008 #define __JPEGImage_h_
    00009
    00010 #include "Image.h"
    00011 #include <stdio.h>
    00012
    00013 // INT32 and FAR conflict with any other header files...
    00014 #define INT32 _INT32
    00015 #undef FAR
    00016 #include "Tools/JPEGlib/jpeglib.h"
    00017 #undef INT32
    00018 #undef FAR
    00019
    00020 class JPEGImage;
    00021
    00022 /**
    00023  * Streaming operator that writes a JPEGImage to a stream.
    00024  * @param stream The stream to write on.
    00025  * @param image The JPEGImage object.
    00026  * @return The stream.
    00027  */
    00028 Out& operator<<(Out& stream,const JPEGImage& image);
    00029
    00030 /**
    00031  * Streaming operator that reads a JPEGImage from a stream.
    00032  * @param stream The stream to read from.
    00033  * @param image The JPEGImage object.
    00034  * @return The stream.
    00035  */
    00036 In& operator>>(In& stream,JPEGImage& image);
    00037
    00038 /**
    00039  * Definition of a class for JPEG-compressed images.
    00040  */
    00041 class JPEGImage : public Image
    00042 {
    00043   private:
    00044     /**
    00045      * The class is required during JPEG-compression to access
    00046      * the main JPEGImage object from library handlers.
    00047      */
    00048     class DestDescriptor : public jpeg_destination_mgr
    00049     {
    00050       public:
    00051         JPEGImage* theObject; /**< A pointer to the JPEGImage object. */
    00052     };
    00053
    00054     unsigned size; /**< The size of the JPEG image. */
    00055
    00056     //!@name Handlers for JPEG-compression
    00057     //!@{
    00058     static void onDestInit(j_compress_ptr cInfo);
    00059     static int onDestEmpty(j_compress_ptr);
    00060     static void onDestTerm(j_compress_ptr cInfo);
    00061
    00062     static void onSrcSkip(j_decompress_ptr cInfo,long numBytes);
    00063     static int onSrcEmpty(j_decompress_ptr);
    00064     static void onSrcIgnore(j_decompress_ptr);
    00065     //!@}
    00066
    00067   public:
    00068     /**
    00069      * Empty constructor.
    00070      */
    00071     JPEGImage() {size = 0;}
    00072
    00073     /**
    00074      * Constructs a JPEG image from an image.
    00075      * @param src The image used as template.
    00076      */
    00077     JPEGImage(const Image& src);
    00078
    00079     /**
    00080      * Assignment operator.
    00081      * @param src The image used as template.
    00082      * @return The resulting JPEG image.
    00083      */
    00084     JPEGImage& operator=(const Image& src);
    00085
    00086     /**
    00087      * Uncompress image.
    00088      * @param dest Will receive the uncompressed image.
    00089      */
    00090     void toImage(Image& dest) const;
    00091
    00092   friend Out& operator<<(Out& stream,const JPEGImage& image);
    00093   friend In& operator>>(In& stream,JPEGImage& image);
    00094 };
    00095
    00096 #endif //__JPEGImage_h_