<?php
function isImageEmpty( $image, $width = null, $height = null, $startx = 0, $starty = 0 )
{
if( !$width )
$width = imagesx( $image );
if( !$height )
$height = imagesy( $image );
$empty = true;
for( $x = $startx; $x <= $width; $x++ )
{
for( $y = $starty; $y <= $height; $y++ )
{
$rgba = imagecolorat( $image, $x, $y );
$r = ($rgb >> 16) & 0xFF;
$g = ($rgb >> 8) & 0xFF;
$b = $rgb & 0xFF;
$a = ($rgba & 0x7F000000) >> 24;
if( $a < 0xFF )
{
$empty = false;
$x = $y = max($width, $height)+1; //taki break :D
}
}
}
}
//$x - jest to iloraz szerokości obrazka i szerokości bloku
//$y - analogicznie
function isBlockEmpty( $image, $x, $y, $a = 49 )
{
return isImageEmpty( $image, $x * $a + $a, $y * $a + $a, $x * $a, $y * $a );
}
//sam sobie pozamieniaj wartość 49
//pamiętaj, że masz na swoim obrazku w pizdu syfu, który będzie przeszkadzał (margines i linie), jeśli koniecznie chcesz z tym liniami, to sobie sam dorób zią!
//nie sprawdzane