#include "HxImageRep.h"
Go to the source code of this file.
Functions | |
HxImageRep L_HXIMAGEREP | HxExtendVal (HxImageRep img, HxSizes newSize, HxValue background, HxPoint begin) |
Extension of domain. More... |
|
Extension of domain. Extend the domain of the image to the given size. The image is put at the position indicated by begin. Points are treated as pixel coordinates (integers).
00014 { 00015 HxString fname("HxExtendVal"); 00016 00017 if (img.isNull()) 00018 { 00019 HxGlobalError::instance()->reportError(fname, img.name(), "null image", HxGlobalError::HX_GE_INVALID); 00020 return HxImageRep(); 00021 } 00022 00023 if (img.pixelDimensionality() == 2) 00024 { 00025 if ((background.tag() != HxValue::V2I) && (background.tag() != HxValue::V2D)) 00026 { 00027 HxGlobalError::instance()->reportError(fname, "value dimensionality is not equal to pixel dimensionalities", HxGlobalError::HX_GE_UNEQUAL_IMAGES); 00028 return HxImageRep(); 00029 } 00030 } 00031 if (img.pixelDimensionality() == 3) 00032 { 00033 if ((background.tag() != HxValue::V3I) && (background.tag() != HxValue::V3D)) 00034 { 00035 HxGlobalError::instance()->reportError(fname, "value dimensionality is not equal to pixel dimensionalities", HxGlobalError::HX_GE_UNEQUAL_IMAGES); 00036 return HxImageRep(); 00037 } 00038 } 00039 00040 if (begin.x() < 0) 00041 { 00042 HxGlobalError::instance()->reportError(fname, "begin.x less then 0", HxGlobalError::HX_GE_INVALID); 00043 return HxImageRep(); 00044 } 00045 if (begin.y() < 0) 00046 { 00047 HxGlobalError::instance()->reportError(fname, "begin.y less then 0", HxGlobalError::HX_GE_INVALID); 00048 return HxImageRep(); 00049 } 00050 if (begin.z() < 0) 00051 { 00052 HxGlobalError::instance()->reportError(fname, "begin.z less then 0", HxGlobalError::HX_GE_INVALID); 00053 return HxImageRep(); 00054 } 00055 if ((begin.x() + img.sizes().x()) > newSize.x()) 00056 { 00057 HxGlobalError::instance()->reportError(fname, "x size of extend too large", HxGlobalError::HX_GE_INVALID); 00058 return HxImageRep(); 00059 } 00060 if ((begin.y() + img.sizes().y()) > newSize.y()) 00061 { 00062 HxGlobalError::instance()->reportError(fname, "y size of extend too large", HxGlobalError::HX_GE_INVALID); 00063 return HxImageRep(); 00064 } 00065 if ((begin.z() + img.sizes().z()) > newSize.z()) 00066 { 00067 HxGlobalError::instance()->reportError(fname, "z size of extend too large", HxGlobalError::HX_GE_INVALID); 00068 return HxImageRep(); 00069 } 00070 00071 00072 return img.extend(newSize, background, begin); 00073 } |