/*! * \return New Woolz object. * \ingroup WlzAllocation * \brief Wrapper for WlzBuildObj3() with buffer passed as bytes. * \param cObj Given current object. * \param og Origin of rectangular buffer. * \param sz Buffer size (note 2D). * \param gType The grey type. * \param bufSz Number of values in the buffer * (ie sz.vtX * sz.vtY * sizeof(<gType>))). * \param buf Given buffer of values. * \param dstErr Destination error pointer, may be NULL. */ WlzObject *WlzBuildObj3B(WlzObject *cObj, WlzIVertex3 og, WlzIVertex2 sz, WlzGreyType gType, int bufSz, char *buf, WlzErrorNum *dstErr) { int gSz, bufPSz = 0; WlzGreyP bufP; WlzObject *nObj = NULL; WlzErrorNum errNum = WLZ_ERR_NONE; bufP.ubp = (WlzUByte *)buf; if((gSz = WlzGreySize(gType)) <= 0) { errNum = WLZ_ERR_GREY_TYPE; } else { bufPSz = bufSz / gSz; nObj = WlzBuildObj3(cObj, og, sz, gType, bufPSz, bufP, &errNum); } if(dstErr) { *dstErr = errNum; } return(nObj); }
/*! * \return New 2D Woolz object or NULL on error. * \ingroup WlzTransform * \brief Creates a new 2D Woolz object with a single line which * is the profile from the given start position to the * given end position. This function assumes that it is * given either a 2 or 3D spatial domain object and that * this object has a non-NULL domain. See WlzProfileLine(). * \param gObj Given Woolz object. * \param sPos Start position. * \param ePos End position. * \param dstErr Destination error pointer, may be NULL. */ static WlzObject *WlzProfileLnSD( WlzObject *gObj, WlzIVertex3 sPos, WlzIVertex3 ePos, WlzErrorNum *dstErr) { WlzDomain rDom = {0}; WlzValues rVal = {0}; WlzObject *rObj = NULL; WlzGreyP rPix = {0}; WlzGreyValueWSpace *gVWSp = NULL; WlzErrorNum errNum = WLZ_ERR_NONE; rDom.i = WlzProfileLineIDom(gObj, sPos, ePos, &errNum); if(errNum == WLZ_ERR_NONE) { if(gObj->values.core) { gVWSp = WlzGreyValueMakeWSp(gObj, &errNum); if(errNum == WLZ_ERR_NONE) { int len; size_t gSz; len = rDom.i->lastkl - rDom.i->kol1 +1; if((gSz = WlzGreySize(gVWSp->gType)) == 0) { errNum = WLZ_ERR_GREY_TYPE; } else if((rPix.v = AlcMalloc(len * gSz)) == NULL) { errNum = WLZ_ERR_MEM_ALLOC; } } if(errNum == WLZ_ERR_NONE) { WlzPixelV bgd; WlzObjectType tType; bgd.type = gVWSp->gType; bgd.v = gVWSp->gBkd; tType = WlzGreyValueTableType(0, WLZ_GREY_TAB_RECT, gVWSp->gType, NULL); rVal.r = WlzMakeRectValueTb(tType, rDom.i->line1, rDom.i->lastln, rDom.i->kol1, (rDom.i->lastkl - rDom.i->kol1) + 1, bgd, rPix.inp, &errNum); } } } if(errNum == WLZ_ERR_NONE) { rObj = WlzMakeMain(gObj->type, rDom, rVal, NULL, NULL, &errNum); } if(errNum == WLZ_ERR_NONE) { errNum = WlzProfileWalkValues(gObj, rObj, gVWSp, sPos, ePos, &errNum); } if(errNum != WLZ_ERR_NONE) { if(rObj) { (void )WlzFreeObj(rObj); rObj = NULL; } else { if(rVal.core) { (void )WlzFreeDomain(rDom); (void )WlzFreeValues(rVal); } else { AlcFree(rPix.v); } } } if(dstErr) { *dstErr = errNum; } return(rObj); }