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 image and load external data //img = vgCreateImage(imgStencilAlphaFormat, imgStencilAlphaWidth, imgStencilAlphaHeight, VG_IMAGE_QUALITY_FASTER); img = vgCreateImage(VG_lRGBA_8888, imgStencilAlphaWidth, imgStencilAlphaHeight, VG_IMAGE_QUALITY_FASTER); vgImageSubData(img, (const void *)&imgStencilAlphaData[imgStencilAlphaWidth * (imgStencilAlphaHeight - 1)], -imgStencilAlphaDataStride, imgStencilAlphaFormat, 0, 0, imgStencilAlphaWidth, imgStencilAlphaHeight); // set a scissor rectangle scissorRects[0] = 10.0f; scissorRects[1] = 10.0f; scissorRects[2] = 236.0f; scissorRects[3] = 236.0f; vgSetfv(VG_SCISSOR_RECTS, 4, scissorRects); vgSeti(VG_SCISSORING, VG_TRUE); // set alpha mask vgMask(imgSrc, VG_SET_MASK, 0, 0, 256, 256); vgSeti(VG_MASKING, VG_FALSE); col[0] = 0.0f; col[1] = 0.0f; col[2] = 0.0f; col[3] = 0.9f; vgSetfv(VG_CLEAR_COLOR, 4, col); vgSeti(VG_IMAGE_MODE, VG_DRAW_IMAGE_STENCIL); // 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.7f; col[2] = 0.5f; col[3] = 0.9f; vgSetParameterfv(fillPaint, VG_PAINT_COLOR, 4, col); vgSeti(VG_MASKING, VG_FALSE); for (i = VG_BLEND_SRC; i <= VG_BLEND_ADDITIVE; ++i) { vgClear(0, 0, 256, 256); vgSeti(VG_BLEND_MODE, i); vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE); vgLoadIdentity(); vgTranslate(32.0f, 32.0f); vgScale(0.75f, 0.75f); vgDrawImage(img); strcpy(imgFileName, "draw_image_stencil_color_"); strcat(imgFileName, blendModeToString(i)); strcat(imgFileName, "_affine.png"); strcpy(testDesc, "Test vgDrawImage STENCIL with "); strcat(testDesc, blendModeToString(i)); strcat(testDesc, " blend mode and color paint (without alpha mask, affine transformation)"); 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) { vgClear(0, 0, 256, 256); vgSeti(VG_BLEND_MODE, i); vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE); vgLoadIdentity(); vgTranslate(32.0f, 32.0f); vgScale(0.75f, 0.75f); vgDrawImage(img); strcpy(imgFileName, "draw_image_stencil_color_"); strcat(imgFileName, blendModeToString(i)); strcat(imgFileName, "_mask_affine.png"); strcpy(testDesc, "Test vgDrawImage STENCIL with "); strcat(testDesc, blendModeToString(i)); strcat(testDesc, " blend mode and color paint (with alpha mask, affine transformation)"); saveDrawingSurface(f, imgFileName, testDesc, 0, 0, 256, 256); eglSwapBuffers(display, surface); } /* // generate a perpsective matrix matrix[0] = 1.2f; matrix[3] = 0.2f; matrix[6] = 10.0f; matrix[1] = -0.2f; matrix[4] = 1.2f; matrix[7] = 70.0f; matrix[2] = 0.002f; matrix[5] = 0.003f; matrix[8] = 0.8f; vgSeti(VG_MASKING, VG_FALSE); for (i = VG_BLEND_SRC; i <= VG_BLEND_ADDITIVE; ++i) { vgClear(0, 0, 256, 256); vgSeti(VG_BLEND_MODE, i); vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE); vgLoadMatrix(matrix); vgDrawImage(img); strcpy(imgFileName, "draw_image_stencil_color_"); strcat(imgFileName, blendModeToString(i)); strcat(imgFileName, "_perpsective.png"); strcpy(testDesc, "Test vgDrawImage STENCIL with "); strcat(testDesc, blendModeToString(i)); strcat(testDesc, " blend mode and color paint (without alpha mask, perspective transformation)"); 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) { vgClear(0, 0, 256, 256); vgSeti(VG_BLEND_MODE, i); vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE); vgLoadMatrix(matrix); vgDrawImage(img); strcpy(imgFileName, "draw_image_stencil_color_"); strcat(imgFileName, blendModeToString(i)); strcat(imgFileName, "_mask_perspective.png"); strcpy(testDesc, "Test vgDrawImage STENCIL with "); strcat(testDesc, blendModeToString(i)); strcat(testDesc, " blend mode and color paint (with alpha mask, perspective transformation)"); saveDrawingSurface(f, imgFileName, testDesc, 0, 0, 256, 256); eglSwapBuffers(display, surface); } */ vgDestroyImage(imgSrc); vgDestroyImage(img); vgDestroyPaint(fillPaint);