programming:load a bitmap (bmp) fileWhat links here?
The code can only handle uncompressed format BMP files.

/**************************************************************************
 *  load_bmp                                                              *
 *    Loads a bitmap file into memory.                                    *
 **************************************************************************/


void load_bmp(char *file,BITMAP *b) { FILE *fp; long index; word num_colors; int x;

/* open the file */ if ((fp = fopen(file,"rb")) == NULL) { printf("Error opening file %s.\n",file); exit(1); }

/* check to see if it is a valid bitmap file */ if (fgetc(fp)!='B' || fgetc(fp)!='M') { fclose(fp); printf("%s is not a bitmap file.\n",file); exit(1); }

/* read in the width and height of the image, and the number of colors used; ignore the rest */ fskip(fp,16); fread(&b->width, sizeof(word), 1, fp); fskip(fp,2); fread(&b->height,sizeof(word), 1, fp); fskip(fp,22); fread(&num_colors,sizeof(word), 1, fp); fskip(fp,6);

/* assume we are working with an 8-bit file */ if (num_colors==0) num_colors=256;



/* try to allocate memory */ if ((b->data = (byte *) malloc((word)(b->width*b->height))) == NULL) { fclose(fp); printf("Error allocating memory for file %s.\n",file); exit(1); }

/* Ignore the palette information for now. See palette.c for code to read the palette info. */ fskip(fp,num_colors*4);

/* read the bitmap */ for(index=(b->height-1)*b->width;index>=0;index-=b->width) for(x=0;xwidth;x++) b->data[(word)index+x]=(byte)fgetc(fp);

fclose(fp); }



from here
programming:load a bitmap (bmp) file
AutoCAD - Dialog Control Language (DCL) - (get_attr key attribute)
programming:windows:window styles
AutoCAD LISP - GETSTRING
programming:DDE:PROGMAN DDE Server
programming:DDE
programming:c:size_t
AutoCAD - Dialog Control Language (DCL) - (load_dialog dclfile)
programming:autolisp
programming:windows:CreateWindow
programming:c:struct utimbuf
AutoCAD - Dialog Control Language (DCL) - (start_dialog)
FreeCAD - create object
programming:c:gmtime
X Windows Functions - Display *XOpenDisplay(display_name)
programming:windows:WM_NCCALCSIZE
programming:c:CLOCKS_PER_SEC
tk:tk_canvas
filename:programming:load a bitmap (bmp) file
filename:programming%3Aload%20a%20bitmap%20%28bmp%29%20file
last edit:May 01 2010 18:13:32 (6061 days ago)
ct = 1796429710.000000 = December 05 2026 00:15:10
ft = 1272737612.000000 = May 01 2010 18:13:32
dt = 523692098.000000