📄 resize.cpp
字号:
/* //////////////////////////////////////////////////////////////////////////// INTEL CORPORATION PROPRIETARY INFORMATION// This software is supplied under the terms of a license agreement or// nondisclosure agreement with Intel Corporation and may not be copied// or disclosed except in accordance with the terms of that agreement.// Copyright(c) 2004-2005 Intel Corporation. All Rights Reserved.//////*/#ifndef XSCALE#include "resize.h"#include "pp.h"#include "image.h"#include "imageconvert.h"void Resize( const ImageCoreC<Ipp32s, 1> &src, const RectSize &srcSize, const ImageCoreC<Ipp32s, 1> &dst, const RectSize &dstSize){ if(srcSize == dstSize) { Copy(src, dst, srcSize); return; } // it uses 32f primitive ImageC<Ipp32f, 1> tmpSrc(srcSize); ImageC<Ipp32f, 1> tmpDst(dstSize); Convert(src, tmpSrc, srcSize); Resize(tmpSrc, srcSize, tmpDst, dstSize); Convert(tmpDst, dst, dstSize);}void ResizeUp( const ImageCoreC<Ipp32f, 1> &src, const RectSize &srcSize, const RectSize &srcSampleSize, const ImageCoreC<Ipp32f, 1> &dst, const Rect &dstRefRect){ if((srcSampleSize == RectSize(1,1)) && (dstRefRect.Size() == srcSize)) { Copy(src, dst, srcSize); return; } // to avoid black fields when sample phase shift is used during resizing // it's required to build 1 point borders around source image ImageC<Ipp32f, 1> tmpSrc(srcSize + RectSize(1,1)); CopyReplicateBorder((const ImageCoreC<Ipp32s, 1> &)src, srcSize, (const ImageCoreC<Ipp32s, 1> &)tmpSrc, tmpSrc.Size(), Point(1,1)); double xShift = - (double) (dstRefRect.Origin().X() % srcSampleSize.Width()); double yShift = - (double) (dstRefRect.Origin().Y() % srcSampleSize.Height()); double xCenter = 0.5 * (double)tmpSrc.Size().Width() + xShift / (double)srcSampleSize.Width(); double yCenter = 0.5 * (double)tmpSrc.Size().Height() + yShift / (double)srcSampleSize.Height(); ResizeCenter(tmpSrc, tmpSrc.Size(), dst, dstRefRect.Size(), (double)srcSampleSize.Width(), (double)srcSampleSize.Height(), xCenter, yCenter);}void ResizeUp( const ImageCoreC<Ipp32s, 1> &src, const RectSize &srcSize, const RectSize &srcSampleSize, const ImageCoreC<Ipp32s, 1> &dst, const Rect &dstRefRect){ if((srcSampleSize == RectSize(1,1)) && (dstRefRect.Size() == srcSize)) { Copy(src, dst, srcSize); return; } // it uses 32f primitive ImageC<Ipp32f, 1> tmpSrc(srcSize); ImageC<Ipp32f, 1> tmpDst(dstRefRect.Size()); Convert(src, tmpSrc, srcSize); ResizeUp(tmpSrc, srcSize, srcSampleSize, tmpDst, dstRefRect); Convert(tmpDst, dst, dstRefRect.Size());}void ResizeDown( const ImageCoreC<Ipp32f, 1> &src, const Rect &srcRefRect, const ImageCoreC<Ipp32f, 1> &dst, const RectSize &dstSize, const RectSize &dstSampleSize){ if((dstSampleSize == RectSize(1,1)) && (srcRefRect.Size() == dstSize)) { Copy(src, dst, srcRefRect.Size()); return; } // to avoid black fields when sample phase shift is used during resizing // it's required to build 1 point borders around source image ImageC<Ipp32f, 1> tmpSrc(srcRefRect.Size() + RectSize(1,1)); CopyReplicateBorder((const ImageCoreC<Ipp32s, 1> &)src, srcRefRect.Size(), (const ImageCoreC<Ipp32s, 1> &)tmpSrc, tmpSrc.Size(), Point(1,1)); double xFactor = 1.0/(double)dstSampleSize.Width(); double yFactor = 1.0/(double)dstSampleSize.Height(); double xShift = - xFactor * (double) (srcRefRect.Origin().X() % dstSampleSize.Width()); double yShift = - yFactor * (double) (srcRefRect.Origin().Y() % dstSampleSize.Height()); double xCenter = xFactor * (0.5 * (double)dstSize.Width() + xShift / (double)dstSampleSize.Width()); double yCenter = yFactor * (0.5 * (double)dstSize.Height() + yShift / (double)dstSampleSize.Height()); ResizeCenter(tmpSrc, tmpSrc.Size(), dst, dstSize, xFactor, yFactor, xCenter, yCenter);}void ResizeDown( const ImageCoreC<Ipp32s, 1> &src, const Rect &srcRefRect, const ImageCoreC<Ipp32s, 1> &dst, const RectSize &dstSize, const RectSize &dstSampleSize){ if((dstSampleSize == RectSize(1,1)) && (srcRefRect.Size() == dstSize)) { Copy(src, dst, srcRefRect.Size()); return; } // it uses 32f primitive ImageC<Ipp32f, 1> tmpSrc(srcRefRect.Size()); ImageC<Ipp32f, 1> tmpDst(dstSize); Convert(src, tmpSrc, tmpSrc.Size()); ResizeDown(tmpSrc, srcRefRect, tmpDst, dstSize, dstSampleSize); Convert(tmpDst, dst, dstSize);}#endif //#ifndef XSCALE
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -