1

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.

Alfa07
  • 3,314
  • 3
  • 26
  • 39

2 Answers2

1

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

ygrek
  • 6,656
  • 22
  • 29
0

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
  • 3,314
  • 3
  • 26
  • 39