// create image and load external data imgSrc = vgCreateImage(VG_sRGBA_5551, imgDiceAlphaWidth, imgDiceAlphaHeight, VG_IMAGE_QUALITY_NONANTIALIASED); vgImageSubData(imgSrc, (const void *)imgDiceAlphaData, imgDiceAlphaDataStride, imgDiceAlphaFormat, 0, 0, imgDiceAlphaWidth, imgDiceAlphaHeight); #if defined(OPENVG_VERSION_1_1) for (j = VG_sRGBX_8888; j <= VG_A_4; ++j) { #else for (j = VG_sRGBX_8888; j <= VG_BW_1; ++j) { #endif imgDst = vgCreateImage((VGImageFormat)j, imgDiceAlphaWidth, imgDiceAlphaHeight, VG_IMAGE_QUALITY_NONANTIALIASED); vgCopyImage(imgDst, 0, 0, imgSrc, 0, 0, imgDiceAlphaWidth, imgDiceAlphaHeight, VG_TRUE); vgGetImageSubData(imgDst, imgOutputDataRGBA, imgDiceAlphaDataStride, imgDiceAlphaFormat, 0, 0, imgDiceAlphaWidth, imgDiceAlphaHeight); strcpy(imgFileName, "imgconv_sRGBA5551_to_"); strcat(imgFileName, imageFormatToString((VGImageFormat)j)); strcat(imgFileName, "_dither.png"); strcpy(testDesc, "Image conversion from sRGBA_5551 format to "); strcat(testDesc, imageFormatToString((VGImageFormat)j)); strcat(testDesc, " format, with dithering."); // pixel format without alpha channel will be saved forcing alpha to 0xFF switch (j) { case VG_sRGBX_8888: case VG_sRGB_565: case VG_sL_8: case VG_lRGBX_8888: case VG_lL_8: case VG_BW_1: saveImage32(f, imgFileName, testDesc, imgDiceAlphaWidth, imgDiceAlphaHeight, imgOutputDataRGBA, 1); break; default: saveImage32(f, imgFileName, testDesc, imgDiceAlphaWidth, imgDiceAlphaHeight, imgOutputDataRGBA, 0); } vgDestroyImage(imgDst); } vgDestroyImage(imgSrc);