preserve aspect ratio of background for 02_RSS.pm
git-svn-id: https://fhem.svn.sourceforge.net/svnroot/fhem/trunk/fhem@1420 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
@@ -311,6 +311,8 @@ RSS_returnJPEG($) {
|
|||||||
$defs{$name}{fhem}{counter}= 1;
|
$defs{$name}{fhem}{counter}= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# true color
|
||||||
|
GD::Image->trueColor(1);
|
||||||
|
|
||||||
#
|
#
|
||||||
# create the image
|
# create the image
|
||||||
@@ -353,7 +355,16 @@ RSS_returnJPEG($) {
|
|||||||
my $bgfile= $bgdir . "/" . $bgfiles[$bgnr];
|
my $bgfile= $bgdir . "/" . $bgfiles[$bgnr];
|
||||||
my $bg= newFromJpeg GD::Image($bgfile);
|
my $bg= newFromJpeg GD::Image($bgfile);
|
||||||
my ($bgwidth,$bgheight)= $bg->getBounds();
|
my ($bgwidth,$bgheight)= $bg->getBounds();
|
||||||
$S->copyResized($bg,0,0,0,0,$width,$height,$bgwidth,$bgheight);
|
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);
|
||||||
}
|
}
|
||||||
SKIPBG:
|
SKIPBG:
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user