mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-05-04 22:19:38 +00:00
optimization of background image creation
git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@2793 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
6e509ba68f
commit
b014230a71
@ -368,8 +368,9 @@ RSS_returnJPEG($) {
|
|||||||
#
|
#
|
||||||
# create the image
|
# create the image
|
||||||
#
|
#
|
||||||
my $S= GD::Image->newTrueColor($width,$height);
|
my $S;
|
||||||
$S->colorAllocate(0,0,0); # black is the background
|
# my $S= GD::Image->newTrueColor($width,$height);
|
||||||
|
# $S->colorAllocate(0,0,0); # black is the background
|
||||||
|
|
||||||
# wrap to make problems with GD non-lethal
|
# wrap to make problems with GD non-lethal
|
||||||
|
|
||||||
@ -410,6 +411,8 @@ 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();
|
||||||
|
if($bgwidth != $width or $bgheight != $height) {
|
||||||
|
# we need to resize
|
||||||
my ($w,$h);
|
my ($w,$h);
|
||||||
my ($u,$v)= ($bgwidth/$width, $bgheight/$height);
|
my ($u,$v)= ($bgwidth/$width, $bgheight/$height);
|
||||||
if($u>$v) {
|
if($u>$v) {
|
||||||
@ -419,7 +422,18 @@ RSS_returnJPEG($) {
|
|||||||
$h= $height;
|
$h= $height;
|
||||||
$w= $bgwidth/$v;
|
$w= $bgwidth/$v;
|
||||||
}
|
}
|
||||||
|
# create empty image
|
||||||
|
$S= GD::Image->newTrueColor($width,$height);
|
||||||
|
$S->colorAllocate(0,0,0); # black is the background
|
||||||
$S->copyResized($bg,($width-$w)/2,($height-$h)/2,0,0,$w,$h,$bgwidth,$bgheight);
|
$S->copyResized($bg,($width-$w)/2,($height-$h)/2,0,0,$w,$h,$bgwidth,$bgheight);
|
||||||
|
} else {
|
||||||
|
# size is as required, we take the original
|
||||||
|
$S= $bg;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
# no background, we create an empty background
|
||||||
|
$S= GD::Image->newTrueColor($width,$height);
|
||||||
|
$S->colorAllocate(0,0,0); # black is the background
|
||||||
}
|
}
|
||||||
SKIPBG:
|
SKIPBG:
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user