views:

138

answers:

2

Is it possible to make a copy of Gdk.image object using lablgtk2 for Ocaml? I tried to find 'copy' or 'clone' methods but failed.

+1  A: 

Maybe you could use pixbuf? It can be created from any drawable.

ygrek
A: 

Here is my clumsy workaround:

let copy_image image =

    let w, h = Image.width image, Image.height image in 

    let copy = Image.create ~kind: `FASTEST ~visual: (Image.get_visual image) 

  ~width: w 

  ~height: h in

    for x = 0 to w-1 do

        for y = 0 to h-1 do

            Image.put_pixel copy ~x:x ~y:y (Image.get_pixel image ~x:x ~y:y)

        done

    done;
    copy
Alfa07
although pixbuf variant is also clumsy :(
Alfa07