Mercurial > repos > blastem
annotate ppm.c @ 2286:5d3411f52d00
Fix ui.reload for locked-on ROMs
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Fri, 13 Jan 2023 23:42:46 -0800 |
parents | 5f65a16c23ff |
children |
rev | line source |
---|---|
1263
5f65a16c23ff
Implement raw screenshot functionality requested in ticket:10
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1 #include <stdint.h> |
5f65a16c23ff
Implement raw screenshot functionality requested in ticket:10
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2 #include <stdio.h> |
5f65a16c23ff
Implement raw screenshot functionality requested in ticket:10
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3 |
5f65a16c23ff
Implement raw screenshot functionality requested in ticket:10
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
4 void save_ppm(FILE *f, uint32_t *buffer, uint32_t width, uint32_t height, uint32_t pitch) |
5f65a16c23ff
Implement raw screenshot functionality requested in ticket:10
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5 { |
5f65a16c23ff
Implement raw screenshot functionality requested in ticket:10
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
6 fprintf(f, "P6\n%d %d\n255\n", width, height); |
5f65a16c23ff
Implement raw screenshot functionality requested in ticket:10
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
7 for(uint32_t y = 0; y < height; y++) |
5f65a16c23ff
Implement raw screenshot functionality requested in ticket:10
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
8 { |
5f65a16c23ff
Implement raw screenshot functionality requested in ticket:10
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
9 uint32_t *line = buffer; |
5f65a16c23ff
Implement raw screenshot functionality requested in ticket:10
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
10 for (uint32_t x = 0; x < width; x++, line++) |
5f65a16c23ff
Implement raw screenshot functionality requested in ticket:10
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
11 { |
5f65a16c23ff
Implement raw screenshot functionality requested in ticket:10
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
12 uint8_t buf[3] = { |
5f65a16c23ff
Implement raw screenshot functionality requested in ticket:10
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
13 *line >> 16, //red |
5f65a16c23ff
Implement raw screenshot functionality requested in ticket:10
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
14 *line >> 8, //green |
5f65a16c23ff
Implement raw screenshot functionality requested in ticket:10
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
15 *line //blue |
5f65a16c23ff
Implement raw screenshot functionality requested in ticket:10
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
16 }; |
5f65a16c23ff
Implement raw screenshot functionality requested in ticket:10
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
17 fwrite(buf, 1, sizeof(buf), f); |
5f65a16c23ff
Implement raw screenshot functionality requested in ticket:10
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
18 } |
5f65a16c23ff
Implement raw screenshot functionality requested in ticket:10
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
19 buffer = buffer + pitch / sizeof(uint32_t); |
5f65a16c23ff
Implement raw screenshot functionality requested in ticket:10
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
20 } |
5f65a16c23ff
Implement raw screenshot functionality requested in ticket:10
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
21 } |