//----------------------------------------------------------------------------- //ImageOperIPP::resizeImage PUBLIC // //DESC: Resize an input image by factorX and factorY // //PARAMETERS: // pImageIn: pointer to input 1D image // nRows: number rows input image // nCols: number columns input image // factorX: factor to reduce columns // factorY: factor to reduce rows // pImageOut: pointer to output 1D image // nRowsOut: number rows output image // nColsOut: number columns output image // //RETVAL: Error Codes ; 0 no error, otherwise error // //----------------------------------------------------------------------------- int ImageOperIPP::resizeImage ( BYTE *pImageIn, int nRows, int nCols, double factorX, double factorY, BYTE *pImageOut, int nRowsOut, int nColsOut) { int errCode = 0; try { //Verify that images have been allocated if (pImageIn==NULL || pImageOut == NULL) throw (int) 0xFFFF; //Create intel IPP images ppType type = pp8u; CIppiImage* pImageIPP = new CIppiImage(); BOOL rtn1 = pImageIPP->CreateImage(nCols, nRows,1,type,false); Ipp8u* ptrImageIPP= (Ipp8u*)pImageIPP->DataPtr(); CIppiImage* pImageOutIPP = new CIppiImage(); BOOL rtn2 = pImageOutIPP->CreateImage(nCols, nRows,1,type,false); if (!rtn1 || ! rtn2) { pImageIPP->Reset(); pImageOutIPP->Reset(); delete pImageIPP; delete pImageOutIPP; throw (int) 0xFFFF; } //Copy input 1D image row by row //first get number of pixels per scanline int realColsPix = pImageIPP->StepPix(); //pixels per scanline BYTE* ptrAux = pImageIn; for (int i = 0; i < nRows; i++) { memcpy(ptrImageIPP, ptrAux, cast_to_size_t(nCols) * sizeof(pImageIn[0])); ptrImageIPP += realColsPix; ptrAux += nCols; } //Resize input image IppiRect srcRoi = {1,1,nCols, nRows}; IppiSize dstRoiSize = {nColsOut, nRowsOut}; IppStatus result = ippStsNoErr; #ifndef WIN64 result = ippiResize_8u_C1R((Ipp8u*)pImageIPP->DataPtr(), pImageIPP->Size(), pImageIPP->Step(), srcRoi, (Ipp8u*)pImageOutIPP->DataPtr(), pImageOutIPP->Step(), dstRoiSize, factorX, factorY, IPPI_INTER_NN); #else #pragma message ( "64bit API calls are not supported, need to revisit." __FILE__ ) #endif if (result != ippStsNoErr) { errCode = 0xFFFF; } else { //Copy resized image to output 1D image Ipp8u* ptrImageOutIPP= (Ipp8u*)pImageOutIPP->DataPtr(); int realColsOutPix = pImageOutIPP->StepPix(); //pixels per scanline BYTE* ptrAux = pImageOut; for (int i = 0; i < nRowsOut; i++ ) { memcpy(ptrAux, ptrImageOutIPP, cast_to_size_t(nColsOut)*sizeof(pImageOut[0])); ptrAux += nColsOut; ptrImageOutIPP += realColsOutPix; } } //Reset created images pImageIPP->Reset(); pImageOutIPP->Reset(); delete pImageIPP; delete pImageOutIPP; } //end try catch(int error) { errCode = error; } catch(...) { assert(0); errCode = VERR_OS_RUN_TIME; } return errCode; }