# Shape Combine Mask

**URL:** <https://www.ruby-forum.com/t/shape-combine-mask/183066>\
**Category:** Ruby-Gnome 2\
**Created:** [February 7, 2010, 1:36pm UTC](https://www.ruby-forum.com/t/shape-combine-mask/183066 "2010-02-07T13:36:06Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![xogue](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/ce73a5/32.png) [@xogue](https://www.ruby-forum.com/u/xogue)\
**Post date:** [February 7, 2010, 1:36pm UTC](https://www.ruby-forum.com/t/shape-combine-mask/183066/1 "2010-02-07T13:36:06Z")

</div>

I posted something a while back about custom shaped windows. now i know  
how to do it sort of. i can make a custom shaped window by using  
shape\_combine\_region on a Gdk::Window. problem is, that method is very  
tedious, it basically has me plotting several points on the widow grid  
to make a custom shape i want, here is the example:

`
require 'gtk2'
require 'win32/sound'
include Win32
include Gtk
region = Gdk::Region.new([[0, 0], [100, 50], [400, 50], [450, 0], [400,
100],
[400, 700], [450, 800], [400, 750], [50, 750], [0, 800], [50, 700],
[50, 100]], Gdk::Region::WINDING_RULE)
attribute = Gdk::WindowAttr.new(800, 800, Gdk::Window::INPUT_OUTPUT,
Gdk::Window::TOPLEVEL)
window = Gdk::Window.new(nil, attribute, Gdk::Window::WA_TITLE)
window.shape_combine_region(region, 5, 5)
window.show
main
`

this works fine, (if anyone runs this, i know the shape is still funny  
looking, im still playing with it.)

but i would like to use an image as the shape, there is a function to do  
so by using shape\_combine\_mask on the Gdk::Window. but it calls for a  
bitmap (pixmap, depth == 1) which they call a shape mask. i have tried  
making one. drawing random shapes in paint and gimp, even tried making  
the background transparent, as well as trying saving the files as bmp,  
xbm, and xpm.

`
require 'gtk2'
require 'win32/sound'
include Win32
include Gtk
white = Gdk::Color.new(0, 0, 0)
black = Gdk::Color.new(65000, 65000, 65000)
pixmap = Gdk::Pixmap.create_from_data(nil, “XFolders/RF/circle.xbm”,
200, 200)
attribute = Gdk::WindowAttr.new(500, 500, Gdk::Window::INPUT_OUTPUT,
Gdk::Window::TOPLEVEL)
window = Gdk::Window.new(nil, attribute, Gdk::Window::WA_TITLE)
window.shape_combine_mask(pixmap, 5, 5)
#window.add()
window.show
main
`

the colors are there because the “pixmap =  
Gdk::Pixmap.create\_from\_data(nil, “XFolders/RF/circle.xbm”, 200, 200)”  
command has optional arguments for the fg and bg, and i was playing with  
them a bit. this runs, but the output is hard to explain, but i will  
try. its like a channel on your tv that is purely static, and the black  
dots are part of the window and and the white parts are transparent and  
you can click on whatever is behind the window. like i said hard to  
expplain. would be easier if you tried to run it and see what happens,  
hopefully you can recreate the issue.

any help is appreciated, thanks in advance.

```
X
```
