X-Git-Url: https://hackdaworld.org/gitweb/?p=my-code%2Fapi.git;a=blobdiff_plain;f=bmp%2Fbmp.c;h=cc53c7cc6161463be4d96f3b471b32dfdf8fd2ea;hp=520b2838b061d3a6c9c04b2a14ac1effe557438b;hb=a21023e93104fb6e96b57afa23ab4628c8e5e055;hpb=577595e067a03be4d9bb9c7f1277047e7a6eb5de diff --git a/bmp/bmp.c b/bmp/bmp.c index 520b283..cc53c7c 100644 --- a/bmp/bmp.c +++ b/bmp/bmp.c @@ -138,7 +138,9 @@ int bmp_write_file(t_bmp *bmp) { return B_SUCCESS; } -int bmp_cut_bottom(t_bmp *dst,t_bmp *src,int dz) { +int bmp_cut_grab_bottom(t_bmp *dst,t_bmp *src,int dz,unsigned char m) { + + int off; dst->width=src->width; dst->height=dz; @@ -148,18 +150,13 @@ int bmp_cut_bottom(t_bmp *dst,t_bmp *src,int dz) { return B_E_GEOMETRY; } - /* obsolete - we point to wanted memory instead if(bmp_alloc_map(dst)!=B_SUCCESS) { dprintf(dst->outfd,"[bmp] no map memory\n"); return B_E_MEM; } - */ - /* obsolete - we point to wanted memory instead - memcpy(dst->map,src->map+(src->height-dz)*src->width, - dz*src->width*sizeof(t_pixel)); - */ - dst->map=src->map+(src->height-dz)*src->width; + off=(m==GRAB)?0:(src->height-dz)*src->width; + memcpy(dst->map,src->map+off,dz*src->width*sizeof(t_pixel)); return B_SUCCESS; }