readtif, writetif: simplify rounding
This commit is contained in:
parent
0fc3aa99a1
commit
171db68c3d
2 changed files with 3 additions and 11 deletions
|
@ -1574,7 +1574,6 @@ readfield(Tif *t, Fld *f)
|
||||||
static int
|
static int
|
||||||
checkfields(Tif *t)
|
checkfields(Tif *t)
|
||||||
{
|
{
|
||||||
double a, b;
|
|
||||||
ulong n, size;
|
ulong n, size;
|
||||||
|
|
||||||
if(t->dx == 0) {
|
if(t->dx == 0) {
|
||||||
|
@ -1647,9 +1646,7 @@ checkfields(Tif *t)
|
||||||
werrstr("rows per strip");
|
werrstr("rows per strip");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
a = (double)t->dy;
|
n = (t->dy + t->rows - 1) / t->rows;
|
||||||
b = (double)t->rows;
|
|
||||||
n = (ulong)floor((a+b-1)/b);
|
|
||||||
if(t->strips == nil || t->nstrips != n) {
|
if(t->strips == nil || t->nstrips != n) {
|
||||||
werrstr("strip offsets");
|
werrstr("strip offsets");
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -1041,19 +1041,14 @@ alloctif(Tif *t)
|
||||||
{
|
{
|
||||||
int rgb;
|
int rgb;
|
||||||
ulong i, count, n;
|
ulong i, count, n;
|
||||||
double a, b;
|
|
||||||
|
|
||||||
count = t->ndata < 0x2000? t->ndata: 0x2000;
|
count = t->ndata < 0x2000? t->ndata: 0x2000;
|
||||||
t->rows = count / t->bpl;
|
t->rows = (count + t->bpl - 1) / t->bpl;
|
||||||
if(count%t->bpl != 0)
|
|
||||||
t->rows++;
|
|
||||||
if(t->comp == Tt4enc && t->opt) {
|
if(t->comp == Tt4enc && t->opt) {
|
||||||
if((n = t->rows%Kpar) != 0)
|
if((n = t->rows%Kpar) != 0)
|
||||||
t->rows += Kpar - n;
|
t->rows += Kpar - n;
|
||||||
}
|
}
|
||||||
a = (double)t->dy;
|
t->nstrips = (t->dy + t->rows - 1) / t->rows;
|
||||||
b = (double)t->rows;
|
|
||||||
t->nstrips = (ulong)floor((a+b-1)/b);
|
|
||||||
t->strips = malloc(t->nstrips*sizeof *t->strips);
|
t->strips = malloc(t->nstrips*sizeof *t->strips);
|
||||||
if(t->strips == nil)
|
if(t->strips == nil)
|
||||||
return memerr;
|
return memerr;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue