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

6 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <?php
  2. function interpolate( $color1, $color2, $progress) {
  3. //$a1 = ($color1 & 0xff000000) >> 24;
  4. $r1 = ($color1 & 0x00ff0000) >> 16;
  5. $g1 = ($color1 & 0x0000ff00) >> 8;
  6. $b1 = $color1 & 0x000000ff;
  7. //$a2 = ($color2 & 0xff000000) >> 24;
  8. $r2 = ($color2 & 0x00ff0000) >> 16;
  9. $g2 = ($color2 & 0x0000ff00) >> 8;
  10. $b2 = $color2 & 0x000000ff;
  11. $k1 = log10( $progress );
  12. $k2 = 1.0 - $k1;
  13. //$newA = (int)($a1 * $k2 + $a2 * $k1);
  14. $newR = (int)($r1 * $k2 + $r2 * $k1);
  15. $newG = (int)($g1 * $k2 + $g2 * $k1);
  16. $newB = (int)($b1 * $k2 + $b2 * $k1);
  17. //return ($newA << 24) + ($newR << 16) + ($newG << 8) + $newB;
  18. return ($newR << 16) + ($newG << 8) + $newB;
  19. };
  20. //*
  21. $thumbnail = imagecreatetruecolor( 2304, 288);
  22. if(!$thumbnail) {
  23. die('Error when creating the destination image.');
  24. };
  25. //$filename = "storage/192.168.1.63_2222_draw_yard.raw";
  26. $filename = "storage/192.168.1.63_2222_draw_field.raw";
  27. $handle = fopen($filename, "rb");
  28. $cx = 0;
  29. $cy = 288;
  30. $cc = 0.0;
  31. $k = 1.0/409.60;
  32. while( !feof( $handle ) ){
  33. $data = fread( $handle, 4*2304 );
  34. $stride = unpack ( "V*", $data );//, int $offset = 0 );
  35. if( count($stride) == 2304 ){
  36. for( $index = 0; $index< 2304; $index++ ){
  37. $z = $k * ( ( $stride[$index+1] >> 12 ) & 0xFFF);
  38. //$z = $k * ( $stride[$index+1] & 0xFFF);
  39. $s = 1.0 - log10( $z );
  40. $R = (int)(255 * $s);
  41. $G = (int)(255 * $s);
  42. $B = (int)(255 * $s);
  43. $C = imagecolorclosest ( $thumbnail, $R, $G, $B);
  44. imagesetpixel ( $thumbnail, $index, $cy , $C );
  45. };
  46. $cy--;
  47. };
  48. };
  49. fclose( $handle );
  50. //header("Content-Type: image/png");
  51. imagepng( $thumbnail );
  52. //*/
  53. /*
  54. $canvas = new Imagick();
  55. $width = 2304;
  56. $height = 288;
  57. $canvas->newImage($width, $height, new ImagickPixel("black"));
  58. $canvas->setImageFormat("png");
  59. $filename = "storage/18May_test.raw";
  60. $handle = fopen($filename, "rb");
  61. $cy = 288;
  62. $k = 1.0 / 4096.0;
  63. while( !feof( $handle ) ){
  64. $data = fread( $handle, 4*2304 );
  65. $stride = unpack ( "V*", $data );//, int $offset = 0 );
  66. if( count($stride) == 2304 ){
  67. $iterator = $canvas->getPixelRegionIterator( 0, $cy, $width, 1);
  68. $index = 0;
  69. foreach( $iterator as $pixels ){
  70. foreach( $pixels as $pixel ){
  71. $a = interpolate( 0xFFFFFFFF, 0xFF00FF00, ( $k * ( $stride[$index+1] & 0xFFF )) );
  72. $c = '#' . sprintf("%08x", $a );
  73. //echo $cy . " " . $index . " " . $c . "\n";
  74. $pixel->setColor( $c );
  75. $index++;
  76. };
  77. $iterator->syncIterator();
  78. };
  79. $cy--;
  80. };
  81. };
  82. fclose( $handle );
  83. // header( 'Content-type: ' . $canvas->getFormat() );
  84. echo $canvas->getimageblob();
  85. */
  86. ?>