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/threshold.h> 00019 00020 00021 image_threshold::~image_threshold() 00022 { 00023 } 00024 00025 00026 image_threshold::image_threshold( 00027 const image::pointer &a_deeper, 00028 double a_level 00029 ) : 00030 deeper(a_deeper), 00031 level(a_level) 00032 { 00033 } 00034 00035 00036 image_threshold::pointer 00037 image_threshold::create(const image::pointer &a_deeper, double a_level) 00038 { 00039 return pointer(new image_threshold(a_deeper, a_level)); 00040 } 00041 00042 00043 unsigned 00044 image_threshold::get_width(void) 00045 const 00046 { 00047 return deeper->get_width(); 00048 } 00049 00050 00051 unsigned 00052 image_threshold::get_height(void) 00053 const 00054 { 00055 return deeper->get_height(); 00056 } 00057 00058 00059 void 00060 image_threshold::save_to_file(const std::string &filename) 00061 const 00062 { 00063 deeper->save_to_file(filename); 00064 } 00065 00066 00067 const char * 00068 image_threshold::type_name(void) 00069 const 00070 { 00071 return deeper->type_name(); 00072 } 00073 00074 00075 void 00076 image_threshold::get_pixel(int x, int y, icon_pixel &p) 00077 const 00078 { 00079 icon_pixel p2; 00080 deeper->get_pixel(x, y, p2); 00081 if (p2.get_intensity() >= level) 00082 p = icon_pixel(1., 1., 1., p2.get_alpha()); 00083 else 00084 p = icon_pixel(0., 0., 0., p2.get_alpha()); 00085 } 00086 00087 00088 void 00089 image_threshold::set_pixel(int x, int y, const icon_pixel &p) 00090 { 00091 deeper->set_pixel(x, y, p); 00092 }