diff --git a/modules/imgcodecs/src/grfmt_pfm.cpp b/modules/imgcodecs/src/grfmt_pfm.cpp index baa0108081..53ef5d677c 100644 --- a/modules/imgcodecs/src/grfmt_pfm.cpp +++ b/modules/imgcodecs/src/grfmt_pfm.cpp @@ -5,7 +5,7 @@ #include "precomp.hpp" #include "utils.hpp" #include "grfmt_pfm.hpp" -#include +#include #ifdef HAVE_IMGCODEC_PFM @@ -64,11 +64,10 @@ T read_number(cv::RLByteStream& strm) return atoT(str); } -template bool write_anything(cv::WLByteStream& strm, const T& t) +bool write_integer(cv::WLByteStream& strm, int value) { - std::ostringstream ss; - ss << t; - return strm.putBytes(ss.str().c_str(), static_cast(ss.str().size())); + const std::string text = std::to_string(value); + return strm.putBytes(text.c_str(), static_cast(text.size())); } } @@ -220,20 +219,19 @@ bool PFMEncoder::write(const Mat& img, const std::vector& params) CHECK_WRITE(strm.putByte('\n')); - CHECK_WRITE(write_anything(strm, float_img.cols)); + CHECK_WRITE(write_integer(strm, float_img.cols)); CHECK_WRITE(strm.putByte(' ')); - CHECK_WRITE(write_anything(strm, float_img.rows)); + CHECK_WRITE(write_integer(strm, float_img.rows)); CHECK_WRITE(strm.putByte('\n')); #ifdef WORDS_BIGENDIAN - CHECK_WRITE(write_anything(strm, 1.0)); + CHECK_WRITE(write_integer(strm, 1)); #else - CHECK_WRITE(write_anything(strm, -1.0)); + CHECK_WRITE(write_integer(strm, -1)); #endif CHECK_WRITE(strm.putByte('\n')); // Comments are not officially supported in this file format. - // write_anything(strm, "# Generated by OpenCV " CV_VERSION "\n"); for (int y = float_img.rows - 1; y >= 0; --y) {