コード例 #1
0
ファイル: graphicspath.c プロジェクト: WASSUM/longene_travel
GpStatus WINGDIPAPI GdipCreatePath2I(GDIPCONST GpPoint* points,
    GDIPCONST BYTE* types, INT count, GpFillMode fill, GpPath **path)
{
    GpPointF *ptF;
    GpStatus ret;
    INT i;

    ptF = GdipAlloc(sizeof(GpPointF)*count);

    for(i = 0;i < count; i++){
        ptF[i].X = (REAL)points[i].X;
        ptF[i].Y = (REAL)points[i].Y;
    }

    ret = GdipCreatePath2(ptF, types, count, fill, path);

    GdipFree(ptF);

    return ret;
}
コード例 #2
0
ファイル: region-path-tree.c プロジェクト: mono/libgdiplus
/*
 * gdip_region_deserialize_tree:
 * @data: a byte array
 * @size: the length of the byte array
 * @tree: a GpPathTree
 *
 * Recursively deserialize the @tree from the supplied buffer @data. Returns 
 * TRUE if the deserialization was possible, or FALSE if a problem was found
 * (e.g. @size mismatch, bad data...)
 */
BOOL
gdip_region_deserialize_tree (BYTE *data, int size, GpPathTree *tree)
{
	int len = sizeof (guint32);
	guint32 tag;

	memcpy (&tag, data, len);
	data += len;
	size -= len;

	switch (tag) {
	case REGION_TAG_PATH: {
		/* deserialize a path from the memory blob */
		guint32 count;
		FillMode mode;

		tree->mode = CombineModeReplace;
		tree->branch1 = NULL;
		tree->branch2 = NULL;
		/* count */
		memcpy (&count, data, len);
		data += len;
		size -= len;
		/* mode (FillMode, not CombineMode) */
		memcpy (&mode, data, len);
		data += len;
		size -= len;
		/* check that the size match the length of the type (byte) and 
		   GpPointF for the specified count */
		if (size == count + count * sizeof (GpPointF)) {
			BYTE* types = data;
			GpPointF *points = (GpPointF*) (data + count);
			return (GdipCreatePath2 (points, types, count, mode, &tree->path) == Ok);
		}
		return FALSE;
		}
		break;
	case REGION_TAG_TREE: {
		guint branch_size;
		tree->path = NULL;
		/* operation */
		memcpy (&tree->mode, data, len);
		data += len;
		size -= len;
		/* size (branch1) */
		memcpy (&branch_size, data, len);
		data += len;
		size -= len;
		/* deserialize a tree from the memory blob */
		tree->branch1 = (GpPathTree*) GdipAlloc (sizeof (GpPathTree));
		if (!tree->branch1)
			return FALSE;

		if (!gdip_region_deserialize_tree (data, branch_size, tree->branch1))
			return FALSE;
		data += branch_size;
		size -= branch_size;
		/* size (branch2) */
		memcpy (&branch_size, data, len);
		data += len;
		size -= len;
		tree->branch2 = (GpPathTree*) GdipAlloc (sizeof (GpPathTree));
		if (!tree->branch2)
			return FALSE;

		if (!gdip_region_deserialize_tree (data, branch_size, tree->branch2))
			return FALSE;
		}
		break;
	default:
		g_warning ("Invalid tag %d", tag);
		return FALSE;
	}
	return TRUE;
}