Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^2: Icon generation on the fly

by chessgui (Scribe)
on Jan 31, 2012 at 13:50 UTC ( [id://950972]=note: print w/replies, xml ) Need Help??


in reply to Re: Icon generation on the fly
in thread Icon generation on the fly

Thanks a lot but I'm incapable of building Gtk2. It may be possible but seems not to worth the effort as of yet. I would rather put something to work with the means easily accesible. With Imager suggested by Anonymous Monk I was able to put together this code:
use Imager; my $icon_width=128; my $icon_height=128; my $image = Imager->new(xsize => $icon_width, ysize => $icon_height); $image->box( xmin=>0, ymin=>0, xmax=>$icon_width-1, ymax => $icon_height-1, filled => 1, color => '#ffffff' ); my $font_filename = 'C:/Windows/Fonts/arialbd.ttf'; my $font = Imager::Font->new(file=>$font_filename) or die "Cannot loa +d $font_filename: ", Imager->errstr; print "Enter number: ";my $text=<>;chomp($text); my $text_size = 96; $font->align( string => $text, size => $text_size, color => '#000000', x => $image->getwidth/2, y => $image->getheight/2, halign => 'center', valign => 'center', image => $image ); $image->write(file=>'number.ico') or die 'Cannot save image: ', $image +->errstr;
It is a little bit weird (my be this is not the right font for this) but it works.

Replies are listed 'Best First'.
Re^3: Icon generation on the fly
by Khen1950fx (Canon) on Jan 31, 2012 at 19:31 UTC
    If you can't build Gtk2, then you could use SystemTray::Applet. It doesn't require Gtk2, and it doessn't require any specialized knowledge of the user's toolkit.
    #!/usr/bin/perl use strict; use warnings; use SystemTray::Applet; my $num = 10; my $applet = SystemTray::Applet->new( "text" => $num, "callback" => sub { my ($self) = @_; $self->{"text"} = $num; } );
      SystemTray::Applet can't be built in the legal way (it detects a circular dependency with SystemTray::Applet::Win32). If the module is built with force it prints '10' on STDOUT then freezes. If I build SystemTray::Applet::Win32 with force and use it instead of SystemTray::Applet it creates an empty icon in the system tray over which if I hover with the cursor it pops up a bubble saying '10'. I would rather like it to represent '10' in the tray permanently.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://950972]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (3)
As of 2024-04-19 19:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found