Dohhh, I knew I would screw it up the first time. But no, I doubly screwed
it up. Read the rows from bottom to top rather than top to bottom and flipped row/col ...
This commit is contained in:
parent
c9757cb753
commit
7c3f6dd15d
2 changed files with 18 additions and 9 deletions
|
@ -2,17 +2,22 @@
|
||||||
|
|
||||||
use GD;
|
use GD;
|
||||||
|
|
||||||
$output = "picture.png";
|
$input = shift( @ARGV );
|
||||||
|
$output = shift( @ARGV );
|
||||||
|
|
||||||
|
print " < $input > $output\n";
|
||||||
|
|
||||||
# load data
|
# load data
|
||||||
$width = <>; chomp($width);
|
open( INPUT, "<$input" );
|
||||||
$height = <>; chomp($height);
|
$width = <INPUT>; chomp($width);
|
||||||
|
$height = <INPUT>; chomp($height);
|
||||||
$min = 9999;
|
$min = 9999;
|
||||||
$max = -9999;
|
$max = -9999;
|
||||||
|
|
||||||
for ( $i = 0; $i < $height; $i++ ) {
|
for ( $i = 0; $i < $height; $i++ ) {
|
||||||
|
print "$i ";
|
||||||
for ( $j = 0; $j < $width; $j++ ) {
|
for ( $j = 0; $j < $width; $j++ ) {
|
||||||
$d = <>; chomp($d);
|
$d = <INPUT>; chomp($d);
|
||||||
if ( $d < -9999 ) {
|
if ( $d < -9999 ) {
|
||||||
$d = 0;
|
$d = 0;
|
||||||
}
|
}
|
||||||
|
@ -22,9 +27,9 @@ for ( $i = 0; $i < $height; $i++ ) {
|
||||||
if ( $d > $max ) {
|
if ( $d > $max ) {
|
||||||
$max = $d;
|
$max = $d;
|
||||||
}
|
}
|
||||||
$data{ "$i:$j" } = $d;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
close(INPUT);
|
||||||
print "min = $min max = $max\n";
|
print "min = $min max = $max\n";
|
||||||
|
|
||||||
$im = new GD::Image( $width, $height );
|
$im = new GD::Image( $width, $height );
|
||||||
|
@ -37,10 +42,14 @@ for ( $i = 0; $i < 255; $i++ ) {
|
||||||
$red = $im->colorAllocate( 255, 10, 10 );
|
$red = $im->colorAllocate( 255, 10, 10 );
|
||||||
|
|
||||||
# draw image
|
# draw image
|
||||||
|
open( INPUT, "<$input" );
|
||||||
|
$width = <INPUT>; chomp($width);
|
||||||
|
$height = <INPUT>; chomp($height);
|
||||||
for ( $i = 0; $i < $height; $i++ ) {
|
for ( $i = 0; $i < $height; $i++ ) {
|
||||||
for ( $j = 0; $j < $width; $j++ ) {
|
for ( $j = 0; $j < $width; $j++ ) {
|
||||||
if ( $data{ "$i:$j" } > 0 ) {
|
$d = <INPUT>; chomp($d);
|
||||||
$level = 55 + int(200 * ( $data{ "$i:$j" } - $min ) / ( $max - $min ));
|
if ( $d > 0 ) {
|
||||||
|
$level = 55 + int(200 * ( $d - $min ) / ( $max - $min ));
|
||||||
} else {
|
} else {
|
||||||
$level = 0;
|
$level = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -133,9 +133,9 @@ TGHgt::load( ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
short int *var;
|
short int *var;
|
||||||
for ( int row = 0; row < size; ++row ) {
|
for ( int row = size - 1; row >= 0; --row ) {
|
||||||
for ( int col = 0; col < size; ++col ) {
|
for ( int col = 0; col < size; ++col ) {
|
||||||
var = &data[row][col];
|
var = &data[col][row];
|
||||||
if ( gzread ( fd, var, sizeof(short) ) != sizeof(short) ) {
|
if ( gzread ( fd, var, sizeof(short) ) != sizeof(short) ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue