Canola
0.8.D001
|
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 #include <lib/image/invert.h> 00019 00020 00021 image_invert::~image_invert() 00022 { 00023 } 00024 00025 00026 image_invert::image_invert(const image::pointer &a_deeper) : 00027 deeper(a_deeper) 00028 { 00029 } 00030 00031 00032 image_invert::pointer 00033 image_invert::create(const image::pointer &a_deeper) 00034 { 00035 return pointer(new image_invert(a_deeper)); 00036 } 00037 00038 00039 const char * 00040 image_invert::type_name(void) 00041 const 00042 { 00043 return deeper->type_name(); 00044 } 00045 00046 00047 void 00048 image_invert::get_pixel(int x, int y, icon_pixel &result) 00049 const 00050 { 00051 icon_pixel tmp; 00052 deeper->get_pixel(x, y, tmp); 00053 result = 00054 icon_pixel 00055 ( 00056 1. - tmp.get_red(), 00057 1. - tmp.get_green(), 00058 1. - tmp.get_blue(), 00059 tmp.get_alpha() 00060 ); 00061 } 00062 00063 00064 void 00065 image_invert::set_pixel(int x, int y, const icon_pixel &value) 00066 { 00067 icon_pixel 00068 tmp 00069 ( 00070 1. - value.get_red(), 00071 1. - value.get_green(), 00072 1. - value.get_blue(), 00073 value.get_alpha() 00074 ); 00075 deeper->set_pixel(x, y, tmp); 00076 } 00077 00078 00079 unsigned 00080 image_invert::get_width(void) 00081 const 00082 { 00083 return deeper->get_width(); 00084 } 00085 00086 00087 unsigned 00088 image_invert::get_height(void) 00089 const 00090 { 00091 return deeper->get_height(); 00092 } 00093 00094 00095 void 00096 image_invert::save_to_file(const std::string &filename) 00097 const 00098 { 00099 deeper->save_to_file(filename); 00100 }