Mercurial > repos > blastem
comparison ppm.c @ 1263:5f65a16c23ff
Implement raw screenshot functionality requested in ticket:10
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Sat, 04 Mar 2017 11:50:14 -0800 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
1262:462d9770d467 | 1263:5f65a16c23ff |
---|---|
1 #include <stdint.h> | |
2 #include <stdio.h> | |
3 | |
4 void save_ppm(FILE *f, uint32_t *buffer, uint32_t width, uint32_t height, uint32_t pitch) | |
5 { | |
6 fprintf(f, "P6\n%d %d\n255\n", width, height); | |
7 for(uint32_t y = 0; y < height; y++) | |
8 { | |
9 uint32_t *line = buffer; | |
10 for (uint32_t x = 0; x < width; x++, line++) | |
11 { | |
12 uint8_t buf[3] = { | |
13 *line >> 16, //red | |
14 *line >> 8, //green | |
15 *line //blue | |
16 }; | |
17 fwrite(buf, 1, sizeof(buf), f); | |
18 } | |
19 buffer = buffer + pitch / sizeof(uint32_t); | |
20 } | |
21 } |