本文整理汇总了C++中FlexImage::Reallocate方法的典型用法代码示例。如果您正苦于以下问题:C++ FlexImage::Reallocate方法的具体用法?C++ FlexImage::Reallocate怎么用?C++ FlexImage::Reallocate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FlexImage
的用法示例。
在下文中一共展示了FlexImage::Reallocate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FlexLoadBMPColor
bool FlexLoadBMPColor(const char *file, FlexImage<Im8u,3> &img)
{
FILE *in;
BITMAPFILEHDR bmfh;
BITMAPINFOHDR bmih;
in=fopen(file,"rb");
if (in == NULL)
return(false);
//WARNING: Extra padding in bmfh causes erroneous reading into all but first field of structure
fread(&bmfh,BFHSIZE,1,in); //read BMP header
ConvertBmfh(&bmfh);
if (bmfh.bfType != 19778) //check for valid BMP file
return(false);
fread(&bmih,BIHSIZE,1,in); //read info header
ConvertBmih(&bmih);
if (bmih.biBitCount != 24)
return(false); //only read 8 bit images
img.Reallocate(bmih.biWidth, abs(bmih.biHeight)); //allocate image to size
RGBA tmp;
for(int i = 0; i < (int)bmih.biClrUsed; i++) //skip color info
fread(&tmp, sizeof(RGBA), 1, in);
int padWidth = 3 * bmih.biWidth;
while(padWidth%4) padWidth++;
int dir = 1, yv = 0;
if (bmih.biHeight > 0)
{ dir = -1;
yv = img.Height() - 1;
}
for(int y = 0; y < img.Height(); y++ ) //read in pixel data
{ char tmp;
fread(&img(0,yv), 1, img.Width() * 3, in);
yv += dir;
for(int i = 0; i < padWidth - img.Width() * 3; i++) //skip over pad bytes
fread(&tmp, 1, 1, in);
}
fclose(in);
return(true);
}
示例2: FlexFilterRowVOMP
bool FlexFilterRowVOMP(FlexImage<T,1> &src, FlexImage<T,1> &dst, T2 *kernel, int kernelSize, bool allocate = true)
{
if(kernelSize % 2 == 0) //enforce odd length kernels
return false;
if(allocate)
dst.Reallocate(src.Size());
dst.Set((T)0);
int n = kernelSize / 2, h = src.Height();
#pragma omp parallel for
for(int y = 0; y < h; y++)
{ T *psrc = &src(n, y), *pdst = &dst(n, y);
for(int x = n; x < src.Width() - n; x++)
{ int k = 0;
T2 acc = 0;
for(int i = -n; i <= n; i++)
acc += (T2)(psrc[i] * kernel[k++]);
*pdst = (T)acc;
pdst++;
psrc++;
}
}
return true;
}
示例3: FlexFilterColumnVOMP
bool FlexFilterColumnVOMP(FlexImage<T,1> &src, FlexImage<T,1> &dst, T2 *kernel, int kernelSize, bool allocate = true)
{
if(kernelSize % 2 == 0) //enforce odd length kernels
return false;
if(allocate)
dst.Reallocate(src.Size());
dst.Set((T)0);
int n = kernelSize / 2;
int sb = src.StepBytes(), h = src.Height() - n;
#pragma omp parallel for
for(int y = n; y < h; y++)
{ T *psrc = &src(0, y), *pdst = &dst(0, y);
for(int x = 0; x < src.Width(); x++)
{ int k = 0;
T2 acc = 0;
for(int i = -n; i <= n; i++)
acc += (T2)(*(T *)((char *)psrc + sb * i) * kernel[k++]);
*pdst = (T)acc;
pdst++;
psrc++;
}
}
return true;
}