#include <windows.h>#include <stdio.h>Go to the source code of this file.
Defines | |
| #define | WIN32_LEAN_AND_MEAN |
| #define | WIDTH 640 |
| #define | HEIGHT 480 |
| #define | RED(x) ((unsigned short)((x>>11) & 0x1f)) |
| #define | GREEN(x) ((unsigned short)((x>>5 ) & 63)) |
| #define | BLUE(x) ((unsigned short)((x>>0 ) & 0x1f)) |
Functions | |
| int | WriteBMP (unsigned short *ScreenBuffer, const char *Name) |
Variables | |
| BITMAPFILEHEADER | bfh |
| BITMAPINFO | bi |
|
|
Definition at line 63 of file Bmp.c. Referenced by WriteBMP(). |
|
|
Definition at line 62 of file Bmp.c. Referenced by WriteBMP(). |
|
|
|
|
|
Definition at line 61 of file Bmp.c. Referenced by WriteBMP(). |
|
|
|
|
|
|
|
||||||||||||
|
Definition at line 66 of file Bmp.c. References bfh, bi, BLUE, GREEN, HEIGHT, RED, WIDTH, and y. Referenced by GMain_ScreenShot().
00067 {
00068 FILE * out;
00069 int y;
00070
00071 out = fopen(Name, "wb");
00072
00073 if (!out)
00074 return 0;
00075
00076 if (fwrite(&bfh, sizeof(bfh), 1, out) != 1)
00077 return 0;
00078
00079 if (fwrite(&bi, sizeof(bi), 1, out) != 1)
00080 return 0;
00081
00082 for (y = HEIGHT-1; y >= 0; y--)
00083 {
00084 int i;
00085 unsigned short *p;
00086 unsigned char Buff[WIDTH * 3];
00087 unsigned char * BuffPtr;
00088
00089 BuffPtr = &Buff[0];
00090 p = &ScreenBuffer[y*WIDTH];
00091 for (i = 0; i < WIDTH; i++)
00092 {
00093 #ifdef BIT16
00094 unsigned short c;
00095
00096 c = p[i];
00097 c = (RED(c) << 10) + (GREEN(c) << 5) + BLUE(c);
00098 p[i] = c;
00099 #else
00100
00101 #ifdef VER1
00102 char c[3];
00103 c = (char)(GREEN(p[i]) << 2);
00104 fwrite(&c, 1, 1, out);
00105 c = (char)(RED(p[i]) << 3);
00106 fwrite(&c, 1, 1, out);
00107 c = (char)(BLUE(p[i]) << 3);
00108 fwrite(&c, 1, 1, out);
00109 #else
00110 #if 0
00111 char c[3];
00112 c = (char)(BLUE(p[i]) << 3);
00113 fwrite(&c, 1, 1, out);
00114 c = (char)(GREEN(p[i]) << 2);
00115 fwrite(&c, 1, 1, out);
00116 c = (char)(RED(p[i]) << 3);
00117 fwrite(&c, 1, 1, out);
00118 #else
00119 *BuffPtr++ = (char)(BLUE(p[i]) << 3);
00120 *BuffPtr++ = (char)(GREEN(p[i]) << 2);
00121 *BuffPtr++ = (char)(RED(p[i]) << 3);
00122 // fwrite(&c[0], 3, 1, out);
00123 #endif
00124 #endif
00125 #endif
00126 }
00127
00128 fwrite(&Buff[0], WIDTH * 3, 1, out);
00129 #ifdef BIT16
00130 p = &ScreenBuffer[y*WIDTH];
00131 for (i = 0; i < WIDTH; i++)
00132 fwrite(&p[(i+2)%WIDTH], 2, 1, out);
00133 #endif
00134 }
00135
00136 if (fclose(out))
00137 return 0;
00138
00139 return 1;
00140 }
|
|
|
Initial value:
{
((unsigned short)'B' | ((unsigned short)'M' << 8)),
sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFO) + WIDTH * HEIGHT * 2,
0,
0,
sizeof(BITMAPINFOHEADER)
}
Definition at line 30 of file Bmp.c. Referenced by ScreenShot(), and WriteBMP(). |
|
|
Initial value:
{
{
sizeof(BITMAPINFOHEADER),
WIDTH,
HEIGHT,
1,
24,
BI_RGB,
0,
0,
0,
0,
0
}
}
Definition at line 39 of file Bmp.c. Referenced by WriteBMP(). |
1.3.2