... | ... |
@@ -93,9 +93,10 @@ static int |
93 | 93 |
writebmp(int w, int h, u32int *p) |
94 | 94 |
{ |
95 | 95 |
/* clang-format off */ |
96 |
+ int sz = 14 + 40 + 4*4 + 4*w*h; |
|
96 | 97 |
u8int hd[14+40+4*4] = { |
97 | 98 |
'B', 'M', |
98 |
- 0, 0, 0, 0, /* file size */ |
|
99 |
+ sz, sz>>8, sz>>16, sz>>24, /* file size */ |
|
99 | 100 |
0, 0, |
100 | 101 |
0, 0, |
101 | 102 |
14+40+4*4, 0, 0, 0, /* pixel data offset */ |
... | ... |
@@ -110,20 +111,13 @@ writebmp(int w, int h, u32int *p) |
110 | 111 |
0, 0, 0, 0, /* dummy ver ppm */ |
111 | 112 |
0, 0, 0, 0, /* dummy num of colors */ |
112 | 113 |
0, 0, 0, 0, /* dummy important colors */ |
113 |
- 0, 0, 0, 0xff, |
|
114 |
- 0, 0, 0xff, 0, |
|
115 |
- 0, 0xff, 0, 0, |
|
116 |
- 0xff, 0, 0, 0, |
|
114 |
+ 0, 0, 0, 0xff, /* R mask */ |
|
115 |
+ 0, 0, 0xff, 0, /* G mask */ |
|
116 |
+ 0, 0xff, 0, 0, /* B mask */ |
|
117 |
+ 0xff, 0, 0, 0, /* A mask */ |
|
117 | 118 |
}; |
118 |
- int sz; |
|
119 | 119 |
/* clang-format on */ |
120 | 120 |
|
121 |
- sz = 14 + 40 + 4 * 4 + 4 * w * h; |
|
122 |
- hd[2] = sz; |
|
123 |
- hd[3] = sz >> 8; |
|
124 |
- hd[4] = sz >> 16; |
|
125 |
- hd[5] = sz >> 24; |
|
126 |
- |
|
127 | 121 |
write(1, hd, sizeof(hd)); |
128 | 122 |
while(h-- >= 0) |
129 | 123 |
write(1, p + w * h, 4 * w); |