Web UI for ARGUS server
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

92 lines
2.7 KiB

<?php
function interpolate( $color1, $color2, $progress) {
//$a1 = ($color1 & 0xff000000) >> 24;
$r1 = ($color1 & 0x00ff0000) >> 16;
$g1 = ($color1 & 0x0000ff00) >> 8;
$b1 = $color1 & 0x000000ff;
//$a2 = ($color2 & 0xff000000) >> 24;
$r2 = ($color2 & 0x00ff0000) >> 16;
$g2 = ($color2 & 0x0000ff00) >> 8;
$b2 = $color2 & 0x000000ff;
$k1 = log10( $progress );
$k2 = 1.0 - $k1;
//$newA = (int)($a1 * $k2 + $a2 * $k1);
$newR = (int)($r1 * $k2 + $r2 * $k1);
$newG = (int)($g1 * $k2 + $g2 * $k1);
$newB = (int)($b1 * $k2 + $b2 * $k1);
//return ($newA << 24) + ($newR << 16) + ($newG << 8) + $newB;
return ($newR << 16) + ($newG << 8) + $newB;
};
//*
$thumbnail = imagecreatetruecolor( 2304, 288);
if(!$thumbnail) {
die('Error when creating the destination image.');
};
//$filename = "storage/192.168.1.63_2222_draw_yard.raw";
$filename = "storage/192.168.1.63_2222_draw_field.raw";
$handle = fopen($filename, "rb");
$cx = 0;
$cy = 288;
$cc = 0.0;
$k = 1.0/409.60;
while( !feof( $handle ) ){
$data = fread( $handle, 4*2304 );
$stride = unpack ( "V*", $data );//, int $offset = 0 );
if( count($stride) == 2304 ){
for( $index = 0; $index< 2304; $index++ ){
$z = $k * ( ( $stride[$index+1] >> 12 ) & 0xFFF);
//$z = $k * ( $stride[$index+1] & 0xFFF);
$s = 1.0 - log10( $z );
$R = (int)(255 * $s);
$G = (int)(255 * $s);
$B = (int)(255 * $s);
$C = imagecolorclosest ( $thumbnail, $R, $G, $B);
imagesetpixel ( $thumbnail, $index, $cy , $C );
};
$cy--;
};
};
fclose( $handle );
//header("Content-Type: image/png");
imagepng( $thumbnail );
//*/
/*
$canvas = new Imagick();
$width = 2304;
$height = 288;
$canvas->newImage($width, $height, new ImagickPixel("black"));
$canvas->setImageFormat("png");
$filename = "storage/18May_test.raw";
$handle = fopen($filename, "rb");
$cy = 288;
$k = 1.0 / 4096.0;
while( !feof( $handle ) ){
$data = fread( $handle, 4*2304 );
$stride = unpack ( "V*", $data );//, int $offset = 0 );
if( count($stride) == 2304 ){
$iterator = $canvas->getPixelRegionIterator( 0, $cy, $width, 1);
$index = 0;
foreach( $iterator as $pixels ){
foreach( $pixels as $pixel ){
$a = interpolate( 0xFFFFFFFF, 0xFF00FF00, ( $k * ( $stride[$index+1] & 0xFFF )) );
$c = '#' . sprintf("%08x", $a );
//echo $cy . " " . $index . " " . $c . "\n";
$pixel->setColor( $c );
$index++;
};
$iterator->syncIterator();
};
$cy--;
};
};
fclose( $handle );
// header( 'Content-type: ' . $canvas->getFormat() );
echo $canvas->getimageblob();
*/
?>