-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.c
More file actions
27 lines (26 loc) · 704 Bytes
/
Copy pathtest.c
File metadata and controls
27 lines (26 loc) · 704 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <stdio.h>
#include "toybmp.h"
#pragma warning(disable:4996)
unsigned char rgb[256 * 256 * 3];
unsigned char rgba[256 * 256 * 4];
int main(void) {
unsigned char* p = rgb;
unsigned char* pa = rgba;
for (int y = 0; y < 256; ++y) {
for (int x = 0; x < 256; ++x) {
*p++ = (unsigned char)x;
*p++ = (unsigned char)y;
*p++ = (unsigned char)128;
}
}
for (int y = 0; y < 256; ++y) {
for (int x = 0; x < 256; ++x) {
*pa++ = (unsigned char)x;
*pa++ = (unsigned char)y;
*pa++ = (unsigned char)128;
*pa++ = (unsigned char)((x + y) / 2); // A
}
}
toybmp(fopen("rgb.bmp", "wb"), 256, 256, p, 0);
toybmp(fopen("rgba.bmp", "wb"), 256, 256, pa, 1);
}