Beispiel #1
0
		public static byte[] Decode (byte[] pngData, out Size size, out PixelFormat pxFormat) {
			IntPtr p;
			int w, h;
			var error = LibLodePng.Decode32(out p, out w, out h, pngData, (IntPtr)pngData.Length);
			if (error != 0) {
				throw new ContentException("Failed to load png");
				//throw new ContentException ("Error decoding PNG: " + LibLodePng.ErrorText (error));
			}
			var buf = new byte[w * h * 4];
			Marshal.Copy(p, buf, 0, buf.Length);
			LibLodePng.Free(p);
			size = new Size(w, h);
			pxFormat = PixelFormat.Rgba;
			return buf;
		}
Beispiel #2
0
        private void GrabScreenshot2()
        {
            if (_image == null || _image.Width != this.Width || _image.Height != this.Height)
            {
                _image = new System.Drawing.Bitmap(ClientSize.Width, ClientSize.Height);
            }
            System.Drawing.Imaging.BitmapData data = _image.LockBits(this.ClientRectangle, System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
            //OpenTK.Graphics.OpenGL.GL.ReadPixels(0, 0, ClientSize.Width, ClientSize.Height, OpenTK.Graphics.PixelFormat.Bgr, OpenTK.Graphics.PixelType.UnsignedByte, data.Scan0)
            OpenTK.Graphics.OpenGL.PixelFormat pxFormat = OpenTK.Graphics.OpenGL.PixelFormat.Bgr;
            OpenTK.Graphics.OpenGL.PixelType   pxType   = OpenTK.Graphics.OpenGL.PixelType.UnsignedByte;

            OpenTK.Graphics.OpenGL.GL.ReadPixels(0, 0, ClientSize.Width, ClientSize.Height, pxFormat, pxType, data.Scan0);
            _image.UnlockBits(data);
            _image.RotateFlip(System.Drawing.RotateFlipType.RotateNoneFlipY);
        }
Beispiel #3
0
 public static void ClearNamedBufferSubData <T6>(UInt32 buffer, OpenTK.Graphics.OpenGL.ExtDirectStateAccess internalformat, OpenTK.Graphics.OpenGL.PixelFormat format, OpenTK.Graphics.OpenGL.PixelType type, IntPtr offset, IntPtr size, [InAttribute, OutAttribute] ref T6 data)
     where T6 : struct
 {
     ClearNamedBufferSubData(buffer, internalformat, offset, size, format, type, ref data);
 }
Beispiel #4
0
 public static void ClearNamedBufferSubData(UInt32 buffer, OpenTK.Graphics.OpenGL.ExtDirectStateAccess internalformat, OpenTK.Graphics.OpenGL.PixelFormat format, OpenTK.Graphics.OpenGL.PixelType type, IntPtr offset, IntPtr size, IntPtr data)
 {
     ClearNamedBufferSubData(buffer, internalformat, offset, size, format, type, data);
 }
Beispiel #5
0
		public static byte[] Decode (Stream stream, out Size size, out PixelFormat pxFormat) {
			var buf = new byte[stream.Length];
			stream.Read(buf, 0, buf.Length);
			stream.Close();
			return Decode(buf, out size, out pxFormat);
		}