// 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); // set channel masks vgSeti(VG_FILTER_CHANNEL_MASK, VG_RED | VG_GREEN | VG_BLUE | VG_ALPHA); vgSeti(VG_FILTER_FORMAT_LINEAR, VG_FALSE); vgSeti(VG_FILTER_FORMAT_PREMULTIPLIED, VG_FALSE); // generate a non-premultiplied palatte for (i = 0; i < 256; ++i) { VGubyte r = (VGubyte)(127.0f * sin(2 * (i * 6.2831f / 256.0f)) + 127.5f); VGubyte g = (VGubyte)(127.0f * sin(1 * (i * 6.2831f / 256.0f)) + 127.5f); VGubyte b = (VGubyte)(127.0f * cos(1 * (i * 6.2831f / 256.0f)) + 127.5f); VGubyte a = i; lut[i] = (r << 24) | (g << 16) | (b << 8) | a; } // lookup single filter (using red source channel), in linear non-premultiplied color space vgLookupSingle(imgDst, imgSrc, lut, VG_RED, VG_TRUE, VG_FALSE); vgGetImageSubData(imgDst, imgOutputDataRGBA, imgGirlAlphaDataStride, imgGirlAlphaFormat, 0, 0, imgGirlAlphaWidth, imgGirlAlphaHeight); strcpy(imgFileName, "filter_lookup_single_l.png"); saveImage32(f, imgFileName, "Lookup single filter (using red source channel), in linear non-premultiplied output color space.", imgGirlAlphaWidth, imgGirlAlphaHeight, imgOutputDataRGBA, 0); // lookup single filter (using green source channel), in non-linear non-premultiplied color space vgLookupSingle(imgDst, imgSrc, lut, VG_GREEN, VG_FALSE, VG_FALSE); vgGetImageSubData(imgDst, imgOutputDataRGBA, imgGirlAlphaDataStride, imgGirlAlphaFormat, 0, 0, imgGirlAlphaWidth, imgGirlAlphaHeight); strcpy(imgFileName, "filter_lookup_single_s.png"); saveImage32(f, imgFileName, "Lookup single filter (using green source channel), in non-linear non-premultiplied output color space.", imgGirlAlphaWidth, imgGirlAlphaHeight, imgOutputDataRGBA, 0); // generate a premultiplied palatte for (i = 0; i < 256; ++i) { VGubyte a = i; VGubyte r = (VGubyte)(a * (127.0f * sin(2 * (i * 6.2831f / 256.0f)) + 127.5f) / 255.0f); VGubyte g = (VGubyte)(a * (127.0f * sin(1 * (i * 6.2831f / 256.0f)) + 127.5f) / 255.0f); VGubyte b = (VGubyte)(a * (127.0f * cos(1 * (i * 6.2831f / 256.0f)) + 127.5f) / 255.0f); lut[i] = (r << 24) | (g << 16) | (b << 8) | a; } // lookup single filter (using blue source channel), in linear premultiplied color space vgLookupSingle(imgDst, imgSrc, lut, VG_BLUE, VG_TRUE, VG_TRUE); vgGetImageSubData(imgDst, imgOutputDataRGBA, imgGirlAlphaDataStride, imgGirlAlphaFormat, 0, 0, imgGirlAlphaWidth, imgGirlAlphaHeight); strcpy(imgFileName, "filter_lookup_single_lpre.png"); saveImage32(f, imgFileName, "Lookup single filter (using blue source channel), in linear premultiplied output color space.", imgGirlAlphaWidth, imgGirlAlphaHeight, imgOutputDataRGBA, 0); // lookup single filter (using alpha source channel), in non-linear premultiplied color space vgLookupSingle(imgDst, imgSrc, lut, VG_ALPHA, VG_FALSE, VG_TRUE); vgGetImageSubData(imgDst, imgOutputDataRGBA, imgGirlAlphaDataStride, imgGirlAlphaFormat, 0, 0, imgGirlAlphaWidth, imgGirlAlphaHeight); strcpy(imgFileName, "filter_lookup_single_spre.png"); saveImage32(f, imgFileName, "Lookup single filter (using alpha source channel), in non-linear premultiplied output color space.", imgGirlAlphaWidth, imgGirlAlphaHeight, imgOutputDataRGBA, 0); vgDestroyImage(imgSrc); vgDestroyImage(imgDst); // generate a non-premultiplied palatte for (i = 0; i < 256; ++i) { VGubyte r = (VGubyte)(127.0f * sin(1.5f * (i * 6.2831f / 256.0f)) + 127.5f); VGubyte g = (VGubyte)(127.0f * sin(0.8f * (i * 6.2831f / 256.0f)) + 127.5f); VGubyte b = (VGubyte)(127.0f * cos(1.3f * (i * 6.2831f / 256.0f)) + 127.5f); VGubyte a = i; lut[i] = (r << 24) | (g << 16) | (b << 8) | a; } imgSrc = vgCreateImage(VG_sRGBA_8888, imgStencilAlphaWidth, imgStencilAlphaHeight, VG_IMAGE_QUALITY_NONANTIALIASED); vgImageSubData(imgSrc, (const void *)imgStencilAlphaData, imgStencilAlphaDataStride, imgStencilAlphaFormat, 0, 0, imgStencilAlphaWidth, imgStencilAlphaHeight); #if defined(OPENVG_VERSION_1_1) for (i = VG_sRGBX_8888; i <= VG_A_4; ++i) { #else for (i = VG_sRGBX_8888; i <= VG_BW_1; ++i) { #endif imgDst = vgCreateImage((VGImageFormat)i, imgStencilAlphaWidth, imgStencilAlphaHeight, VG_IMAGE_QUALITY_NONANTIALIASED); vgLookupSingle(imgDst, imgSrc, lut, VG_GREEN, VG_TRUE, VG_FALSE); vgGetImageSubData(imgDst, imgOutputDataRGBA, imgStencilAlphaDataStride, imgStencilAlphaFormat, 0, 0, imgStencilAlphaWidth, imgStencilAlphaHeight); strcpy(imgFileName, "filter_lookup_single_sRGBA8888_to_"); strcat(imgFileName, imageFormatToString((VGImageFormat)i)); strcat(imgFileName, ".png"); strcpy(testDesc, "Lookup single filter (using green source channel), in linear non-premultiplied output color space, from sRGBA8888 to "); strcat(testDesc, imageFormatToString((VGImageFormat)i)); strcat(testDesc, " format."); saveImage32(f, imgFileName, testDesc, imgStencilAlphaWidth, imgStencilAlphaHeight, imgOutputDataRGBA, 0); vgDestroyImage(imgDst); } vgDestroyImage(imgSrc); imgSrc = vgCreateImage(VG_sRGBA_4444, imgStencilAlphaWidth, imgStencilAlphaHeight, VG_IMAGE_QUALITY_NONANTIALIASED); vgImageSubData(imgSrc, (const void *)imgStencilAlphaData, imgStencilAlphaDataStride, imgStencilAlphaFormat, 0, 0, imgStencilAlphaWidth, imgStencilAlphaHeight); #if defined(OPENVG_VERSION_1_1) for (i = VG_sRGBX_8888; i <= VG_A_4; ++i) { #else for (i = VG_sRGBX_8888; i <= VG_BW_1; ++i) { #endif imgDst = vgCreateImage((VGImageFormat)i, imgStencilAlphaWidth, imgStencilAlphaHeight, VG_IMAGE_QUALITY_NONANTIALIASED); vgLookupSingle(imgDst, imgSrc, lut, VG_GREEN, VG_TRUE, VG_FALSE); vgGetImageSubData(imgDst, imgOutputDataRGBA, imgStencilAlphaDataStride, imgStencilAlphaFormat, 0, 0, imgStencilAlphaWidth, imgStencilAlphaHeight); strcpy(imgFileName, "filter_lookup_single_sRGBA4444_to_"); strcat(imgFileName, imageFormatToString((VGImageFormat)i)); strcat(imgFileName, ".png"); strcpy(testDesc, "Lookup single filter (using green source channel), in linear non-premultiplied output color space, from sRGBA4444 to "); strcat(testDesc, imageFormatToString((VGImageFormat)i)); strcat(testDesc, " format."); saveImage32(f, imgFileName, testDesc, imgStencilAlphaWidth, imgStencilAlphaHeight, imgOutputDataRGBA, 0); vgDestroyImage(imgDst); } vgDestroyImage(imgSrc); imgSrc = vgCreateImage(VG_sL_8, imgGirlWidth, imgGirlHeight, VG_IMAGE_QUALITY_NONANTIALIASED); vgImageSubData(imgSrc, (const void *)imgGirlData, imgGirlDataStride, imgGirlFormat, 0, 0, imgGirlWidth, imgGirlHeight); #if defined(OPENVG_VERSION_1_1) for (i = VG_sRGBX_8888; i <= VG_A_4; ++i) { #else for (i = VG_sRGBX_8888; i <= VG_BW_1; ++i) { #endif imgDst = vgCreateImage((VGImageFormat)i, imgGirlWidth, imgGirlHeight, VG_IMAGE_QUALITY_NONANTIALIASED); vgLookupSingle(imgDst, imgSrc, lut, VG_GREEN, VG_TRUE, VG_FALSE); vgGetImageSubData(imgDst, imgOutputDataRGBA, imgGirlDataStride, imgGirlFormat, 0, 0, imgGirlWidth, imgGirlHeight); strcpy(imgFileName, "filter_lookup_single_sL8_to_"); strcat(imgFileName, imageFormatToString((VGImageFormat)i)); strcat(imgFileName, ".png"); strcpy(testDesc, "Lookup single filter (using green source channel), in linear non-premultiplied output color space, from sL8 to "); strcat(testDesc, imageFormatToString((VGImageFormat)i)); strcat(testDesc, " format."); saveImage32(f, imgFileName, testDesc, imgGirlWidth, imgGirlHeight, imgOutputDataRGBA, 0); vgDestroyImage(imgDst); } vgDestroyImage(imgSrc); imgSrc = vgCreateImage(VG_A_8, imgBarbaraAlphaWidth, imgBarbaraAlphaHeight, VG_IMAGE_QUALITY_NONANTIALIASED); vgImageSubData(imgSrc, (const void *)imgBarbaraAlphaData, imgBarbaraAlphaDataStride, imgBarbaraAlphaFormat, 0, 0, imgBarbaraAlphaWidth, imgBarbaraAlphaHeight); #if defined(OPENVG_VERSION_1_1) for (i = VG_sRGBX_8888; i <= VG_A_4; ++i) { #else for (i = VG_sRGBX_8888; i <= VG_BW_1; ++i) { #endif imgDst = vgCreateImage((VGImageFormat)i, imgBarbaraAlphaWidth, imgBarbaraAlphaHeight, VG_IMAGE_QUALITY_NONANTIALIASED); vgLookupSingle(imgDst, imgSrc, lut, VG_GREEN, VG_TRUE, VG_FALSE); vgGetImageSubData(imgDst, imgOutputDataRGBA, imgBarbaraAlphaDataStride, imgBarbaraAlphaFormat, 0, 0, imgBarbaraAlphaWidth, imgBarbaraAlphaHeight); strcpy(imgFileName, "filter_lookup_single_A8_to_"); strcat(imgFileName, imageFormatToString((VGImageFormat)i)); strcat(imgFileName, ".png"); strcpy(testDesc, "Lookup single filter (using green source channel), in linear non-premultiplied output color space, from A8 to "); strcat(testDesc, imageFormatToString((VGImageFormat)i)); strcat(testDesc, " format."); saveImage32(f, imgFileName, testDesc, imgBarbaraAlphaWidth, imgBarbaraAlphaHeight, imgOutputDataRGBA, 0); vgDestroyImage(imgDst); } vgDestroyImage(imgSrc); #if defined(OPENVG_VERSION_1_1) imgSrc = vgCreateImage(VG_A_4, imgBarbaraAlphaWidth, imgBarbaraAlphaHeight, VG_IMAGE_QUALITY_NONANTIALIASED); vgImageSubData(imgSrc, (const void *)imgBarbaraAlphaData, imgBarbaraAlphaDataStride, imgBarbaraAlphaFormat, 0, 0, imgBarbaraAlphaWidth, imgBarbaraAlphaHeight); for (i = VG_sRGBX_8888; i <= VG_A_4; ++i) { imgDst = vgCreateImage(i, imgBarbaraAlphaWidth, imgBarbaraAlphaHeight, VG_IMAGE_QUALITY_NONANTIALIASED); vgLookupSingle(imgDst, imgSrc, lut, VG_GREEN, VG_TRUE, VG_FALSE); vgGetImageSubData(imgDst, imgOutputDataRGBA, imgBarbaraAlphaDataStride, imgBarbaraAlphaFormat, 0, 0, imgBarbaraAlphaWidth, imgBarbaraAlphaHeight); strcpy(imgFileName, "filter_lookup_single_A4_to_"); strcat(imgFileName, imageFormatToString(i)); strcat(imgFileName, ".png"); strcpy(testDesc, "Lookup single filter (using green source channel), in linear non-premultiplied output color space, from A4 to "); strcat(testDesc, imageFormatToString(i)); strcat(testDesc, " format."); saveImage32(f, imgFileName, testDesc, imgBarbaraAlphaWidth, imgBarbaraAlphaHeight, imgOutputDataRGBA, 0); vgDestroyImage(imgDst); } vgDestroyImage(imgSrc); #endif imgSrc = vgCreateImage(VG_BW_1, imgOldManWidth, imgOldManHeight, VG_IMAGE_QUALITY_NONANTIALIASED); vgImageSubData(imgSrc, (const void *)imgOldManData, imgOldManDataStride, imgOldManFormat, 0, 0, imgOldManWidth, imgOldManHeight); #if defined(OPENVG_VERSION_1_1) for (i = VG_sRGBX_8888; i <= VG_A_4; ++i) { #else for (i = VG_sRGBX_8888; i <= VG_BW_1; ++i) { #endif imgDst = vgCreateImage((VGImageFormat)i, imgOldManWidth, imgOldManHeight, VG_IMAGE_QUALITY_NONANTIALIASED); vgLookupSingle(imgDst, imgSrc, lut, VG_GREEN, VG_TRUE, VG_FALSE); vgGetImageSubData(imgDst, imgOutputDataRGBA, imgOldManDataStride, imgOldManFormat, 0, 0, imgOldManWidth, imgOldManHeight); strcpy(imgFileName, "filter_lookup_single_BW1_to_"); strcat(imgFileName, imageFormatToString((VGImageFormat)i)); strcat(imgFileName, ".png"); strcpy(testDesc, "Lookup single filter (using green source channel), in linear non-premultiplied output color space, from BW1 to "); strcat(testDesc, imageFormatToString((VGImageFormat)i)); strcat(testDesc, " format."); saveImage32(f, imgFileName, testDesc, imgOldManWidth, imgOldManHeight, imgOutputDataRGBA, 0); vgDestroyImage(imgDst); } vgDestroyImage(imgSrc);