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