@@ -77,26 +77,26 @@ auto image_load_from_memory(uint8_t* memory_data, std::size_t memory_data_size)
7777 return create_image_data (image_data, width, height, channels);
7878}
7979
80- void image_save (const std::filesystem::path& image_path, const std::vector< uint8_t >& image_data , int width, int height, int channels)
80+ void image_save (const std::filesystem::path& image_path, const uint8_t * image_data_ptr , int width, int height, int channels)
8181{
8282 bool ok = false ;
8383 const std::string image_ext = (image_path.has_extension () ? image_path.extension ().string () : " png" );
8484
8585 if (image_ext == " .png" )
8686 {
87- ok = stbi_write_png (image_path.string ().c_str (), width, height, channels, image_data. data () , width * channels) != 0 ;
87+ ok = stbi_write_png (image_path.string ().c_str (), width, height, channels, image_data_ptr , width * channels) != 0 ;
8888 }
8989 else if (image_ext == " .jpg" || image_ext == " .jpeg" )
9090 {
91- ok = stbi_write_jpg (image_path.string ().c_str (), width, height, channels, image_data. data () , /* quality*/ 100 ) != 0 ;
91+ ok = stbi_write_jpg (image_path.string ().c_str (), width, height, channels, image_data_ptr , /* quality*/ 100 ) != 0 ;
9292 }
9393 else if (image_ext == " .bmp" )
9494 {
95- ok = stbi_write_bmp (image_path.string ().c_str (), width, height, channels, image_data. data () ) != 0 ;
95+ ok = stbi_write_bmp (image_path.string ().c_str (), width, height, channels, image_data_ptr ) != 0 ;
9696 }
9797 else if (image_ext == " .tga" )
9898 {
99- ok = stbi_write_tga (image_path.string ().c_str (), width, height, channels, image_data. data () ) != 0 ;
99+ ok = stbi_write_tga (image_path.string ().c_str (), width, height, channels, image_data_ptr ) != 0 ;
100100 }
101101 else
102102 {
@@ -108,4 +108,9 @@ void image_save(const std::filesystem::path& image_path, const std::vector<uint8
108108 }
109109}
110110
111+ void image_save (const std::filesystem::path& image_path, const std::vector<uint8_t >& image_data, int width, int height, int channels)
112+ {
113+ return image_save (image_path, image_data.data (), width, height, channels);
114+ }
115+
111116}
0 commit comments