Saving bitmaps to file in Microsoft C

eweb at ccvax.ucd.ie eweb at ccvax.ucd.ie
Wed Feb 28 10:20:26 AEST 1990


My problem is that I'm trying to write bitmaps, to a file for 
future use. The program compiles okay but doesn't read the images 
back in. If I introduce a bug into the program, (e.g. an undeclared
variable) I get warnings about converting near pointers to far pointers.

  int x1, y1, x2, y2;
  unsigned int size;
  void *ptr;
  
  size = (unsigned int) _imagesize(x1,y1,x2,y2);
  ptr = malloc(size);
  _getimage(x1,y1,x2,y2,ptr);
  fwrite(&size, sizeof(unsigned int), 1, fp);
  fwrite(ptr, size, 1, fp);


and then later

  fread(&size, sizeof(unsigned int), 1, fp);
  ptr = malloc(size);
  fread(ptr, size, 1, fp);
  _putimage(x1,y1,ptr,_GXOR);

I'd prefer to know what I'm doing wrong, but if you can provide code, but 
can't provide an answer, well I'm not that proud....


Eamonn Webster                       eweb at ccvax.ucd.ie
Department of Computer Science       eweb at ccvax.bitnet
University College Dublin
Belfield
Dublin 4
Ireland

I never had an original thought in my life, so views expressed must be
someone else's....



More information about the Comp.lang.c mailing list