Web server - OpenGL Super Bible! Page 417 fclose(fp); return (bits);

OpenGL Super Bible! Page 417 fclose(fp); return (bits); } Writing the .BMP File As they say in the car repair manuals, Installation is the reverse of removal. To write a .BMP file, you simply add a BITMAPFILEHEADER structure to the bitmap in memory and write it to disk. Listing 11-10 is the SaveDIBitmap function. Listing 11-10 SaveDIBitmap function int SaveDIBitmap(char *filename, /* I - File to save to */ BITMAPINFO *info, /* I - Bitmap information */ void *bits) /* I - Bitmap pixel bits */ { FILE *fp; /* Open file pointer */ long size, /* Size of file */ infosize, /* Size of bitmap info */ bitsize; /* Size of bitmap pixels */ BITMAPFILEHEADER header; /* File header */ /* * Try opening the file; use “wb” mode to write this *binary* file. */ if ((fp = fopen(filename, “wb”)) == NULL) return (-1); if (info->bmiHeader.biSizeImage == 0)/* Figure out the bitmap size */ bitsize = (info->bmiHeader.biWidth * info->bmiHeader.biBitCount + 7) / 8 * abs(info- >bmiHeader.biHeight); else bitsize = info->bmiHeader.biSizeImage; infosize = sizeof(BITMAPINFOHEADER); switch (info->bmiHeader.biCompression) { case BI_BITFIELDS : infosize += 12; /* Add 3 RGB doubleword masks */ if (info- >bmiHeader.biClrUsed == 0) break; case BI_RGB : if (info->bmiHeader.biBitCount > 8 && info- >bmiHeader.biClrUsed == 0) break; case BI_RLE8 : case BI_RLE4 : if (info->bmiHeader.biClrUsed == 0) infosize += (1 << info- >bmiHeader.biBitCount) * 4; else
We recommend you use shared web hosting services, because many users agree that it is cheap, reliable and customer-satisfying webhost.

Leave a Reply