|
|
1.1 root 1: /* Generator is (c) James Ponder, 1997-2001 http://www.squish.net/generator/ */
2:
3: #include <assert.h>
4: #include <stdlib.h>
5:
6: #include "generator.h"
7:
8: #include "dib.h"
9:
10: /* From http://www.jmcgowan.com/avitech.html */
11:
12: /*
13: * The DIB files have a standard header that identifies the format, size,
14: * color palette (if applicable) of the bitmapped image. The header
15: * is a BITMAPINFO structure.
16: *
17: * typedef struct tagBITMAPINFO {
18: * BITMAPINFOHEADER bmiHeader;
19: * RGBQUAD bmiColors[1];
20: * } BITMAPINFO;
21: *
22: * The BITMAPINFOHEADER is a structure of the form:
23: *
24: * typedef struct tagBITMAPINFOHEADER{ // bmih
25: * DWORD biSize;
26: * LONG biWidth;
27: * LONG biHeight;
28: * WORD biPlanes;
29: * WORD biBitCount
30: * DWORD biCompression; // a DIB can be compressed using run length encoding
31: * DWORD biSizeImage;
32: * LONG biXPelsPerMeter;
33: * LONG biYPelsPerMeter;
34: * DWORD biClrUsed;
35: * DWORD biClrImportant;
36: * } BITMAPINFOHEADER;
37: *
38: * bmiColors[1] is the first entry in an optional color palette or color
39: * table of RGBQUAD data structures. True color (24 bit RGB) images
40: * do not need a color table. 4 and 8 bit color images use a color table.
41: *
42: * typedef struct tagRGBQUAD { // rgbq
43: * BYTE rgbBlue;
44: * BYTE rgbGreen;
45: * BYTE rgbRed;
46: * BYTE rgbReserved; // always zero
47: * } RGBQUAD;
48: *
49: * A DIB consists of
50: *
51: * (BITMAPINFOHEADER)(optional color table of RGBQUAD's)(data for the
52: * bitmapped image)
53: *
54: */
55:
56: /*
57: * Other useful links:
58: * http://www.cwi.nl/ftp/audio/RIFF-format
59: *
60: */
61:
62: void dib_setheader(t_bmih *bmih, uint32 x, uint32 y)
63: {
64: uint8 pad = 4 - ((x * 3) & 3); /* must align to 32 bits (4 bytes) */
65:
66: if (pad == 4)
67: pad = 0;
68: bmih->biSize = sizeof(t_bmih);
69: bmih->biWidth = x;
70: bmih->biHeight = y;
71: bmih->biPlanes = 1;
72: bmih->biBitCount = 24;
73: bmih->biCompression = 0; /* BI_RGB */
74: bmih->biSizeImage = ((x * 3) + pad) * y;
75: bmih->biXPelsPerMeter = 0;
76: bmih->biYPelsPerMeter = 0;
77: bmih->biClrUsed = 0; /* no palette in 24 bit mode */
78: bmih->biClrImportant = 0; /* no palette in 24 bit mode */
79: assert(bmih->biSize == 40);
80: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.