public static Bitmap BitmapFromPixbuf( Gdk.Pixbuf pixbuf )
 {
     //save bitmap to stream
     byte[] bytes = pixbuf.SaveToBuffer( "png" );
     System.IO.MemoryStream stream = new System.IO.MemoryStream( bytes );
     //verry important: put stream on position 0
     stream.Position     = 0;
     //get the pixmap mask
     Bitmap bmp = new Bitmap( stream );
     return bmp;
 }
示例#2
0
 public static byte[] GetBytes(Gdk.Pixbuf pixbuf)
 {
     try
     {
         return pixbuf.SaveToBuffer("png");
     }
     catch
     {
         return null;
     }
 }
示例#3
0
文件: DftUtil.cs 项目: whztt07/DGLE
        public static void Write(this BinaryWriter file, Gdk.Pixbuf pixbuf)
        {
            byte[] buf = pixbuf.SaveToBuffer("bmp");

            for (int i = 1; i <= pixbuf.Height; ++i)
                for (int j = 0; j < pixbuf.Width; ++j)
                {
                    int pos = buf.Length - i * pixbuf.Width * 3 + j * 3;
                    byte data = (byte)(((int)buf[pos + 0] + (int)buf[pos + 1] + (int)buf[pos + 2]) / 3);
                    file.Write(data);
                }
        }
示例#4
0
        public static void Write(BinaryWriter file, Gdk.Pixbuf pixbuf)
        {
            byte[] buf = pixbuf.SaveToBuffer ("bmp");
            // skip header
            for (int i = 54; i < buf.Length; i += 3) {
                byte r, g, b;
                r = buf[i + 0];
                g = buf[i + 1];
                b = buf[i + 2];

                byte data = (byte)(((int)r + (int)g + (int)b) / 3);
                file.Write (data);
            }
        }
示例#5
0
 public BitmapImpl(Gdk.Pixbuf pixbuf)
     :base(pixbuf.SaveToBuffer("png"))
 {
 }