vgSeti(VG_RENDERING_QUALITY, VG_RENDERING_QUALITY_BETTER); vgSeti(VG_IMAGE_QUALITY, VG_IMAGE_QUALITY_BETTER); vgSeti(VG_SCISSORING, VG_FALSE); col[0] = 0.0f; col[1] = 0.0f; col[2] = 0.0f; col[3] = 0.0f; vgSetfv(VG_CLEAR_COLOR, 4, col); vgClear(0, 0, 256, 256); // create alphamask image and load external data imgSrc = vgCreateImage(VG_lRGBA_8888, imgBarbaraAlphaWidth, imgBarbaraAlphaHeight, VG_IMAGE_QUALITY_NONANTIALIASED); vgImageSubData(imgSrc, (const void *)&imgBarbaraAlphaData[imgBarbaraAlphaWidth * (imgBarbaraAlphaHeight - 1)], -imgBarbaraAlphaDataStride, imgBarbaraAlphaFormat, 0, 0, imgBarbaraAlphaWidth, imgBarbaraAlphaHeight); // create draw images and load external data imgL = vgCreateImage(VG_lRGBA_8888, imgMultiplyAlphaWidth, imgMultiplyAlphaHeight, VG_IMAGE_QUALITY_NONANTIALIASED); vgImageSubData(imgL, (const void *)&imgMultiplyAlphaData[imgMultiplyAlphaWidth * (imgMultiplyAlphaHeight - 1)], -imgMultiplyAlphaDataStride, imgMultiplyAlphaFormat, 0, 0, imgMultiplyAlphaWidth, imgMultiplyAlphaHeight); imgS = vgCreateImage(VG_sRGBA_8888, imgMultiplyAlphaWidth, imgMultiplyAlphaHeight, VG_IMAGE_QUALITY_NONANTIALIASED); vgImageSubData(imgS, (const void *)&imgMultiplyAlphaData[imgMultiplyAlphaWidth * (imgMultiplyAlphaHeight - 1)], -imgMultiplyAlphaDataStride, imgMultiplyAlphaFormat, 0, 0, imgMultiplyAlphaWidth, imgMultiplyAlphaHeight); imgLpre = vgCreateImage(VG_lRGBA_8888_PRE, imgMultiplyAlphaWidth, imgMultiplyAlphaHeight, VG_IMAGE_QUALITY_NONANTIALIASED); vgImageSubData(imgLpre, (const void *)&imgMultiplyAlphaData[imgMultiplyAlphaWidth * (imgMultiplyAlphaHeight - 1)], -imgMultiplyAlphaDataStride, imgMultiplyAlphaFormat, 0, 0, imgMultiplyAlphaWidth, imgMultiplyAlphaHeight); imgSpre = vgCreateImage(VG_sRGBA_8888_PRE, imgMultiplyAlphaWidth, imgMultiplyAlphaHeight, VG_IMAGE_QUALITY_NONANTIALIASED); vgImageSubData(imgSpre, (const void *)&imgMultiplyAlphaData[imgMultiplyAlphaWidth * (imgMultiplyAlphaHeight - 1)], -imgMultiplyAlphaDataStride, imgMultiplyAlphaFormat, 0, 0, imgMultiplyAlphaWidth, imgMultiplyAlphaHeight); // set alpha mask vgMask(imgSrc, VG_SET_MASK, 0, 0, 256, 256); vgSeti(VG_MASKING, VG_FALSE); vgSeti(VG_IMAGE_MODE, VG_DRAW_IMAGE_MULTIPLY); // create and set a paint for fill fillPaint = vgCreatePaint(); vgSetParameteri(fillPaint, VG_PAINT_TYPE, VG_PAINT_TYPE_COLOR); vgSetPaint(fillPaint, VG_FILL_PATH); col[0] = 0.9f; col[1] = 0.3f; col[2] = 0.6f; col[3] = 0.9f; vgSetParameterfv(fillPaint, VG_PAINT_COLOR, 4, col); vgSeti(VG_MATRIX_MODE, VG_MATRIX_FILL_PAINT_TO_USER); vgLoadIdentity(); vgSeti(VG_MASKING, VG_FALSE); for (i = VG_BLEND_SRC; i <= VG_BLEND_ADDITIVE; ++i) { vgSeti(VG_SCISSORING, VG_FALSE); vgWritePixels(imgBackgroundData, imgBackgroundDataStride, imgBackgroundFormat, 0, 0, imgBackgroundWidth, imgBackgroundHeight); vgSeti(VG_SCISSORING, VG_TRUE); vgSeti(VG_BLEND_MODE, i); vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE); vgLoadIdentity(); scissorRects[0] = 10.0f; scissorRects[1] = 10.0f; scissorRects[2] = 118.0f; scissorRects[3] = 118.0f; vgSetfv(VG_SCISSOR_RECTS, 4, scissorRects); vgDrawImage(imgL); scissorRects[0] = 10.0f; scissorRects[1] = 128.0f; scissorRects[2] = 118.0f; scissorRects[3] = 118.0f; vgSetfv(VG_SCISSOR_RECTS, 4, scissorRects); vgDrawImage(imgS); scissorRects[0] = 128.0f; scissorRects[1] = 128.0f; scissorRects[2] = 118.0f; scissorRects[3] = 118.0f; vgSetfv(VG_SCISSOR_RECTS, 4, scissorRects); vgDrawImage(imgLpre); scissorRects[0] = 128.0f; scissorRects[1] = 10.0f; scissorRects[2] = 118.0f; scissorRects[3] = 118.0f; vgSetfv(VG_SCISSOR_RECTS, 4, scissorRects); vgDrawImage(imgSpre); strcpy(imgFileName, "draw_image_multiply_color_"); strcat(imgFileName, blendModeToString((VGBlendMode)i)); strcat(imgFileName, "_identity.png"); strcpy(testDesc, "Test vgDrawImage MULTIPLY with "); strcat(testDesc, blendModeToString((VGBlendMode)i)); strcat(testDesc, " blend mode and color paint (without alpha mask)"); saveDrawingSurface(f, imgFileName, testDesc, 0, 0, 256, 256); eglSwapBuffers(display, surface); } vgSeti(VG_MASKING, VG_TRUE); for (i = VG_BLEND_SRC; i <= VG_BLEND_ADDITIVE; ++i) { vgSeti(VG_SCISSORING, VG_FALSE); vgWritePixels(imgBackgroundData, imgBackgroundDataStride, imgBackgroundFormat, 0, 0, imgBackgroundWidth, imgBackgroundHeight); vgSeti(VG_SCISSORING, VG_TRUE); vgSeti(VG_BLEND_MODE, i); vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE); vgLoadIdentity(); scissorRects[0] = 10.0f; scissorRects[1] = 10.0f; scissorRects[2] = 118.0f; scissorRects[3] = 118.0f; vgSetfv(VG_SCISSOR_RECTS, 4, scissorRects); vgDrawImage(imgL); scissorRects[0] = 10.0f; scissorRects[1] = 128.0f; scissorRects[2] = 118.0f; scissorRects[3] = 118.0f; vgSetfv(VG_SCISSOR_RECTS, 4, scissorRects); vgDrawImage(imgS); scissorRects[0] = 128.0f; scissorRects[1] = 128.0f; scissorRects[2] = 118.0f; scissorRects[3] = 118.0f; vgSetfv(VG_SCISSOR_RECTS, 4, scissorRects); vgDrawImage(imgLpre); scissorRects[0] = 128.0f; scissorRects[1] = 10.0f; scissorRects[2] = 118.0f; scissorRects[3] = 118.0f; vgSetfv(VG_SCISSOR_RECTS, 4, scissorRects); vgDrawImage(imgSpre); strcpy(imgFileName, "draw_image_multiply_color_"); strcat(imgFileName, blendModeToString((VGBlendMode)i)); strcat(imgFileName, "_mask_identity.png"); strcpy(testDesc, "Test vgDrawImage MULTIPLY with "); strcat(testDesc, blendModeToString((VGBlendMode)i)); strcat(testDesc, " blend mode and color paint (with alpha mask)"); saveDrawingSurface(f, imgFileName, testDesc, 0, 0, 256, 256); eglSwapBuffers(display, surface); } #if defined(OPENVG_VERSION_1_1) // set a color transformation { VGfloat ctValues[8] = { -1.0f, -1.0f, -1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f }; vgSetfv(VG_COLOR_TRANSFORM_VALUES, 8, ctValues); } vgSeti(VG_COLOR_TRANSFORM, VG_TRUE); #endif vgSeti(VG_MASKING, VG_FALSE); for (i = VG_BLEND_SRC; i <= VG_BLEND_ADDITIVE; ++i) { vgSeti(VG_SCISSORING, VG_FALSE); vgWritePixels(imgBackgroundData, imgBackgroundDataStride, imgBackgroundFormat, 0, 0, imgBackgroundWidth, imgBackgroundHeight); vgSeti(VG_SCISSORING, VG_TRUE); vgSeti(VG_BLEND_MODE, i); vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE); vgLoadIdentity(); vgTranslate(128.0f, 128.0f); vgRotate(90.0f); vgTranslate(-128.0f, -128.0f); scissorRects[0] = 10.0f; scissorRects[1] = 10.0f; scissorRects[2] = 118.0f; scissorRects[3] = 118.0f; vgSetfv(VG_SCISSOR_RECTS, 4, scissorRects); vgDrawImage(imgL); scissorRects[0] = 10.0f; scissorRects[1] = 128.0f; scissorRects[2] = 118.0f; scissorRects[3] = 118.0f; vgSetfv(VG_SCISSOR_RECTS, 4, scissorRects); vgDrawImage(imgS); scissorRects[0] = 128.0f; scissorRects[1] = 128.0f; scissorRects[2] = 118.0f; scissorRects[3] = 118.0f; vgSetfv(VG_SCISSOR_RECTS, 4, scissorRects); vgDrawImage(imgLpre); scissorRects[0] = 128.0f; scissorRects[1] = 10.0f; scissorRects[2] = 118.0f; scissorRects[3] = 118.0f; vgSetfv(VG_SCISSOR_RECTS, 4, scissorRects); vgDrawImage(imgSpre); strcpy(imgFileName, "draw_image_multiply_color_"); strcat(imgFileName, blendModeToString((VGBlendMode)i)); strcat(imgFileName, "_affine.png"); strcpy(testDesc, "Test vgDrawImage MULTIPLY with "); strcat(testDesc, blendModeToString((VGBlendMode)i)); #if defined(OPENVG_VERSION_1_1) strcat(testDesc, " blend mode and color paint (without alpha mask, affine transformation and color transform)"); #else strcat(testDesc, " blend mode and color paint (without alpha mask, affine transformation)"); #endif saveDrawingSurface(f, imgFileName, testDesc, 0, 0, 256, 256); eglSwapBuffers(display, surface); } vgSeti(VG_MASKING, VG_TRUE); for (i = VG_BLEND_SRC; i <= VG_BLEND_ADDITIVE; ++i) { vgSeti(VG_SCISSORING, VG_FALSE); vgWritePixels(imgBackgroundData, imgBackgroundDataStride, imgBackgroundFormat, 0, 0, imgBackgroundWidth, imgBackgroundHeight); vgSeti(VG_SCISSORING, VG_TRUE); vgSeti(VG_BLEND_MODE, i); vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE); vgLoadIdentity(); vgTranslate(128.0f, 128.0f); vgRotate(90.0f); vgTranslate(-128.0f, -128.0f); scissorRects[0] = 10.0f; scissorRects[1] = 10.0f; scissorRects[2] = 118.0f; scissorRects[3] = 118.0f; vgSetfv(VG_SCISSOR_RECTS, 4, scissorRects); vgDrawImage(imgL); scissorRects[0] = 10.0f; scissorRects[1] = 128.0f; scissorRects[2] = 118.0f; scissorRects[3] = 118.0f; vgSetfv(VG_SCISSOR_RECTS, 4, scissorRects); vgDrawImage(imgS); scissorRects[0] = 128.0f; scissorRects[1] = 128.0f; scissorRects[2] = 118.0f; scissorRects[3] = 118.0f; vgSetfv(VG_SCISSOR_RECTS, 4, scissorRects); vgDrawImage(imgLpre); scissorRects[0] = 128.0f; scissorRects[1] = 10.0f; scissorRects[2] = 118.0f; scissorRects[3] = 118.0f; vgSetfv(VG_SCISSOR_RECTS, 4, scissorRects); vgDrawImage(imgSpre); strcpy(imgFileName, "draw_image_multiply_color_"); strcat(imgFileName, blendModeToString((VGBlendMode)i)); strcat(imgFileName, "_mask_affine.png"); strcpy(testDesc, "Test vgDrawImage MULTIPLY with "); strcat(testDesc, blendModeToString((VGBlendMode)i)); #if defined(OPENVG_VERSION_1_1) strcat(testDesc, " blend mode and color paint (with alpha mask, affine transformation and color transform)"); #else strcat(testDesc, " blend mode and color paint (with alpha mask, affine transformation)"); #endif saveDrawingSurface(f, imgFileName, testDesc, 0, 0, 256, 256); eglSwapBuffers(display, surface); } #if defined(OPENVG_VERSION_1_1) vgSeti(VG_COLOR_TRANSFORM, VG_FALSE); #endif vgDestroyImage(imgSrc); vgDestroyImage(imgL); vgDestroyImage(imgS); vgDestroyImage(imgLpre); vgDestroyImage(imgSpre); vgDestroyPaint(fillPaint);