1 // Implementation of: Portable float-map
2 // Spec: https://web.archive.org/web/20100708234919/gl.ict.usc.edu/HDRShop/PFM/PFM_Image_File_Format.html
3 // Known to work in: Substance Designer ( Use node format c32f )
5 // Write pfm file to disk (32 bpc, RGB floats) (96 bits per pixel)
6 int csr_32f_write( char const *path
, int w
, int h
, float const *buffer
)
9 uint32_t image_size_bytes
;
11 write_ptr
= fopen( path
, "wb" );
16 // Write header (little endian)
17 fprintf( write_ptr
, "PF\n%d %d\n-1.0\n", w
, h
);
19 image_size_bytes
= w
* h
* sizeof( float ) * 3;
22 fwrite( buffer
, image_size_bytes
, 1, write_ptr
);