| 257 | // format used by Microsoft Windows for its .bmp extension files. |
| 258 | |
| 259 | void WriteBmp2(CONST Bitmap *b, FILE *file) |
| 260 | { |
| 261 | int x, y, cb; |
| 262 | dword dw; |
| 263 | |
| 264 | cb = (4 - ((b->x*3) & 3)) & 3; |
| 265 | // BitmapFileHeader |
| 266 | PutByte('B'); PutByte('M'); |
| 267 | dw = 14+40 + 0 + b->y*(b->x*3+cb); |
| 268 | PutLong(dw); |
| 269 | PutWord(0); PutWord(0); |
| 270 | PutLong(14+40 + 0); |
| 271 | // BitmapInfo / BitmapInfoHeader |
| 272 | PutLong(40); |
| 273 | PutLong(b->x); PutLong(b->y); |
| 274 | PutWord(1); PutWord(24); |
| 275 | PutLong(0 /*BI_RGB*/); PutLong(0); |
| 276 | PutLong(0); PutLong(0); |
| 277 | PutLong(0); PutLong(0); |
| 278 | // RgbQuad |
| 279 | // Data |
| 280 | for (y = b->y-1; y >= 0; y--) { |
| 281 | for (x = 0; x < b->x; x++) { |
| 282 | dw = _GetXY(b, x, y); |
| 283 | PutByte(RgbB(dw)); PutByte(RgbG(dw)); PutByte(RgbR(dw)); |
| 284 | } |
| 285 | for (x = 0; x < cb; x++) |
| 286 | PutByte(0); |
| 287 | } |
| 288 | } |
| 289 | |
| 290 | |
| 291 | // Set all pixels in a 24 bit bitmap to the specified RGB color value. |