// create image and load external data imgSrc = vgCreateImage(VG_lRGBA_8888, imgGirlAlphaWidth, imgGirlAlphaHeight, VG_IMAGE_QUALITY_NONANTIALIASED); vgImageSubData(imgSrc, (const void *)imgGirlAlphaData, imgGirlAlphaDataStride, imgGirlAlphaFormat, 0, 0, imgGirlAlphaWidth, imgGirlAlphaHeight); imgDst = vgCreateImage(VG_lRGBA_8888, imgGirlAlphaWidth, imgGirlAlphaHeight, VG_IMAGE_QUALITY_NONANTIALIASED); // create a 3x3 kernel matrix kernelX[0] = 1; kernelX[1] = 1; kernelX[2] = -1; kernelY[0] = -2; kernelY[1] = 2; kernelY[2] = 2; // set channel masks and a border color vgSeti(VG_FILTER_CHANNEL_MASK, VG_RED | VG_GREEN | VG_BLUE | VG_ALPHA); col[0] = 0.12f; col[1] = 0.35f; col[2] = 0.75f; col[3] = 1.0f; vgSetfv(VG_TILE_FILL_COLOR, 4, col); vgSeti(VG_FILTER_FORMAT_LINEAR, VG_TRUE); vgSeti(VG_FILTER_FORMAT_PREMULTIPLIED, VG_FALSE); // basic centered convolve filter vgSeparableConvolve(imgDst, imgSrc, 3, 3, 1, 1, kernelX, kernelY, 1.0f / 2.0f, 0.2f, VG_TILE_FILL); vgGetImageSubData(imgDst, imgOutputDataRGBA, imgGirlAlphaDataStride, imgGirlAlphaFormat, 0, 0, imgGirlAlphaWidth, imgGirlAlphaHeight); strcpy(imgFileName, "filter_separable_convolve.png"); saveImage32(f, imgFileName, "Basic centered separable convolve filter.", imgGirlAlphaWidth, imgGirlAlphaHeight, imgOutputDataRGBA, 0); // decentered convolve filter, with tile fill vgSeparableConvolve(imgDst, imgSrc, 3, 3, 128, -128, kernelX, kernelY, 1.0f / 2.0f, 0.2f, VG_TILE_FILL); vgGetImageSubData(imgDst, imgOutputDataRGBA, imgGirlAlphaDataStride, imgGirlAlphaFormat, 0, 0, imgGirlAlphaWidth, imgGirlAlphaHeight); strcpy(imgFileName, "filter_separable_convolve_fill.png"); saveImage32(f, imgFileName, "Decentered separable convolve filter, with tile fill.", imgGirlAlphaWidth, imgGirlAlphaHeight, imgOutputDataRGBA, 0); // decentered convolve filter, with tile pad vgSeparableConvolve(imgDst, imgSrc, 3, 3, 128, -128, kernelX, kernelY, 1.0f / 2.0f, 0.2f, VG_TILE_PAD); vgGetImageSubData(imgDst, imgOutputDataRGBA, imgGirlAlphaDataStride, imgGirlAlphaFormat, 0, 0, imgGirlAlphaWidth, imgGirlAlphaHeight); strcpy(imgFileName, "filter_separable_convolve_pad.png"); saveImage32(f, imgFileName, "Decentered separable convolve filter, with tile pad.", imgGirlAlphaWidth, imgGirlAlphaHeight, imgOutputDataRGBA, 0); // decentered convolve filter, with tile repeat vgSeparableConvolve(imgDst, imgSrc, 3, 3, 128, -128, kernelX, kernelY, 1.0f / 2.0f, 0.2f, VG_TILE_REPEAT); vgGetImageSubData(imgDst, imgOutputDataRGBA, imgGirlAlphaDataStride, imgGirlAlphaFormat, 0, 0, imgGirlAlphaWidth, imgGirlAlphaHeight); strcpy(imgFileName, "filter_separable_convolve_repeat.png"); saveImage32(f, imgFileName, "Decentered separable convolve filter, with tile repeat.", imgGirlAlphaWidth, imgGirlAlphaHeight, imgOutputDataRGBA, 0); // decentered convolve filter, with tile reflect vgSeparableConvolve(imgDst, imgSrc, 3, 3, 128, -128, kernelX, kernelY, 1.0f / 2.0f, 0.2f, VG_TILE_REFLECT); vgGetImageSubData(imgDst, imgOutputDataRGBA, imgGirlAlphaDataStride, imgGirlAlphaFormat, 0, 0, imgGirlAlphaWidth, imgGirlAlphaHeight); strcpy(imgFileName, "filter_separable_convolve_reflect.png"); saveImage32(f, imgFileName, "Decentered separable convolve filter, with tile reflect.", imgGirlAlphaWidth, imgGirlAlphaHeight, imgOutputDataRGBA, 0); vgDestroyImage(imgSrc); vgDestroyImage(imgDst);