コード例 #1
0
 /// <summary>
 /// Draw this image to the current OpenVG drawing surface.
 /// </summary>
 public void Draw()
 {
     if (handle == null)
     {
         throw new ObjectDisposedException("Some Image");
     }
     VG.vgDrawImage(handle);
     VG.DetectError("Draw Image failed");
     draws.Add(1.0);
 }
コード例 #2
0
 internal void Draw()
 {
     if (handle == null)
     {
         throw new ObjectDisposedException("Some Path");
     }
     VG.vgDrawPath(handle);
     VG.DetectError("Draw Path failed");
     draws.Add(1.0);
 }
コード例 #3
0
        /// <summary>
        /// Sets the image contents
        /// </summary>
        /// <param name="data">The pixel data</param>
        /// <param name="scanlinestride">Offset for consecutive scan lines of the image in data.</param>
        /// <param name="destination">The rectangle of the image to fill</param>
        /// <remarks>
        /// The pixels should be packed into data with the pixel format used to construct this image.
        /// There is no offset between pixels on a line. Consecutive lines are placed at scanlinestride intervals, measured
        /// from line start to line start.
        /// </remarks>
        public void SetImageData(byte[] data, int scanlinestride, Rect destination)
        {
            if (handle == null)
            {
                throw new ObjectDisposedException("Some Image");
            }

            int lastbyte = (scanlinestride * ((int)destination.size.y - 1)) + (int)destination.size.x;

            if (data == null || lastbyte < 0 || data.Length < lastbyte)
            {
                throw new ArgumentException("Expected " + lastbyte + " bytes, got " + (data == null ? "null" : data.Length.ToString()));
            }
            VG.vgImageSubData(handle, data, scanlinestride, Format, destination.pos.x, destination.pos.y, destination.size.x, destination.size.y);
            VG.DetectError("Set image data failed");
        }
コード例 #4
0
        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");
        }