Image functions
Load, create, draw and copy images.
- Enumerations and Structures
- VG_COLORS
- struct VG_ImagecopyAttr
- struct VG_ImagecopyAttrImage
- struct VG_ImagecopyAttrPixel
- struct VG_PixelColor
- struct VG_Point
- Creating and destroying images
- vg4->image->create()
Create image. - vg4->image->load()
Load image from file. - vg4->image->clone()
Clone image creating a new one. - vg4->image->destroy()
Destroy image. - vg4->image->destroyall()
Destroy all images. - Modifying images
- vg4->image->clear()
Clear an image. - vg4->image->copy()
Copy image onto another image. - vg4->image->fill()
Fill image with a color. - vg4->image->draw_point()
Draw a pixel onto an image. - vg4->image->draw_points()
Draw pixels onto an image. - vg4->image->draw_line()
Draw a line onto an image. - vg4->image->draw_rect()
Draw a rectangle onto an image. - vg4->image->draw_circle()
Draw a circle onto an image. - Miscellaneous functions
- vg4->image->getpoint()
Get a pixel of an image. - vg4->image->getname()
Get filename of an image, if any. - vg4->image->getsize()
Get size of an image. - vg4->image->save()
Save image to file. - vg4->image->tobase64()
Convert image to base64. - vg4->image->attr_sum()
Sum two image-copy attributes.
Example 
/* create an image, draw figures into it and show it */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
#include <errno.h>
#include <vgagames4.h>
int main(int argc, char **argv) {
struct VG_Image *imgp;
int imgw, imgh, radius;
struct VG_Rect rect;
(void)argc; (void)argv;
/* initialize and open window */
if (!VG_init("test")) { exit(1); }
if (!vg4->window->open(VG_WINDOW_SIZE_LOW, VG_WINDOW_SCALE_BEST)) { VG_dest(); exit(1); }
/* create image */
imgw = imgh = 100;
imgp = vg4->image->create(imgw, imgh);
/* fill image with grey color */
vg4->image->fill(imgp, VG_COLOR_RGB(64, 64, 64));
/* draw a filled circle */
radius = 40;
vg4->image->draw_circle(imgp, imgw / 2, imgh / 2, radius, VG_COLOR_YELLOW, VG_TRUE);
/* draw a rectangle around the circle */
rect.x = imgw / 2 - radius;
rect.w = radius * 2 + 1;
rect.y = imgh / 2 - radius;
rect.h = radius * 2 + 1;
vg4->image->draw_rect(imgp, &rect, VG_COLOR_RED, VG_FALSE);
/* draw two lines */
vg4->image->draw_line(imgp, 0, 0, imgw - 1, imgh - 1, VG_COLOR_TURQUOISE);
vg4->image->draw_line(imgp, imgw - 1, 0, 0, imgh - 1, VG_COLOR_TURQUOISE);
/* copy image to window */
vg4->window->copy(imgp, NULL, NULL);
vg4->window->flush();
sleep(5);
/* destroy and exit */
VG_dest();
exit(0);
}