X-Git-Url: https://hackdaworld.org/gitweb/?p=physik%2Fnlsop.git;a=blobdiff_plain;f=nlsop.c;h=ec8e4d32946cc5219f526237d73b7797dd93c3fa;hp=372af4ed7fa0b17e4d9d5d13547ff81cfbc77173;hb=385dd1d28c455f57ecdbdc61766607123a0c5063;hpb=9cf6b39411438c9113f573a7971fb1beebbcf30b diff --git a/nlsop.c b/nlsop.c index 372af4e..ec8e4d3 100644 --- a/nlsop.c +++ b/nlsop.c @@ -307,7 +307,7 @@ int calc_max_extra(d3_lattice *d3_l) 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]; @@ -315,21 +315,24 @@ int write_bmp(d3_lattice *d3_l,int window,u32 x,u32 y,u32 z) 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; } @@ -391,6 +394,15 @@ int write_bmp(d3_lattice *d3_l,int window,u32 x,u32 y,u32 z) 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) @@ -407,6 +419,15 @@ int write_bmp(d3_lattice *d3_l,int window,u32 x,u32 y,u32 z) 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) @@ -423,6 +444,15 @@ int write_bmp(d3_lattice *d3_l,int window,u32 x,u32 y,u32 z) 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);