#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::SI) && (background.tag() != HxValue::SD) && 00026 (background.tag() != HxValue::V2I) && (background.tag() != HxValue::V2D)) 00027 { 00028 HxGlobalError::instance()->reportError(fname, "value dimensionality is not equal to pixel dimensionalities", HxGlobalError::HX_GE_UNEQUAL_IMAGES); 00029 return HxImageRep(); 00030 } 00031 } 00032 if (img.pixelDimensionality() == 3) 00033 { 00034 if ((background.tag() != HxValue::SI) && (background.tag() != HxValue::SD) && 00035 (background.tag() != HxValue::V3I) && (background.tag() != HxValue::V3D)) 00036 { 00037 HxGlobalError::instance()->reportError(fname, "value dimensionality is not equal to pixel dimensionalities", HxGlobalError::HX_GE_UNEQUAL_IMAGES); 00038 return HxImageRep(); 00039 } 00040 } 00041 00042 if (begin.x() < 0) 00043 { 00044 HxGlobalError::instance()->reportError(fname, "begin.x less then 0", HxGlobalError::HX_GE_INVALID); 00045 return HxImageRep(); 00046 } 00047 if (begin.y() < 0) 00048 { 00049 HxGlobalError::instance()->reportError(fname, "begin.y less then 0", HxGlobalError::HX_GE_INVALID); 00050 return HxImageRep(); 00051 } 00052 if (begin.z() < 0) 00053 { 00054 HxGlobalError::instance()->reportError(fname, "begin.z less then 0", HxGlobalError::HX_GE_INVALID); 00055 return HxImageRep(); 00056 } 00057 if ((begin.x() + img.sizes().x()) > newSize.x()) 00058 { 00059 HxGlobalError::instance()->reportError(fname, "x size of extend too large", HxGlobalError::HX_GE_INVALID); 00060 return HxImageRep(); 00061 } 00062 if ((begin.y() + img.sizes().y()) > newSize.y()) 00063 { 00064 HxGlobalError::instance()->reportError(fname, "y size of extend too large", HxGlobalError::HX_GE_INVALID); 00065 return HxImageRep(); 00066 } 00067 if ((begin.z() + img.sizes().z()) > newSize.z()) 00068 { 00069 HxGlobalError::instance()->reportError(fname, "z size of extend too large", HxGlobalError::HX_GE_INVALID); 00070 return HxImageRep(); 00071 } 00072 00073 00074 return img.extend(newSize, background, begin); 00075 } |