Canola  0.8.D001
lib/image/format.h
Go to the documentation of this file.
00001 //
00002 // canola - canon canola 1614p emulator
00003 // Copyright (C) 2011 Peter Miller
00004 //
00005 // This program is free software; you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License, version 3, as
00007 // published by the Free Software Foundation.
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 GNU
00012 // General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License along
00015 // with this program. If not, see <http://www.gnu.org/licenses/>.
00016 //
00017 
00018 #ifndef LIB_IMAGE_FORMAT_H
00019 #define LIB_IMAGE_FORMAT_H
00020 
00021 #include <lib/image.h>
00022 
00027 class image_format:
00028     public image
00029 {
00030 public:
00034     virtual ~image_format();
00035 
00036 protected:
00037     // See base class for documentation.
00038     void get_pixel(int x, int y, icon_pixel &value) const;
00039 
00040     // See base class for documentation.
00041     void set_pixel(int x, int y, const icon_pixel &value);
00042 
00043     // See base class for documentation.
00044     unsigned get_width() const;
00045 
00046     // See base class for documentation.
00047     unsigned get_height() const;
00048 
00049     typedef unsigned char data_t;
00050 
00051     const data_t *get_data() const;
00052 
00053     const data_t *
00054     get_data(int y)
00055         const
00056     {
00057         return (data + 4 * width * y);
00058     }
00059 
00060     const data_t *
00061     get_data(int x, int y)
00062         const
00063     {
00064         return (data + 4 * (width * y + x));
00065     }
00066 
00074     virtual void save_to_file(const std::string &filename) const;
00075 
00086     image_format(int width, int height, data_t *data);
00087 
00098     image_format(int width, int height);
00099 
00100 private:
00101     unsigned width;
00102     unsigned height;
00103     data_t *data;
00104 
00108     image_format();
00109 
00113     image_format(const image_format &);
00114 
00118     image_format &operator=(const image_format &);
00119 };
00120 
00121 #endif // LIB_IMAGE_FORMAT_H