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.h> 00019 00020 00021 void 00022 image::copy(const image::pointer &src) 00023 { 00024 copy(src, 0, 0); 00025 } 00026 00027 00028 void 00029 image::copy(const image::pointer &src, int ox, int oy) 00030 { 00031 int dx = src->get_width(); 00032 int dy = src->get_height(); 00033 if (ox < 0) 00034 { 00035 dx += ox; 00036 ox = 0; 00037 } 00038 if (oy < 0) 00039 { 00040 dy += oy; 00041 oy = 0; 00042 } 00043 if (ox + dx > (int)get_width()) 00044 dx = get_width() - ox; 00045 if (dx <= 0) 00046 return; 00047 if (oy + dy > (int)get_height()) 00048 dy = get_height() - oy; 00049 if (dy <= 0) 00050 return; 00051 for (int y = 0; y < dy; ++y) 00052 { 00053 for (int x = 0; x < dx; ++x) 00054 { 00055 icon_pixel value; 00056 src->get_pixel(x, y, value); 00057 set_pixel(x + ox, y + oy, value); 00058 } 00059 } 00060 }