summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOliver Schinagl <oliver@schinagl.nl>2005-04-05 16:09:50 (GMT)
committerOliver Schinagl <oliver@schinagl.nl>2005-04-05 16:09:50 (GMT)
commitb3bceeefd41d45662bf342a834a5163cb07fae51 (patch)
tree67b98cde95af2d27b23d22c5de23a59134ce1e86
parent5507227171e9212e57fab30d271b57e450442e61 (diff)
download5kk53-b3bceeefd41d45662bf342a834a5163cb07fae51.zip
5kk53-b3bceeefd41d45662bf342a834a5163cb07fae51.tar.gz
5kk53-b3bceeefd41d45662bf342a834a5163cb07fae51.tar.bz2
BMP file is opened and header is readed en the file is written in Image1 array
-rw-r--r--src/main.c75
1 files changed, 63 insertions, 12 deletions
diff --git a/src/main.c b/src/main.c
index 7e260da..39d5bfc 100644
--- a/src/main.c
+++ b/src/main.c
@@ -3,25 +3,76 @@
#define ENCODE 0
#define DECODE 1
+#define MAXROWS 1024
+#define MAXCOLS 768
-int main(int argc, char argv[]) {
- int retval;
+unsigned char Image1[MAXCOLS*3*MAXROWS];
+
+int main(int argc, char *argv[]) {
+ int retval, i;
int workspace[DCTSIZE_BLOCK];
int type;
+ int x, y, offset, depth;
+
char *fileIn, *fileOut;
FILE *fI, *fO;
+ unsigned char ch, mrgb[3];
+
+/* Just for testing on the PC */
+ if(argc != 4)
+ {
+ printf("need more arguments");
+ return 0;
+ }
+ type = atoi(argv[1]);
+ fileIn = argv[2];
+ fileOut = argv[3];
- fI = fopen(fileIn,"rb");
- if (fI == NULL) {
- printf("unable to open the file",fileIn);
- return 0;
- }
- fO = fopen(fileOut,"wb");
- if (fO == NULL) {
- printf("unable to open the file",fileOut);
- return 0;
- }
+ if (NULL == (fI = fopen(fileIn, "rb"))){
+ printf("unable to open the file to read from (%s)",fileIn);
+ return 0;
+ }
+ if ((fO = fopen(fileOut,"wb")) == NULL) {
+ printf("unable to open the file to write (%s)",fileOut);
+ return 0;
+ }
+
+ switch(type) {
+ case ENCODE:
+ fseek(fI, 10L, SEEK_SET);
+ fread(mrgb, 1, 4, fI);
+ offset = mrgb[3];
+ offset <<= 8;
+ offset += mrgb[2];
+ offset <<= 8;
+ offset += mrgb[1];
+ offset <<= 8;
+ offset += mrgb[0];
+
+
+ fseek(fI, 18L, SEEK_SET);
+ fread(mrgb, 1, 4, fI);
+ x = ((int)mrgb[3] << 24) + ((int)mrgb[2] << 16) + ((int)mrgb[1] << 8) + mrgb[0];
+ fseek(fI, 22L, SEEK_SET);
+ fread(mrgb, 1, 4, fI);
+ y = ((int)mrgb[3] << 24) + ((int)mrgb[2] << 16) + ((int)mrgb[1] << 8) + mrgb[0];
+ fseek(fI, 28L, SEEK_SET);
+ fread(mrgb, 1, 2, fI);
+ depth = ((int)mrgb[1] << 8) + mrgb[0];
+
+ printf("Image Resolution: %d x %d x %i \n", x, y, depth);
+
+ fseek(fI, offset, SEEK_SET);
+
+ fread(Image1, sizeof(unsigned char), (x*y*(depth/3)), fI);
+
+ break;
+ case DECODE:
+
+ break;
+ }
+/* End for just for testing on the PC */
retval = 0;