From df24ee5347d75876b6999e99efa11656b348829c Mon Sep 17 00:00:00 2001 From: borisneubert Date: Sun, 18 May 2014 13:29:39 +0000 Subject: [PATCH] enabled GIF, PNG and JPG as background image formats, enabled relative font size changed and perl specials for font size in 02_RSS.pm git-svn-id: svn://svn.code.sf.net/p/fhem/code/trunk@5885 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/CHANGED | 3 ++ fhem/FHEM/02_RSS.pm | 84 +++++++++++++++++++++++++-------------------- 2 files changed, 49 insertions(+), 38 deletions(-) diff --git a/fhem/CHANGED b/fhem/CHANGED index 7e3e26b0f..2a48ab352 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -1,5 +1,8 @@ # Add changes at the top of the list. Keep it in ASCII, and 80-char wide. # Do not insert empty lines here, update check depends on it. + - feature: enabled GIF, PNG and JPG as background image formats, enabled + relative font size changed and perl specials for font size + in 02_RSS.pm - feature: YAMAHA_AVR: new set commands and readings for controlling the sound output behavior (Enhancer, DSP and straight output) and sleep timer. For details, see commandref. diff --git a/fhem/FHEM/02_RSS.pm b/fhem/FHEM/02_RSS.pm index 46469aba3..53e645ea1 100644 --- a/fhem/FHEM/02_RSS.pm +++ b/fhem/FHEM/02_RSS.pm @@ -66,26 +66,16 @@ RSS_readLayout($) { my $filename= $hash->{fhem}{filename}; my $name= $hash->{NAME}; - if(configDBUsed()) { - my @layout = cfgDB_FileRead($filename); - if(!(int(@layout))) { - $hash->{fhem}{layout}= ("text 0.1 0.1 'Layout definition not found in database!'"); - Log 1, "RSS $name: Layout $filename not found in database"; - } else { - $hash->{fhem}{layout} = join("\n", @layout); - } + my ($err, @layoutfile) = FileRead($filename); + if($err) { + Log 1, "RSS $name: $err"; + $hash->{fhem}{layout}= ("text 0.1 0.1 'Error: $err'"); } else { - if(open(LAYOUT, $filename)) { - my @layout= ; - $hash->{fhem}{layout}= join("", @layout); - close(LAYOUT); - } else { - $hash->{fhem}{layout}= (); - Log 1, "RSS $name: Cannot open $filename"; - } + $hash->{fhem}{layout}= join("\n", @layoutfile); + $hash->{fhem}{layout} =~ s/\n\n/\n/g; } + return; } - ################## sub @@ -493,7 +483,13 @@ RSS_evalLayout($$@) { } elsif($cmd eq "font") { $params{font}= $def; } elsif($cmd eq "pt") { - $params{pt}= $def; + $def= AnalyzePerlCommand(undef, $def); + if($def =~ m/^[+-]/) { + $params{pt} += $def; + } else { + $params{pt} = $def; + } + $params{pt} = 6 if($params{pt} < 0); } elsif($cmd eq "moveto") { my ($tox,$toy)= split('[ \t]+', $def, 2); my ($x,$y)= RSS_xy($S, $tox,$toy,%params); @@ -649,25 +645,33 @@ RSS_returnIMG($$) { if($bgnr > $#bgfiles) { $bgnr= 0; } $defs{$name}{fhem}{bgnr}= $bgnr; my $bgfile= $bgdir . "/" . $bgfiles[$bgnr]; - my $bg= newFromJpeg GD::Image($bgfile); - my ($bgwidth,$bgheight)= $bg->getBounds(); - if($bgwidth != $width or $bgheight != $height) { - # we need to resize - my ($w,$h); - my ($u,$v)= ($bgwidth/$width, $bgheight/$height); - if($u>$v) { - $w= $width; - $h= $bgheight/$u; - } else { - $h= $height; - $w= $bgwidth/$v; - } - $S->copyResized($bg,($width-$w)/2,($height-$h)/2,0,0,$w,$h,$bgwidth,$bgheight); + my $filetype =(split(/\./,$bgfile))[-1]; + my $bg; + $bg= newFromGif GD::Image($bgfile) if $filetype =~ m/^gif$/i; + $bg= newFromJpeg GD::Image($bgfile) if $filetype =~ m/^jpe?g$/i; + $bg= newFromPng GD::Image($bgfile) if $filetype =~ m/^png$/i; + if(defined($bg)) { + my ($bgwidth,$bgheight)= $bg->getBounds(); + if($bgwidth != $width or $bgheight != $height) { + # we need to resize + my ($w,$h); + my ($u,$v)= ($bgwidth/$width, $bgheight/$height); + if($u>$v) { + $w= $width; + $h= $bgheight/$u; + } else { + $h= $height; + $w= $bgwidth/$v; + } + $S->copyResized($bg,($width-$w)/2,($height-$h)/2,0,0,$w,$h,$bgwidth,$bgheight); + } else { + # size is as required + # kill the predefined image and take the original + $S= undef; + $S= $bg; + } } else { - # size is as required - # kill the predefined image and take the original - $S = undef; - $S= $bg; + $S= undef; } } } @@ -811,7 +815,8 @@ RSS_CGI(){