GDI+ / AmanithVG / ShivaVG framework + question


First, a contribution. Here is the C++ graphics framework we’re using in our project:

It abstracts over GDI+ and OpenVG (supporting both AmanithVG and ShivaVG). Some of the features:

  • parsing of TrueType fonts with FreeType (so, people who wondered how to use fonts may use the code)
  • formatted text rendering
  • 9grid seamless image scaling (it was tricky. not so seamless with GDI+ currently, the working solution was damn slow)
  • image tinting

Second, an inquiry. We use text functions and VG_COLOR_TRANSFORM defined in OpenVG 1.1, but:

1.ShivaVG only supports OpenVG 1.0.1. Are there chances it will be updated? Are there alive developers somewhere in the universe?

2.AmanithVG perfectly supports OpenVG 1.1. But they offer evaluation license only. I’ve contacted them and they tell they’re targeted at hardware manufacturers and don’t offer developer licenses. Guys, are there chances you will?

Thanks in advance.

Some info on the framework:

1.To choose between GDI+ and OpenVG just instantiate the respective class: GraphicsGDIP or GraphicsOVG

2.To choose between AmanithVG and ShivaVG change the #define at the top of GraphicsOVG.cpp

3.The TrueType parsing code is located in _FontFileOVG.h/cpp:

VGFont font;
map<wchar_t, float> advances;

FT_Outline_Funcs FontFileOVG::outline_funcs =
	0, 0

bool FontFileOVG::Load(void *data, int size)
	FT_Face face;

	if (FT_New_Memory_Face(ft_library, (FT_Byte *)data, size, 0, &face))
		return false;

	if (!face->face_flags & FT_FACE_FLAG_SCALABLE)
		return false;
	units_per_EM = face->units_per_EM;
	ascent = face->ascender;
	descent = -face->descender;
	height = face->height;

	if (font) vgDestroyFont(font);
	font = vgCreateFont(face->num_glyphs);	

	FT_UInt glyph_index;
	FT_ULong char_code = FT_Get_First_Char(face, &glyph_index);

	while (glyph_index != 0)
		// NO_SCALE = NO_HINTING, NO_BITMAP, and keeps font in design units
		FT_Load_Glyph(face, glyph_index, FT_LOAD_NO_AUTOHINT | FT_LOAD_NO_SCALE);
		PathOVG path;
		FT_GlyphSlot glyph = face->glyph;
		FT_Outline_Decompose(&glyph->outline, &outline_funcs, (void *)&path);

		VGfloat glyph_origin[2] = { 0.0f, 0.0f };
		VGfloat glyph_escapement[2] = { glyph->advance.x, glyph->advance.y };
		vgSetGlyphToPath(font, char_code, path.Get(), VG_FALSE, glyph_origin, glyph_escapement);
		advances[char_code] = glyph->advance.x;

		char_code = FT_Get_Next_Char(face, char_code, &glyph_index);


	return true;

int FontFileOVG::Outline_MoveTo(const FT_Vector *to, void *user)
	PathOVG *path = (PathOVG *)user;
	path->MoveTo(to->x, to->y);
	return 0;

int FontFileOVG::Outline_LineTo(const FT_Vector *to, void *user)
	PathOVG *path = (PathOVG *)user;
	path->LineTo(to->x, to->y);
	return 0;

int FontFileOVG::Outline_ConicTo(const FT_Vector *control, const FT_Vector *to, void *user)
	VGPath path = ((PathOVG *)user)->Get();
	VGubyte segments[1] = {VG_QUAD_TO_ABS};
	VGfloat coords[4] = {control->x, control->y, to->x, to->y};
	vgAppendPathData(path, 1, segments, coords);
	return 0;

int FontFileOVG::Outline_CubicTo(const FT_Vector* control1, const FT_Vector *control2, const FT_Vector* to, void *user)
	PathOVG *path = (PathOVG *)user;
	path->CubicTo(to->x, to->y, control1->x, control1->y, control2->x, control2->y);
	return 0;

Any tips on optimization from OpenVG experts are welcome!

It is now seamless with GDI+ as well.

Have you tried combining OpenVG with OpenGL? It may be desirable to apply shader effects on 2D objects via OpenGL ES 2.0. Any thoughts?