Hi, I’m trying to write a program that uses a picture from the user’s
files to generate a random jigsaw puzzle. For that I’m using Gtk+ for
the UI, and Cairo to uses png images as mask for creating the pieces. It
works well as long as the base picture is not too large. For what I
tested so far, it works for 750x600 pictures (that generate a 25x20 ->
500 pieces puzzle) or lower, but not for 1020x660 (748 pieces) or higher
poping up an alert message saying :
“GLib-ERROR gmem.c:165 failed to allocate xxx bytes”
with the xxx growing up when the base picture is larger.
I join my code, even if you couldn’t run it (because you don’t have the
png files for the pieces) if someone has some ideas to make it consume
less memory when generating the pieces, it will be great.
I also mentioned in it another problem I have when trying to make a
user-parametrable application (here is a lighten version, I have another
code on different files for the final application). I add to it a menu
bar where the user can choose “New Puzzle”, it opens a Dialog where he
can set the source picture, the framing for it, and other stuff not yet
implemented. But when I get the infos the user entered, the pieces are
created (i used a debug line to be sure of it) but I can’t set them
visible, I tried a show() in th constructor of the Piece class, I tried
to yield layout.show-all, window.show-all, nothing worked. I guess it’s
because the image widgets are created after the Gtk.main command, but
even if I yield it again, it doesn’t work, and it set another bug with
the interpreter not closing after destroying the window. Once again, if
anyone has an hint to solve this, it will be welcome.
Sorry for my pitiful english !