PDA

View Full Version : Displaying Images



johndoe
12-17-2009, 04:07 PM
I have recently started working in Openvg and I am using the iMX35board. I am not able to draw images(.png/bmp) :evil: . i will really appreciate if someone could point me in the right direction.

Thanks

brian.edmond
01-02-2010, 12:46 PM
I load PNG files with either libpng or the Soil library. I then do the following to create a vgImage from the data:

uint8_t *data; // this is a pointer to the decoded image
int stride; // this the decoded data stride, maybe w*bpp (but not always)

image = vgCreateImage(format, width, height, quality); // format is based on the loaded data (VG_lABGR_8888 for example)
vgImagSubdata(image, data, stride, format, 0, 0, w, h);
// you could not free data if you wanted

Now to draw the image
vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_TO_SURFACE)
vgTranslate(x, y);
vgDrawImage(image);

This works for me, hope it helps,
Brian