vgSeti(VG_RENDERING_QUALITY, VG_RENDERING_QUALITY_BETTER); vgSeti(VG_IMAGE_QUALITY, VG_IMAGE_QUALITY_BETTER); // create image and load external data imgSrc = vgCreateImage(VG_sRGBA_8888, imgGirlAlphaWidth, imgGirlAlphaHeight, VG_IMAGE_QUALITY_NONANTIALIASED); imgDst = vgCreateImage(VG_sRGBA_8888, imgGirlAlphaWidth, imgGirlAlphaHeight, VG_IMAGE_QUALITY_NONANTIALIASED); vgImageSubData(imgSrc, (const void *)&imgGirlAlphaData[imgGirlAlphaWidth * (imgGirlAlphaHeight - 1)], -imgGirlAlphaDataStride, VG_sRGBA_8888, 0, 0, imgGirlAlphaWidth, imgGirlAlphaHeight); 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); vgSetPixels(0, 0, imgSrc, -128, -128, imgGirlAlphaWidth, imgGirlAlphaHeight); vgSetPixels(0, 0, imgSrc, 128, 128, imgGirlAlphaWidth, imgGirlAlphaHeight); vgSetPixels(-128, 128, imgSrc, 0, 0, imgGirlAlphaWidth, imgGirlAlphaHeight); vgSetPixels(128, 0, imgSrc, 0, 128, imgGirlAlphaWidth, imgGirlAlphaHeight); saveDrawingSurface(f, "drawing_surface_pixels00.png", "Test vgSetPixels, to write drawing surface pixels.", 0, 0, 256, 256); eglSwapBuffers(display, surface); // clear screen col[0] = 1.0f; col[1] = 1.0f; col[2] = 1.0f; col[3] = 1.0f; vgSetfv(VG_CLEAR_COLOR, 4, col); vgClear(0, 0, 256, 256); // set some scissor rectangle scissorRects[0] = 0.0f; scissorRects[1] = 128.0f; scissorRects[2] = 128.0f; scissorRects[3] = 128.0f; scissorRects[4] = 128.0f; scissorRects[5] = 0.0f; scissorRects[6] = 128.0f; scissorRects[7] = 128.0f; vgSetfv(VG_SCISSOR_RECTS, 8, scissorRects); // write two portions without scissoring vgWritePixels((const void *)&imgGirlAlphaData[imgGirlAlphaWidth * (imgGirlAlphaHeight - 1)], -imgGirlAlphaDataStride, VG_sRGBA_8888, 128, 0, imgGirlAlphaWidth, imgGirlAlphaHeight); vgWritePixels((const void *)&imgGirlAlphaData[imgGirlAlphaWidth * (imgGirlAlphaHeight - 1)], -imgGirlAlphaDataStride, VG_sRGBA_8888, -128, 0, imgGirlAlphaWidth, imgGirlAlphaHeight); // enable scissoring vgSeti(VG_SCISSORING, VG_TRUE); vgWritePixels((const void *)&imgGirlAlphaData[imgGirlAlphaWidth * (imgGirlAlphaHeight - 1)], -imgGirlAlphaDataStride, VG_sRGBA_8888, 0, 128, imgGirlAlphaWidth, imgGirlAlphaHeight); vgWritePixels((const void *)&imgGirlAlphaData[imgGirlAlphaWidth * (imgGirlAlphaHeight - 1)], -imgGirlAlphaDataStride, VG_sRGBA_8888, 0, -128, imgGirlAlphaWidth, imgGirlAlphaHeight); saveDrawingSurface(f, "drawing_surface_pixels01.png", "Test vgWritePixels, to write drawing surface pixels.", 0, 0, 256, 256); eglSwapBuffers(display, surface); // reconstruct image using vgGetPixels vgGetPixels(imgDst, -128, 0, -128, 128, imgGirlAlphaWidth, imgGirlAlphaHeight); vgGetPixels(imgDst, -128, 128, 0, 128, imgGirlAlphaWidth, imgGirlAlphaHeight); vgGetPixels(imgDst, 128, -128, 0, -128, imgGirlAlphaWidth, imgGirlAlphaHeight); vgGetPixels(imgDst, 128, 0, 128, -128, imgGirlAlphaWidth, imgGirlAlphaHeight); vgGetImageSubData(imgDst, (void *)&imgOutputDataRGBA[imgGirlAlphaWidth * (imgGirlAlphaHeight - 1)], -imgGirlAlphaDataStride, VG_sRGBA_8888, 0, 0, imgGirlAlphaWidth, imgGirlAlphaHeight); saveImage32(f, "drawing_surface_pixels02.png", "Test vgGetPixels, to read drawing surface pixels.", imgGirlAlphaWidth, imgGirlAlphaHeight, imgOutputDataRGBA, 0); // reconstruct image using vgReadPixels memset(imgOutputDataRGBA, 0, imgGirlAlphaDataStride * imgGirlAlphaHeight); vgReadPixels(&imgOutputDataRGBA[imgGirlAlphaWidth * (imgGirlAlphaHeight - 1)], -imgGirlAlphaDataStride, VG_sRGBA_8888, 0, 128, imgGirlAlphaWidth, imgGirlAlphaHeight); vgReadPixels(&imgOutputDataRGBA[imgGirlAlphaWidth * 127], -imgGirlAlphaDataStride, VG_sRGBA_8888, 128, 128, imgGirlAlphaWidth, imgGirlAlphaHeight); vgReadPixels(&imgOutputDataRGBA[imgGirlAlphaWidth * (imgGirlAlphaHeight - 1) + 128], -imgGirlAlphaDataStride, VG_sRGBA_8888, 0, 0, 128, 128); vgReadPixels(&imgOutputDataRGBA[imgGirlAlphaWidth * 127 + 128], -imgGirlAlphaDataStride, VG_sRGBA_8888, 128, 0, 128, 128); saveImage32(f, "drawing_surface_pixels03.png", "Test vgReadPixels, to read drawing surface pixels.", imgGirlAlphaWidth, imgGirlAlphaHeight, imgOutputDataRGBA, 0); vgSeti(VG_SCISSORING, VG_FALSE); vgCopyPixels(-64, -64, 64, 64, 128, 128); vgCopyPixels(-64, 64, 64, 64, 128, 128); vgCopyPixels(-64, 192, 64, 64, 128, 128); vgCopyPixels(64, 192, 64, 64, 128, 128); vgCopyPixels(192, 192, 64, 64, 128, 128); vgCopyPixels(192, 64, 64, 64, 128, 128); vgCopyPixels(192, -64, 64, 64, 128, 128); vgCopyPixels(64, -64, 64, 64, 128, 128); saveDrawingSurface(f, "drawing_surface_pixels04.png", "Test vgCopyPixels, to scramble drawing surface pixels.", 0, 0, 256, 256); eglSwapBuffers(display, surface); vgCopyPixels(0, 0, 64, 64, 192, 192); saveDrawingSurface(f, "drawing_surface_pixels05.png", "Test vgCopyPixels, applied to overlapping regions.", 0, 0, 256, 256); eglSwapBuffers(display, surface); vgDestroyImage(imgSrc); vgDestroyImage(imgDst);