mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-21 08:01:30 -07:00
Support the generation of icons from uniformly-coloured screenshots
The square.pl script removed all pixels that were the same colour as the edge ones, even if that meant removing all of the pixels. Now it stops removing pixels at 1x1 so that there will be something left for ImageMagick to work on.
This commit is contained in:
@ -42,13 +42,13 @@ $back = $plist[0];
|
|||||||
# Crop rows and columns off the image to find the central rectangle
|
# Crop rows and columns off the image to find the central rectangle
|
||||||
# of non-background stuff.
|
# of non-background stuff.
|
||||||
$ystart = 0;
|
$ystart = 0;
|
||||||
$ystart++ while $ystart < $h and scalar(grep { $_ ne $back } map { $data->[$ystart*$w+$_] } 0 .. ($w-1)) == 0;
|
$ystart++ while $ystart < $h - 1 and scalar(grep { $_ ne $back } map { $data->[$ystart*$w+$_] } 0 .. ($w-1)) == 0;
|
||||||
$yend = $h-1;
|
$yend = $h-1;
|
||||||
$yend-- while $yend >= $ystart and scalar(grep { $_ ne $back } map { $data->[$yend*$w+$_] } 0 .. ($w-1)) == 0;
|
$yend-- while $yend > $ystart and scalar(grep { $_ ne $back } map { $data->[$yend*$w+$_] } 0 .. ($w-1)) == 0;
|
||||||
$xstart = 0;
|
$xstart = 0;
|
||||||
$xstart++ while $xstart < $w and scalar(grep { $_ ne $back } map { $data->[$_*$w+$xstart] } 0 .. ($h-1)) == 0;
|
$xstart++ while $xstart < $w - 1 and scalar(grep { $_ ne $back } map { $data->[$_*$w+$xstart] } 0 .. ($h-1)) == 0;
|
||||||
$xend = $w-1;
|
$xend = $w-1;
|
||||||
$xend-- while $xend >= $xstart and scalar(grep { $_ ne $back } map { $data->[$_*$w+$xend] } 0 .. ($h-1)) == 0;
|
$xend-- while $xend > $xstart and scalar(grep { $_ ne $back } map { $data->[$_*$w+$xend] } 0 .. ($h-1)) == 0;
|
||||||
|
|
||||||
# Decide how much border we're going to put back on to make the
|
# Decide how much border we're going to put back on to make the
|
||||||
# image perfectly square.
|
# image perfectly square.
|
||||||
|
Reference in New Issue
Block a user