mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-05-04 20:17:45 +00:00
preserve aspect ratio of background for 02_RSS.pm
git-svn-id: https://svn.fhem.de/fhem/trunk@1420 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
05f3ae5bb4
commit
5ec57bad19
@ -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:
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user