int write_bmp(d3_lattice *d3_l,int window,u32 x,u32 y,u32 z)
{
- int fd,i,j,size=0;
+ int fd,i,j,size=0,foo=0;
int width=0,height=0;
char bmpfile[MAX_CHARS];
char buf[128];
if(window==1)
{
sprintf(bmpfile,"x-z_%d.bmp",y);
- size=3*d3_l->max_x*d3_l->max_z;
+ foo=3*d3_l->max_x;
+ size=(foo+(4-foo%4))*d3_l->max_z;
width=d3_l->max_x;
height=d3_l->max_z;
}
if(window==2)
{
sprintf(bmpfile,"y-z_%d.bmp",x);
- size=3*d3_l->max_y*d3_l->max_z;
+ foo=3*d3_l->max_y;
+ size=(foo+(4-foo%4))*d3_l->max_z;
width=d3_l->max_y;
height=d3_l->max_z;
}
if(window==3)
{
sprintf(bmpfile,"x-y_%d.bmp",z);
- size=3*d3_l->max_x*d3_l->max_y;
+ foo=3*d3_l->max_x;
+ size=(foo+(4-foo%4))*d3_l->max_y;
width=d3_l->max_x;
height=d3_l->max_y;
}
return-1;
}
}
+ if(foo%4)
+ {
+ memset(buf,0,4-foo%4);
+ if(write(fd,buf,4-foo%4)<4-foo%4)
+ {
+ puts("failed writing 4 byte ending");
+ return -1;
+ }
+ }
}
}
if(window==2)
return-1;
}
}
+ if(foo%4)
+ {
+ memset(buf,0,4-foo%4);
+ if(write(fd,buf,4-foo%4)<4-foo%4)
+ {
+ puts("failed writing 4 byte ending");
+ return -1;
+ }
+ }
}
}
if(window==3)
return -1;
}
}
+ if(foo%4)
+ {
+ memset(buf,0,4-foo%4);
+ if(write(fd,buf,4-foo%4)<4-foo%4)
+ {
+ puts("failed writing 4 byte ending");
+ return -1;
+ }
+ }
}
}
close(fd);