From: hackbard Date: Mon, 2 Aug 2004 15:42:18 +0000 (+0000) Subject: more work on ft.* X-Git-Url: https://hackdaworld.org/gitweb/?a=commitdiff_plain;h=ffb92a5c75527b3d158d3811c56b3ff33b3ee832;p=physik%2Fnlsop.git more work on ft.* --- diff --git a/ft.c b/ft.c index 0bef018..e997b7f 100644 --- a/ft.c +++ b/ft.c @@ -9,28 +9,35 @@ int usage(void) { puts("usage:"); - puts("ft -i -o -itype -otype -d -g -debug "); + puts("ft -ifile -ofile -itype "); + puts(" -otype -dim "); + puts(" -geometry -debug "); puts(""); - puts("i/o type may be bmp or nlsop"); + puts("itype may be bmp or nlsop"); + puts("otype may be bmp or plot"); puts("dimensions: 2 or 3"); - puts("geometry in 2d: , eg: 64 32 0 80 (64x32 big area starting from (0|80)"); - puts("geometry in 3d: , eg: 64 64 32 0 0 80 (the same in 3 dimensions ^)"); + puts("geometry in 2d: "); + puts(" eg: 64 32 0 80 (64x32 big area starting from (0|80)"); + puts("geometry in 3d: "); + puts(" eg: 64 64 32 0 0 80 (the same in 3 dimensions ^)"); puts(""); puts("you must set -dimensions before specifying -geometry"); puts("default: dimension = 2 , resolution = whole image"); + puts("only 2 dimensions allowed for bmp"); return 1; } -int get_size_of_infile(int fd,int *res,unigned char set) { +int get_size_of_infile(int fd,int *res,unsigned char set) { if(set&SET_IN_BMP) { unsigned char buf[BMP_HEADER_LEN]; - puts("reading bmp header ..."); + printf("reading bmp header ..."); read(fd,buf,BMP_HEADER_LEN); res[0]=buf[18]|(buf[19]<<8); res[1]=buf[22]|(buf[23]<<8); + printf(" done\n"); return ((int)buf[10]); } @@ -54,30 +61,128 @@ int get_size_of_infile(int fd,int *res,unigned char set) { int get_infile_data(int fd,int offset,int *RES,int *res,int *x,unsigned char *orig,unsigned char set) { - int i,j,k,w_len; + int i,j,k,w_len,test; unsigned char *buf; - lseek(fd,offset,SEEK_SET); + test=lseek(fd,offset,SEEK_SET); + + printf("getting data at offset %d ...",test); if(set&SET_IN_BMP) { + w_len=3*RES[1]; - w_len+=(4-w_len%4); + if(w_len%4) w_len+=(4-(w_len%4)); lseek(fd,x[1]*w_len,SEEK_CUR); - buf=(unsigned char)malloc(w_len); + buf=(unsigned char *)malloc(w_len); for(j=0;j>8; + memset(buf+4,0,6); + buf[10]=0x36; /* offset to data */ + memset(buf+11,0,3); + buf[14]=0x28; /* length of bmp info header */ + memset(buf+15,0,3); + buf[18]=res[0]&0xff; /* width and height */ + buf[19]=res[0]>>8; + memset(buf+20,0,2); + buf[22]=res[1]&0xff; + buf[23]=res[1]>>8; + memset(buf+24,0,2); + buf[26]=1; /* # planes -> 1 */ + buf[27]=0; + buf[28]=24; /* bits per pixel -> 2^24 (true color) */ + buf[29]=0; + memset(buf+30,0,4); /* compression -> none */ + buf[34]=size&0xff; /* data size */ + buf[35]=size>>8; + memset(buf+36,0,2); + buf[38]=0x12; /* res: pixel/meter */ + buf[39]=0x0b; + memset(buf+40,0,2); + buf[42]=0x12; + buf[43]=0x0b; + memset(buf+44,0,2); + memset(buf+46,0,8); /* no colors, no important colors */ + /* write it */ + write(fd,buf,54); + + for(j=0;j +#include +#include +#include +#include +#include +#include +#include + #include "dfbapi.h" #include "nlsop.h" @@ -12,8 +22,8 @@ #define SET_OUT_BMP (1<<3) #define SET_IN_BMP (1<<4) #define SET_IN_NLSOP (1<<5) -#define SET_OUT_NLSOP (1<<6) -#define SET_3d (1<<7) +#define SET_OUT_PLOT (1<<6) +#define SET_3D (1<<7) #define BMP (1<<0) #define NLSOP (1<<1)