diff options
author | tradke <tradke@eff87b29-5268-4891-90a3-a07138403961> | 2000-10-25 17:18:03 +0000 |
---|---|---|
committer | tradke <tradke@eff87b29-5268-4891-90a3-a07138403961> | 2000-10-25 17:18:03 +0000 |
commit | f0442a0a3a79f05014d0ef36c2fa91896b9381bf (patch) | |
tree | 032db1c093ba5bc07369c6cf34d2a3cb1995d2d9 | |
parent | a461cee644e9241187e67ef9070284a2a049cb37 (diff) |
Avoid division by zero if minimum == maximum of slice to output.
git-svn-id: http://svn.cactuscode.org/arrangements/CactusIO/IOJpeg/trunk@25 eff87b29-5268-4891-90a3-a07138403961
-rw-r--r-- | src/JPEG.c | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -229,7 +229,17 @@ void AutoColorDataSlice(int nx,int ny, /* size of the image x & y */ int i,last; CCTK_REAL F=(CCTK_REAL)rdfac; /* cast to CCTK_REAL... don't know how the original worked at all without a cast */ for(i=0,last=nx*ny;i<last;i++,dataout+=3){ - CCTK_REAL f=bias-(*datain++ - min)/(max-min); + CCTK_REAL f; + + /* check for division by 0 */ + if (min == max) + { + f = bias; + } + else + { + f = bias-(*datain++ - min)/(max-min); + } /* f-=(max-min); zero-center it */ /* well it can't be less than 0 */ if(f>0){ |