slloyd has asked for the wisdom of the Perl Monks concerning the following question:

I have seen several Win32 programs that use Win32::GUI::BitmapInline to include the bitmap in the code. My question is how do you create the inline code? Lets say I wanted to create a toolbar button for Bold, Underline, and Italic... how would I know what to put in the inline code so that it generates a B, U, and I for me? Is there a way to generate that code by passing in the letter I want to generate to some other subroutine?
use strict; use warnings; use Win32::GUI; use Win32::GUI::BitmapInline (); #This inline image is the number 1 as a button my $bmp = new Win32::GUI::BitmapInline( q( Qk0GAwAAAAAAADYAAAAoAAAAEAAAAA8AAAABABgAAAAAANACAADEDgAAxA4AAAAAAAAAAA +AAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////// +////// ////////////////////////////////////////////AAAAAAAA////////////////AA +AAAAAA AAAAAAAAAAAAAAAA////////////////AAAAAAAA////////////////////////AAAAAA +AA//// ////////////////////AAAAAAAA////////////////////////AAAAAAAA////////// +////// ////////AAAAAAAA////////////////////////AAAAAAAA////////////////////// +//AAAA AAAA////////////////////////AAAAAAAA////////////////////////AAAAAAAA// +////// ////////////////AAAAAAAA////////////////////////AAAAAAAA////////////// +////// ////AAAAAAAA////////////////////////AAAAAAAA////////////////////////AA +AAAAAA ////////////////////////AAAAAAAA////////////////AAAAAAAAAAAAAAAA////// +////// ////////////AAAAAAAA////////////////////AAAAAAAAAAAA////////////////// +////// AAAAAAAA////////////////////////AAAAAAAA////////////////////////AAAAAA +AA//// ////////////////////////////////////////////////////AAAAAAAAAAAAAAAAAA +AAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA ) );

Replies are listed 'Best First'.
Re: Using Win32::GUI::BitmapInline?
by ikegami (Patriarch) on Sep 13, 2005 at 14:10 UTC

    They're created from files, as the first two lines of the docs (other than the title) are:

    To create a BitmapInline:
    perl -MWin32::GUI::BitmapInline -e inline('image.bmp') >>script.pl

    You could create images of "B", "I" and "U" using Image::Magick (google for PerlMagick) which you could then convert, but it's not the most reliable module. I wouldn't count on your users to be able to run it. It's probably easier to create those letter by hand. It'll allow you to fit the letters properly and clean up details that would crowd the button.

    Updated: Originally, it seems I only read the first line of your question, so I added to my reply.

Re: Using Win32::GUI::BitmapInline?
by moot (Chaplain) on Sep 13, 2005 at 13:47 UTC

    This is a really bad idea for several reasons, not least of which is that if you wish to change the design of your buttons you are forced to release new code.

    Why do you want to embed images in your code in this way?

      I am not sure this is such a bad idea for two reasons:

    • Software is commonly released with 'resource files' that contain all of the images, sounds, language/locale specific information for the given client that is needed. If you release your code in a modular fashion you can simply send them an 'update' to give them new resource files
    • Images are embedded in e-mail now all of the time. Consider Base 64 Encode/Decode with OpenSSL for instance.

      Celebrate Intellectual Diversity

        • The OP didn't mention a resource file, with which I have no problem, he directly referred to embedding images in code, which is an entirely different kettle of wax.
        • What does embedding images in email have to do with embedding images in code?