I´ve been asked how I create the datafile for CatanAid - so here is the code I used for CatanAid v. 0.1 (current version):
#!/usr/bin/perl use GD; use Tk; use MIME::Base64; open (DATA, ">graphicsdata"); foreach (<images/*>) { my $type = (split/\//, $_)[1]; foreach (<$_/*.gif>) { my $name = (split /\./,((split/\//, $_)[2]))[0]; print "Adding imagedata to datafile: $type/$name ($_).\n"; open (GIF, $_); $data = encode_base64((newFromGif GD::Image(GIF))->gif); close GIF; print DATA "<" . $type . "/" . $name . ">\n" . $data; } } close DATA;
The images are regular .gif images placed in a simple directory structure:
images/interface/expansionbutton.gif images/interface/background.gif images/interface/standardbutton.gif images/landscapes/mountain.gif images/landscapes/dessert.gif images/landscapes/forest.gif images/landscapes/hill.gif images/landscapes/pasture.gif images/landscapes/plain.gif images/landscapes/sea.gif images/ports/mountain.gif images/ports/forest.gif images/ports/hill.gif images/ports/surprise.gif images/ports/pasture.gif images/ports/plain.gif
Well... this should put at lid on this discussion i´ve been having with myself. :-)

Regards Søren Schimkat

In reply to Re: Re: Re: Re: Re: Re: TK::Photo -file -data by schimkat
in thread TK::Photo -file -data by schimkat

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.