-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path03-File.cpp
37 lines (24 loc) · 1.04 KB
/
03-File.cpp
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
28
29
30
31
32
33
34
35
36
37
#include "aare/File.hpp"
#include <fmt/core.h>
#include <fmt/color.h>
int main(int argc, char const *argv[]){
//First argument is the name of the program, as second we expect the filename
if (argc < 2){
fmt::print(fg(fmt::terminal_color::magenta), "Usage: {} <filename>\n", argv[0]);
return 1;
}
//open the file and read the first frame
aare::File f(argv[1]);
auto frame = f.read_frame(); // allocated the memmory and returns a generic frame object
//Lets look at it as 16bit unsigned integers (hoping it's a jungfrau image)
auto view = frame.view<uint16_t>();
fmt::print("Image size: {}x{}\n", frame.rows(), frame.cols());
fmt::print("Pixel 45,200: {}\n", view(45, 200));
//We can also read into our own buffer
auto* buffer = new uint16_t[f.pixels_per_frame()];
f.read_into(reinterpret_cast<std::byte*>(buffer));
fmt::print("Pixel 0: {}\n", buffer[0]);
// Don't forget =)
delete[] buffer;
// For header access etc. you have to use the RawFile class directly
}