I figured out myself. If anyone else wants to know:
public class WinUtil
{
public static bool ModifyWindowShape( System.Drawing.Bitmap bmp, Gtk.Window window )
{
bool ret = false;
try
{
//save bitmap to stream
System.IO.MemoryStream stream = new System.IO.MemoryStream();
bmp.Save( stream, System.Drawing.Imaging.ImageFormat.Png );
//verry important: put stream on position 0
stream.Position = 0;
//get the pixmap mask
Gdk.Pixbuf buf = new Gdk.Pixbuf( stream, bmp.Width, bmp.Height );
Gdk.Pixmap map1, map2;
buf.RenderPixmapAndMask( out map1, out map2, 255 );
//shape combine window
window.ShapeCombineMask( map2, 0, 0 );
//dispose
buf.Dispose();
map1.Dispose();
map2.Dispose();
bmp.Dispose();
//if evrything is ok return true;
ret = true;
}
catch(Exception ex)
{
Console.WriteLine( ex.Message + "\r\n" + ex.StackTrace );
}
return ret;
}
}
and in your window class add this:
using System.Drawing;
[...] // initialize your form code here, and then:
this.ShowAll();
Bitmap bmp = new Bitmap( 640, 480 );
Graphics g = Graphics.FromImage( bmp );
Brush b = new SolidBrush( Color.Red );
g.FillEllipse( b, 0,0,bmp.Width,bmp.Height );
g.Dispose();
WinUtil.ModifyWindowShape( bmp, this );
daniil00 wrote:
Hy guys,
Can you provide me with a code sample in making a non rectangular window in gtk?
With winforms it was easy using the Region property, but I can't find something similar in gtk.