protected override void Load() { IntPtr hnd = VG.vgCreatePath(0, 3, 1, 0, 0, 0, 6); if (hnd == IntPtr.Zero) { throw new Exception("Error creating Path " + VG.vgGetError()); } handle = new Handle("OpenVG Path", hnd, delegate(IntPtr h) { VG.vgDestroyPath(h); }); List <byte> segments = new List <byte>(); List <float> data = new List <float>(); foreach (Segment s in source()) { segments.Add((byte)s.type); data.AddRange(s.data); } VG.vgAppendPathData(handle, segments.Count, segments.ToArray(), data.ToArray()); VG.DetectError("Unable to append path data"); }
protected override void Load() { if (handle != null) { return; } IntPtr hnd = VG.vgCreateImage(Format, (int)Size.x, (int)Size.y, ImageRenderQuality.Better | ImageRenderQuality.Faster); if (hnd == IntPtr.Zero) { throw new Exception("Error creating Image " + VG.vgGetError()); } handle = new Handle("OpenVG Image", hnd, delegate(IntPtr h) { VG.vgDestroyImage(h); }); if (DataSource != null) { byte[] data = DataSource(); SetImageData(data, data.Length / (int)Size.y, new Rect(Vector2.Zero, Size)); } }
public static object Get(Parameter p, IntPtr handle) { object[] attrs = typeof(Parameter).GetField(typeof(Parameter).GetEnumName(p)).GetCustomAttributes(typeof(ParameterInfoAttribute), false); ParameterInfoAttribute item; if (attrs.Length > 0) { item = (ParameterInfoAttribute)attrs[0]; } else { item = new ParameterInfoAttribute(ParameterAccessor.Int); } int size; object ret; switch (item.Access) { case ParameterAccessor.Int: if (handle == IntPtr.Zero) { ret = VG.vgGeti(p); } else { ret = VG.vgGeti(handle, p); } break; case ParameterAccessor.Float: if (handle == IntPtr.Zero) { ret = VG.vgGetf(p); } else { ret = VG.vgGetf(handle, p); } break; case ParameterAccessor.IntArray: if (handle == IntPtr.Zero) { size = VG.vgGetArraySize(p); } else { size = VG.vgGetArraySize(handle, p); } if (VG.vgGetError() == ErrorCode.NoError) { ret = new int[size]; if (size > 0) { if (handle == IntPtr.Zero) { VG.vgGet(p, size, (int[])ret); } else { VG.vgGet(handle, p, size, (int[])ret); } } } else { ret = null; } break; case ParameterAccessor.FloatArray: if (handle == IntPtr.Zero) { size = VG.vgGetArraySize(p); } else { size = VG.vgGetArraySize(handle, p); } if (VG.vgGetError() == ErrorCode.NoError) { ret = new float[size]; if (size > 0) { if (handle == IntPtr.Zero) { VG.vgGet(p, size, (float[])ret); } else { VG.vgGet(handle, p, size, (float[])ret); } } } else { ret = null; } break; default: return(null); } if (VG.vgGetError() != ErrorCode.NoError) { ret = null; } if (ret != null && ret.GetType() != item.Type) { if (item.Type.IsEnum) { ret = Enum.ToObject(item.Type, ret); } else { ret = Convert.ChangeType(ret, item.Type); } } return(ret); }