1
0
Fork 0

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:
curt 2003-03-11 20:21:30 +00:00
parent c9757cb753
commit 7c3f6dd15d
2 changed files with 18 additions and 9 deletions

View file

@ -2,17 +2,22 @@
use GD;
$output = "picture.png";
$input = shift( @ARGV );
$output = shift( @ARGV );
print " < $input > $output\n";
# load data
$width = <>; chomp($width);
$height = <>; chomp($height);
open( INPUT, "<$input" );
$width = <INPUT>; chomp($width);
$height = <INPUT>; chomp($height);
$min = 9999;
$max = -9999;
for ( $i = 0; $i < $height; $i++ ) {
print "$i ";
for ( $j = 0; $j < $width; $j++ ) {
$d = <>; chomp($d);
$d = <INPUT>; chomp($d);
if ( $d < -9999 ) {
$d = 0;
}
@ -22,9 +27,9 @@ for ( $i = 0; $i < $height; $i++ ) {
if ( $d > $max ) {
$max = $d;
}
$data{ "$i:$j" } = $d;
}
}
close(INPUT);
print "min = $min max = $max\n";
$im = new GD::Image( $width, $height );
@ -37,10 +42,14 @@ for ( $i = 0; $i < 255; $i++ ) {
$red = $im->colorAllocate( 255, 10, 10 );
# draw image
open( INPUT, "<$input" );
$width = <INPUT>; chomp($width);
$height = <INPUT>; chomp($height);
for ( $i = 0; $i < $height; $i++ ) {
for ( $j = 0; $j < $width; $j++ ) {
if ( $data{ "$i:$j" } > 0 ) {
$level = 55 + int(200 * ( $data{ "$i:$j" } - $min ) / ( $max - $min ));
$d = <INPUT>; chomp($d);
if ( $d > 0 ) {
$level = 55 + int(200 * ( $d - $min ) / ( $max - $min ));
} else {
$level = 0;
}

View file

@ -133,9 +133,9 @@ TGHgt::load( ) {
}
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 ) {
var = &data[row][col];
var = &data[col][row];
if ( gzread ( fd, var, sizeof(short) ) != sizeof(short) ) {
return false;
}