1#include "eglcommon.h" 2 3#include <VG/openvg.h> 4 5#include <math.h> 6#include <stdlib.h> 7#include <stdio.h> 8 9static void 10init(void) 11{ 12} 13 14/* new window size or exposure */ 15static void 16reshape(int w, int h) 17{ 18} 19 20static const VGfloat red[4] = { 1.0f, 0.0f, 0.0f, 1.0f }; 21static const VGfloat black[4] = { 0.0f, 0.0f, 0.0f, 1.0f }; 22static const VGfloat white[4] = { 1.0f, 1.0f, 1.0f, 1.0f }; 23 24static void 25draw(void) 26{ 27 const VGint w = 48; 28 VGImage img1, img2; 29 VGint x, y; 30 31 vgSetfv(VG_CLEAR_COLOR, 4, white); 32 vgClear(0, 0, window_width(), window_height()); 33 34 img1 = vgCreateImage(VG_sRGBA_8888, w, w, 35 VG_IMAGE_QUALITY_NONANTIALIASED); 36 img2 = vgCreateImage(VG_sRGBA_8888, w, w, 37 VG_IMAGE_QUALITY_NONANTIALIASED); 38 39 x = 5; 40 y = (window_height() - w) / 2; 41 42 /* test vgSetPixels */ 43 vgSetfv(VG_CLEAR_COLOR, 4, red); 44 vgClearImage(img1, 0, 0, w, w / 2); 45 vgSetfv(VG_CLEAR_COLOR, 4, black); 46 vgClearImage(img1, 0, w / 2, w, w / 2); 47 vgSetPixels(x, y, img1, 0, 0, w, w); 48 49 x += w + 5; 50 51 /* test vgDrawImage */ 52 vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE); 53 vgLoadIdentity(); 54 vgTranslate(x, y); 55 vgDrawImage(img1); 56 57 /* test vgGetPixels */ 58 vgGetPixels(img1, 0, 0, x, y, w, w); 59 x += w + 5; 60 vgSetPixels(x, y, img1, 0, 0, w, w); 61 62 x += w + 5; 63 64 /* test vgCopyImage */ 65 vgCopyImage(img2, 0, 0, img1, 0, 0, w, w, VG_FALSE); 66 vgSetPixels(x, y, img2, 0, 0, w, w); 67 68 /* vgCopyPixels */ 69 vgCopyPixels(x + w + 5, y, x, y, w, w); 70 71 vgDestroyImage(img1); 72 vgDestroyImage(img2); 73} 74 75 76int main(int argc, char **argv) 77{ 78 set_window_size(300, 300); 79 return run(argc, argv, init, reshape, 80 draw, 0); 81} 82