C Board  

Go Back   C Board > General Programming Boards > C Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 04-04-2005, 03:51 AM   #1
Registered User
 
Join Date: Jan 2005
Posts: 25
Errors

Been codeing all night can't seem to find the errors in this code. I expect they are obvious but can't see them with tired eyes. Using gcc for Cygwin as complier

Code:
/* This is a program that reads the header and colour table from a .bmp file */
/* to see if data has been hidden with STools.				     */
/* It does this by looking for duplication in the colour table		     */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>

typedef _bmp_header {
	char ID[2]
	int size;
	char res1[2], res2[2];
	int offset;
} bmp_header;

typedef struct _bmp_info {
	int size, width, height;
	int planes, BitsPerPixel;
	int compress, BMsize;
	int Hres, Vres;
	int CloursUsed, ColoursImportant;
} bmp_info;

/* Prototypes */
void load_bmp_header(FILE *BMP bmp_header *BH);
void load_bmp_info(FILE *BMP bmp_info *BI);

int main(int argc, char* argv[]) {
	int i,j,i1;
	int Dflag, Cflag, BMPsize, num_colours, dup_colours;
	FILE *BMPin;
	unsigned char_cloour_map[1024];
	bmp_header BMPHead;
	bmp_info BMPInfo;

/* Intialisation */
Dflag = 0;
Cflag = 0;

if(argc < 2) {
	fprintf(stderr, "Error: No bmp file\n");
	fprintf(sderr, "Usage SDetect [-d -c] bmp_file\n");
	fprintf(stderr, " -d gives file details\n -c prints out colour map");
	exit(1);
}

/* Look fo command-line flags */
for (i=1; i<(argc-1); i++) {
	if (argv[i][0] == '-') {
		switch (argv[i][1] {
		case 'h':
	printf("Usage: SDetect [-d -c] bmp_file\n");
	printf(" -d gives file details\n -c prints out colour map");
	exit(1);
	break
		case 'c':
	Cflag = 1;
	break;
		case 'd':
	Dflag = 1;
	break;
		default:
	printf("Error: Unknown switch %s\n, argv[i]);
	printf(sderr, "Usage SDetect [-d -c] bmp_file\n");
	printf(stderr, " -d gives file details\n -c prints out colour map");
	exit(1);
	break;
		}
	}
}

BMPin = fopen(argv[argc-1], "rb");
if(BMPin ==0) {
	fprintf(stderr, "**Error** Unable to open input file%s\n", argv[argc-1]);
	exit(1);
}
fseek(BMPin, 0, 0);

load_bmp_header(BMPin, &BMPHead);
load_bmp_info(Bmpin, &BMPInfo);

/* Calculate number of colours in palette */
num_colours = (BMPHead.offset - 14 - BMPInfo.size)/4;

fread(colour_map, 1 BMPInfo.ColoursUsed*4, BMPin);

/* Find duplicat colours */
dup_colour = 0;
for(i=0; i<BMPInfo.ColoursUsed; i++) {
	for(J=0; J<BMPiNFO.ColoursUsed; j++) {
		i1 =abs(colour_map[4*i] - colour_map[4*j]) +
			abs(colour_map[4*i+1] - colour_map[4*j+1]) +
			abs(colour_map [4*i+2] - colour_map[4*j+2]);
		if((i1<4) && (i !=j)) { dup_colour++; }
	}
}

if(Cflag) {
	/* print out colour map */
	printf("Colour Map:\n");
	for(i=0; i<BMPInfo.ColoursUsed; i++) {
		printf(" %3d %3d %3d %3d %3d\n", i,
			colour_map[4*i], colour_map[4*i+1],
			colour_map[4*i+2], colour_map[4*i+3]);
	}
}
fseek(BMPin, BMPHead.offset, 0);

printf(File Name: %s\n", argv[argc-1];
if(Dflag) {
	printf(Width: 		%d Height:		%d/n",
		BMPInfo.width, BMPInfo.height);
	printf("BitsPerPixel: 	%d NumBitPlanes:	%d/n",
		BMPInfo.BitsPerPixel, BMPInfo.planes);
	printf("Compression: %d\n", BMPInfo.compress);
	printf("Colours Used: %d	Colours Important: %d\n\n", 
		BMPInfo.ColoursUsed, BMPInfo.ColoursImportant);

	printf("actual size: %d	Reported: %d\n",
		BMPsize, BMPHead.size);
	printf("Duplicate colours: %d\n", dup_colour);
	printf("File header: Bytes 0 - 13\n")
	printf("Bitmap header: Bytes 14 - %3d/n", 13+BMPInfo.size);
	printf("Colour map: Bytes %3d - %3d\n",
		14+BMPInfo.size, 13+BMPInfo.size+4*BMPInfo.ColoursUsed);
	printf(Image data: Bytes %3d - %3d\n\n", BMPHead.offset,
		BMPHead.offset-1+		
		(BMPInfo.width*BMPInfo.height*BMPInfo.BitsPerPixel+7)/8);
}

if(dup_colour < 100) printf("Data has NOT been hidden in this file with STools");
if(dup_colour >= 100) printf(*** Data HAS BEEN HIDDEN in this file with STools ***")
printf("\n\n");

fclose(BMPin);
}

void load_bmp_header(FILE *BMP, bmp_header *BH) {
	unsigned char buffer[16];
	
	memset(BH, 0, sizeof(bmp_header));
	fread(buffer, 1, 14, BMP);

	memcpy(BH->ID, buffer, 2)
	if ((BH->ID[0] != 'B') || (BH->ID[1] != 'M')) {
		printf("Error: Bad file ID - not a BMP file\n");
		exit(1);
	}
	memcpy(&(BH->SIZE), buffer+2, 4);
	memcpy(BH->res1, buffer+6, 2);	
	memcpy(BH->res2, buffer+8, 2);
	memcpy(&(BH->offset), buffer+10, 4);
}

void load_bmp_info(FILE *BMP, bmp_info *BI) {
	unsigned char buffer[112];
	
	memset(BI, 0 sizeof(bmp_info));
	fread(buffer, 1, 108, BMP);

	memcpy(&(BI->size), buffer, 4);
	if((BI->size != 40) && (BI-> !=108)) {
		printf(BitmapInfo header size is %d - cannot handle this format\n",BI->size);
		exit(1)
	}

/* Reset position to beginning of colour table */

if(BI->size ==40) { fseek(BMP, -68, 1); }
	
	memcpy(&(BI->width), buffer+4, 4);
	memcpy(&(BI->height), buffer+8, 4);
	BI->planes = buffer[12]+256*buffer[13];
	BI->BitsPerPixel = buffer[14]+256*buffer[15];

	memcpy(&(BI->compress), buffer+16, 4);
	memcpy(&(BI->BMsize), buffer+20, 4);
	memcpy(&(BI->Hres), buffer+24, 4);
	memcpy(&(BI->Vres), buffer+28, 4);
	memcpy(&(BI->ColoursUsed), buffer+32, 4);
	memcpy(&(BI->ColoursImportant), buffer+36, 4);

if(BI->ColoursUsed ==0){
	BI->ColoursUsed = 1<< BI->BitsPerPixel;
Rhidian is offline   Reply With Quote
Old 04-04-2005, 04:17 AM   #2
Registered User
 
Join Date: Sep 2004
Posts: 720
how about you fix the code your self - i saw like 12 syntax errors just as i was scrolling past your code. just go to the line number of the errors. i'm not going to sit here and close your functions, open your literals, and correct your if()'s
__________________
Quote:
i seem to have GCC 3.3.4
But how do i start it?
I dont have a menu for it or anything.
misplaced is offline   Reply With Quote
Old 04-04-2005, 05:02 AM   #3
Registered User
 
Join Date: Apr 2004
Posts: 171
While your at it, can you make the indentations better - it'll be easier to read.
0rion is offline   Reply With Quote
Old 04-04-2005, 06:48 AM   #4
Registered User
 
Join Date: Jan 2005
Posts: 25
Sorry about the standard of the last code this is a cleaned up version still has some error in it though.


Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>

typedef struct _bmp_header 
{
  char ID[2];
  int size;
  char res1[2], res2[2];
  int offset;
} bmp_header;

typedef struct _bmp_info 
{
  int size, width, height;
  int planes, BitsPerPixel;
  int compress, BMsize;
  int Hres, Vres;
  int ColorsUsed, ColorsImportant;
} bmp_info;

void load_bmp_header(FILE *BMP, bmp_header *BH);
void load_bmp_info(FILE *BMP, bmp_info *BI);

int  main(int argc, char* argv[])
{
  int i,j,i1;
  int Dflag, Cflag, BMPsize, num_colors, dup_colors;
  FILE *BMPin;
  unsigned char color_map[1024];
  bmp_header BMPHead;
  bmp_info BMPInfo;

  Dflag =0;
  Cflag =0;

  if(argc<2)
  {
    fprintf(stderr, "ERROR: No bmp file\n");
    fprintf(stderr, "Usage: SDetect [-d -c] bmp_file\n");
    fprintf(stderr, "-d gives file details\n -c print out color map\n");
    exit(1);
  }

  for (i=1; i<(argc-1); i++)
  {
    if(argv[i][0] == '1')
    {
      switch (argv[i][1]
      {
    case 'h':
      printf("Usage: SDetect [-d -c] bmp_file\n");
      printf("-d gives file details\n -c prints out color map\n");
      exit(1);
      break;
    case 'c':
      Cflag =1;
      break;
    case 'd':
      Dflag =1;
      break;
    default:
      printf("ERROR: Unkown switch %s\n", argv[i]);
      printf("Usage: SDetect [-d -c] bmp_file\n");
      printf("-d gives file details\n -c prints out color map\n");
      exit(1);
      break;
      }
	      
    }
  }

    BMPin = fopen(argv[argc-1], "rb");
    if (BMPin ==0)
    {
      fprintf(stderr, "**Error** Unable to open input file %s\n", argv[argc-1]);
      exit(1);
    }
    fseek(BMPin, 0, 2);
    BMPsize = ftell(BMPin);
    fseek(BMPin, 0, 0);

    load_bmp_header(BMPin, &BMPHead);
    load_bmp_info(BMPin, &BMPInfo);

    num_colors = (BMPHead.offset - 14 - BMPinfo,size)/4;
    fread(color_map, 1, BMPInfo.ColorsUsed*4, BMPin);

    dup_color = 0;
    for(i=0; i<BMPInfo.ColorsUsed; i++)
    {
      for(j=0; j<BMPinfo.ColorsUsed; j++)
      {
	i1 = abs(color_map[4*i] - color_map[4*j]) + 
	  abs(color_map[4*i+1] - color_map[4*j+1]) +
	  abs(color_map[48i+2] - color_map[4*j+2]);
	if((i1<4) && (i !=j)) 
	{
	  dup_color++;
	}
      }
    }

    if(Cflag) 
    {
      printf("Color Map:\n");
      for(i=0; i<BMPInfo.ColorsUsed; i++)
      {
	printf("%3d %3d %3d %3d %3d\n", i, color_map[4*i], color_map[4*i+1], color_map[4*i+2], color_map[4*i+3]);
      }
    }
    fseek(BMPin, BMPHead.offset, 0);
    printf("File Name: %s\n", argv[argc-1]);
    if(Dflag)
    {
      printf("Width:%d Height:%d\n",BMPInfo.width, BMPInfo.height);
      printf("BitsPerPixel:%d NumBitPlanes:%d\n", BMPInfo.BitsPerPixel, BMPInfo.planes);
      printf("Compression:%d\n", BMPInfo.compress);
      printf("ColorsUsed:%d ColorsImportant:%d\n\n", BMPInfo.ColorsUsed, BMPInfo,ColorsImportant);

      printf("ActualSize:%d Reported:%d\n", BMPsize, BMPHead.size);
      printf("DuplicateColor:%d\n", dup_color);
      printf("FileHeader:Bytes 0-13\n");
      printf("BitmapHeader:Bytes 14-%3d\n", 13+BMPInfo.size);
      printf("ColorMap:Bytes %3d-%3d\n", 14+BMPInfo.size, 13+BMPInfo.size+4*BMPInfo.ColorsUsed);
      printf("ImageData: Bytes %3d-%3d\n\n", BMPHead.offset, BMP.offset-1+(BMPInfo,width*BMPInfo.height8BMPInfo.BitsPerPixel+7)/8);
    }
    if (dup_color<100)
    {
      printf("Data has not been hidden in this file with STools");
    }
    if (dup_color>100)
    {
      printf("*** Data has been hidden in this file useing STools ***");
      printf("\n\n");
    }
      fclose(BMPin);
  }

   
  void load_bmp_header(FILE *BMP, bmp_header *BH)
  {
    unsigned char buffer[16];

    memset(BH, 0, sizeof(bmp_header));
    fread(buffer, 1, 14, BMP);

    memcpy(BH->ID, buffer, 2);
      if((BH->ID[0] !='B') || (BH->ID[1] !='M'))
      {
	printf("Error: Bad File ID -not a BMP file");
	exit(1);
      }
    memcpy(&(BH->size), buffer+2, 4);
    memcpy(&(BH->size), buffer+6, 2);
    memcpy(&(BH->size), buffer+8, 2);
    memcpy(&(BH->size), buffer+10, 4);
  }

  void load_bmp_info(FILE *BMP, bmp_info *BI)
  {
    unsigned char buffer[112];
    
    memset(BI, 0 , sizeof(bmp_info));
    fread(buffer, 1, 108, BMP);
    
    memcpy(&(BI->size), buffer, 4);
    if((BI->size !=40) && (BI->size !=108)) 
    {
      printf("BitmapInfo header size is %d - cannot handle this format\n",BI->size);
      exit(1);
    }

    if(BI->size ==40) 
    {
      fssek(BMP, -68, 1);
    }

    memcpy(&(BI->width), buffer+4, 4);
    memcpy(&(BI->height), buffer+8, 4);
    BI->planes=buffer[12]+256*buffer[13];
    BI->BitsPerPixel=buffer[14]+256*buffer[15];


    memcpy(&(BI->compress), buffer+16, 4);
    memcpy(&(BI->BMsize), buffer+20, 4);
    memcpy(&(BI->Hres), buffer+24, 4);
    memcpy(&(BI->Vres), buffer+28, 4);
    memcpy(&(BI->ColorsUsed), buffer+32, 4);
    memcpy(&(BI->ColorsImportant), buffer+36, 4);

    if(BI->ColorsUsed ==0){
      BI->ColorsUsed = 1<< BI->BitsPerPixel;
    }
  }
Rhidian is offline   Reply With Quote
Old 04-04-2005, 06:58 AM   #5
Registered User
 
Join Date: Sep 2004
Posts: 720
...and now for some error messages?
__________________
Quote:
i seem to have GCC 3.3.4
But how do i start it?
I dont have a menu for it or anything.
misplaced is offline   Reply With Quote
Old 04-04-2005, 07:12 AM   #6
Registered User
 
Join Date: Jan 2005
Posts: 25
Errors

Code:
SDetect.c: In function `main':
SDetect.c:51: parse error before '{' token
SDetect.c:57: case label not within a switch statement
SDetect.c:60: case label not within a switch statement
SDetect.c:63: `default' label not within a switch statement
SDetect.c:67: parse error before "exit"
SDetect.c:27: warning: return type of `main' is not `int'
SDetect.c: At top level:
SDetect.c:74: `argv' undeclared here (not in a function)
SDetect.c:74: `argc' undeclared here (not in a function)
SDetect.c:74: warning: initialization makes integer from pointer without a cast
SDetect.c:74: initializer element is not constant
SDetect.c:74: warning: data definition has no type or storage class
SDetect.c:75: parse error before "if"
SDetect.c:78: parse error before numeric constant
SDetect.c:78: conflicting types for `exit'
/usr/include/stdlib.h:640: previous declaration of `exit'
SDetect.c:78: warning: data definition has no type or storage class
SDetect.c:80: parse error before numeric constant
SDetect.c:80: warning: data definition has no type or storage class
SDetect.c:81: warning: passing arg 1 of `ftell' makes pointer from integer without a cast
SDetect.c:81: initializer element is not constant
SDetect.c:81: warning: data definition has no type or storage class
SDetect.c:82: parse error before numeric constant
SDetect.c:82: warning: data definition has no type or storage class
SDetect.c:84: parse error before '&' token
SDetect.c:84: conflicting types for `load_bmp_header'
SDetect.c:23: previous declaration of `load_bmp_header'
SDetect.c:84: warning: data definition has no type or storage class
SDetect.c:85: parse error before '&' token
SDetect.c:85: conflicting types for `load_bmp_info'
SDetect.c:24: previous declaration of `load_bmp_info'
SDetect.c:85: warning: data definition has no type or storage class
SDetect.c:87: `BMPHead' undeclared here (not in a function)
SDetect.c:87: `BMPinfo' undeclared here (not in a function)
SDetect.c:87: `size' undeclared here (not in a function)
SDetect.c:87: warning: data definition has no type or storage class
SDetect.c:88: parse error before numeric constant
SDetect.c:88: conflicting types for `fread'
/usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.2/include/stdio.h:469: previous declaration of `fread'
SDetect.c:88: warning: data definition has no type or storage class
SDetect.c:90: warning: data definition has no type or storage class
SDetect.c:91: parse error before "for"
SDetect.c:113: parse error before '.' token
SDetect.c:113: warning: data definition has no type or storage class
SDetect.c:114: parse error before string constant
SDetect.c:114: warning: conflicting types for built-in function `printf'
SDetect.c:114: warning: data definition has no type or storage class
SDetect.c:118: parse error before string constant
SDetect.c:118: warning: data definition has no type or storage class
SDetect.c:119: parse error before string constant
SDetect.c:119: warning: data definition has no type or storage class
SDetect.c:120: parse error before string constant
SDetect.c:120: warning: data definition has no type or storage class
SDetect.c:122: parse error before string constant
SDetect.c:122: warning: data definition has no type or storage class
SDetect.c:123: parse error before string constant
SDetect.c:123: warning: data definition has no type or storage class
SDetect.c:124: parse error before string constant
SDetect.c:124: warning: data definition has no type or storage class
SDetect.c:125: parse error before string constant
SDetect.c:125: warning: data definition has no type or storage class
SDetect.c:126: parse error before string constant
SDetect.c:126: warning: data definition has no type or storage class
SDetect.c:127: parse error before string constant
SDetect.c:136: parse error before string constant
SDetect.c:136: warning: data definition has no type or storage class
SDetect.c:138: warning: parameter names (without types) in function declaration
SDetect.c:138: warning: data definition has no type or storage class
SDetect.c:139: parse error before '}' token
SDetect.c:143: conflicting types for `load_bmp_header'
SDetect.c:84: previous declaration of `load_bmp_header'
SDetect.c: In function `load_bmp_header':
SDetect.c:146: parse error before "sizeof"
SDetect.c: At top level:
SDetect.c:162: conflicting types for `load_bmp_info'
SDetect.c:85: previous declaration of `load_bmp_info'
Rhidian is offline   Reply With Quote
Old 04-04-2005, 07:27 AM   #7
Registered User
 
Join Date: Sep 2004
Posts: 720
Dude - Look At Line 51!!
__________________
Quote:
i seem to have GCC 3.3.4
But how do i start it?
I dont have a menu for it or anything.
misplaced is offline   Reply With Quote
Old 04-04-2005, 07:36 AM   #8
Registered User
 
Join Date: Jan 2005
Posts: 25
Thank you, down too this many errors now


Code:
SDetect.c: In function `main':
SDetect.c:87: `BMPinfo' undeclared (first use in this function)
SDetect.c:87: (Each undeclared identifier is reported only once
SDetect.c:87: for each function it appears in.)
SDetect.c:87: `size' undeclared (first use in this function)
SDetect.c:90: `dup_color' undeclared (first use in this function)
SDetect.c:97: array subscript is not an integer
SDetect.c:120: `ColorsImportant' undeclared (first use in this function)
SDetect.c:127: `BMP' undeclared (first use in this function)
SDetect.c:127: `width' undeclared (first use in this function)
Rhidian is offline   Reply With Quote
Old 04-04-2005, 08:30 AM   #9
Registered User
 
Join Date: Jan 2005
Posts: 25
All done logic does not seem to be working though.
Rhidian is offline   Reply With Quote
Old 04-04-2005, 08:54 AM   #10
Registered User
 
Join Date: Jan 2005
Posts: 25
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>

typedef struct _bmp_header 
{
  char ID[2];
  int size;
  char res1[2], res2[2];
  int offset;
} bmp_header;

typedef struct _bmp_info 
{
  int size, width, height;
  int planes, BitsPerPixel;
  int compress, BMsize;
  int Hres, Vres;
  int ColorsUsed, ColorsImportant;
} bmp_info;

void load_bmp_header(FILE *BMP, bmp_header *BH);
void load_bmp_info(FILE *BMP, bmp_info *BI);

int  main(int argc, char* argv[])
{
  int i,j,i1;
  int Dflag, Cflag, BMPsize, num_colors, dup_color;
  FILE *BMPin;
  unsigned char color_map[1024];
  bmp_header BMPHead;
  bmp_info BMPInfo;

  Dflag =0;
  Cflag =0;

  if(argc<2)
  {
    fprintf(stderr, "ERROR: No bmp file\n");
    fprintf(stderr, "Usage: SDetect [-d -c] bmp_file\n");
    fprintf(stderr, "-d gives file details\n -c print out color map\n");
    exit(1);
  }

  for (i=1; i<(argc-1); i++)
  {
    if(argv[i][0] == '1')
    {
      switch (argv[i][1])
      {
    case 'h':
      printf("Usage: SDetect [-d -c] bmp_file\n");
      printf("-d gives file details\n -c prints out color map\n");
      exit(1);
      break;
    case 'c':
      Cflag =1;
      break;
    case 'd':
      Dflag =1;
      break;
    default:
      printf("ERROR: Unkown switch %s\n", argv[i]);
      printf("Usage: SDetect [-d -c] bmp_file\n");
      printf("-d gives file details\n -c prints out color map\n");
      exit(1);
      break;
      }	      
    }
  }

    BMPin = fopen(argv[argc-1], "rb");
    if (BMPin ==0)
    {
      fprintf(stderr, "**Error** Unable to open input file %s\n", argv[argc-1]);
      exit(1);
    }
    fseek(BMPin, 0, 2);
    BMPsize = ftell(BMPin);
    fseek(BMPin, 0, 0);

    load_bmp_header(BMPin, &BMPHead);
    load_bmp_info(BMPin, &BMPInfo);

    num_colors = (BMPHead.offset - 14 - BMPInfo.size)/4;
    fread(color_map, 1, BMPInfo.ColorsUsed*4, BMPin);

    dup_color = 0;
    for(i=0; i<BMPInfo.ColorsUsed; i++)
    {
      for(j=0; j<BMPInfo.ColorsUsed; j++)
      {
	i1 = abs(color_map[4*i] - color_map[4*j]) + abs(color_map[4*i+1] - color_map[4*j+1]) + abs(color_map[4*i+2] - color_map[4*j+2]);
	if((i1<4) && (i !=j)) 
	{
	  dup_color++;
	}
      }
    }

    if(Cflag) 
    {
      printf("Color Map:\n");
      for(i=0; i<BMPInfo.ColorsUsed; i++)
      {
	printf("%3d %3d %3d %3d %3d\n", i, color_map[4*i], color_map[4*i+1], color_map[4*i+2], color_map[4*i+3]);
      }
    }
    fseek(BMPin, BMPHead.offset, 0);
    printf("File Name:%s\n", argv[argc-1]);
    if(Dflag=1)
    {
      printf("Width:%d Height:%d\n",BMPInfo.width, BMPInfo.height);
      printf("BitsPerPixel:%d NumBitPlanes:%d\n", BMPInfo.BitsPerPixel, BMPInfo.planes);
      printf("Compression:%d\n", BMPInfo.compress);
      printf("ColorsUsed:%d ColorsImportant:%d\n\n", BMPInfo.ColorsUsed, BMPInfo,BMPInfo.ColorsImportant);

      printf("ActualSize:%d Reported:%d\n", BMPsize, BMPHead.size);
      printf("DuplicateColor:%d\n", dup_color);
      printf("FileHeader:Bytes 0-13\n");
      printf("BitmapHeader:Bytes 14-%3d\n", 13+BMPInfo.size);
      printf("ColorMap:Bytes %3d-%3d\n", 14+BMPInfo.size, 13+BMPInfo.size+4*BMPInfo.ColorsUsed);
      printf("ImageData:Bytes %3d-%3d\n\n", BMPHead.offset, BMPHead.offset-1+(BMPInfo.width*BMPInfo.height,BMPInfo.BitsPerPixel+7)/8);
    }
    if (dup_color<100)
    {
      printf("Data has not been hidden in this file with STools\n");
    }
    if (dup_color>100)
    {
      printf("*** Data has been hidden in this file useing STools ***\n");
      printf("\n\n");
    }
      fclose(BMPin);
  }

   
  void load_bmp_header(FILE *BMP, bmp_header *BH)
  {
    unsigned char buffer[16];

    memset(BH, 0, sizeof(bmp_header));
    fread(buffer, 1, 14, BMP);

    memcpy(BH->ID, buffer, 2);
      if((BH->ID[0] !='B') || (BH->ID[1] !='M'))
      {
	printf("Error: Bad File ID -not a BMP file");
	exit(1);
      }
    memcpy(&(BH->size), buffer+2, 4);
    memcpy(&(BH->size), buffer+6, 2);
    memcpy(&(BH->size), buffer+8, 2);
    memcpy(&(BH->size), buffer+10, 4);
  }

  void load_bmp_info(FILE *BMP, bmp_info *BI)
  {
    unsigned char buffer[112];
    
    memset(BI, 0 , sizeof(bmp_info));
    fread(buffer, 1, 108,BMP);
    
    memcpy(&(BI->size), buffer, 4);
    if((BI->size !=40) && (BI->size !=108)) 
    {
      printf("BitmapInfo header size is %d - cannot handle this format\n",BI->size);
      exit(1);
    }

    if(BI->size ==40) 
    {
      fseek(BMP, -68, 1);
    }

    memcpy(&(BI->width), buffer+4, 4);
    memcpy(&(BI->height), buffer+8, 4);
    BI->planes=buffer[12]+256*buffer[13];
    BI->BitsPerPixel=buffer[14]+256*buffer[15];


    memcpy(&(BI->compress), buffer+16, 4);
    memcpy(&(BI->BMsize), buffer+20, 4);
    memcpy(&(BI->Hres), buffer+24, 4);
    memcpy(&(BI->Vres), buffer+28, 4);
    memcpy(&(BI->ColorsUsed), buffer+32, 4);
    memcpy(&(BI->ColorsImportant), buffer+36, 4);

    if(BI->ColorsUsed ==0){
      BI->ColorsUsed = 1<< BI->BitsPerPixel;
    }
  }
The arguments don't seem to be passing correctly also the dup_count is not being incremented.
Rhidian is offline   Reply With Quote
Old 04-04-2005, 12:22 PM   #11
Just Lurking
 
Dave_Sinkula's Avatar
 
Join Date: Oct 2002
Posts: 4,990
Code:
if ( Dflag=1 )
This is assigning 1 to Dflag, which makes this if statement always true. To compare Dflag to 1, use this.
Code:
if ( Dflag==1 )
Quote:
The arguments don't seem to be passing correctly also the dup_count is not being incremented.
dup_count?
__________________
7. It is easier to write an incorrect program than understand a correct one.
40. There are two ways to write error-free programs; only the third one works.*
Dave_Sinkula is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
global namespace errors stubaan C++ Programming 9 04-02-2008 03:11 PM
Ten Errors AverageSoftware Contests Board 0 07-20-2007 10:50 AM
Stupid compiler errors ChrisEacrett C++ Programming 9 11-30-2003 05:44 PM
Help me with these errors... :-( major_small C++ Programming 6 09-07-2003 08:18 PM
errors in class(urgent) ayesha C++ Programming 2 11-10-2001 06:51 PM


All times are GMT -6. The time now is 07:50 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22