$search
00001 #include "EdgeDetection/MemoryImage.h" 00002 00003 namespace EdgeDetection 00004 { 00005 Image* RedByteGreenByteBlueByteMemoryImage::GetRegion(int left, int right, int top, int bottom) 00006 { 00007 if (left < 0 || left >= GetWidth()) throw "The parameter 'left' was out of range."; 00008 if (right < 0 || right >= GetWidth()) throw "The parameter 'right' was out of range."; 00009 if (top < 0 || top >= GetHeight()) throw "The parameter 'top' was out of range."; 00010 if (bottom < 0 || bottom >= GetHeight()) throw "The parameter 'bottom' was out of range."; 00011 if (right - left < 0) throw "The parameters 'left' and 'right' were out of range."; 00012 if (bottom - top < 0) throw "The parameters 'top' and 'bottom' were out of range."; 00013 00014 return new RedByteGreenByteBlueByteMemoryImage(right - left, bottom - top, ((unsigned char*)GetData()) + left * 3 + top * GetStride(), GetStride()); 00015 } 00016 Image* GrayDoubleMemoryImage::GetRegion(int left, int right, int top, int bottom) 00017 { 00018 if (left < 0 || left >= GetWidth()) throw "The parameter 'left' was out of range."; 00019 if (right < 0 || right >= GetWidth()) throw "The parameter 'right' was out of range."; 00020 if (top < 0 || top >= GetHeight()) throw "The parameter 'top' was out of range."; 00021 if (bottom < 0 || bottom >= GetHeight()) throw "The parameter 'bottom' was out of range."; 00022 if (right - left < 0) throw "The parameters 'left' and 'right' were out of range."; 00023 if (bottom - top < 0) throw "The parameters 'top' and 'bottom' were out of range."; 00024 00025 return new GrayDoubleMemoryImage(right - left, bottom - top, ((double*)GetData()) + left * 1 + top * GetStride(), GetStride()); 00026 } 00027 };