mirror of
https://github.com/opencv/opencv.git
synced 2026-07-30 07:43:03 +04:00
Merge branch 4.x
This commit is contained in:
@@ -1,44 +1,6 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
// This file is part of OpenCV project.
|
||||
// It is subject to the license terms in the LICENSE file found in the top-level
|
||||
// directory of this distribution and at http://opencv.org/license.html
|
||||
|
||||
#include "precomp.hpp"
|
||||
#include "bitstrm.hpp"
|
||||
@@ -49,11 +11,6 @@ namespace cv
|
||||
|
||||
const int BS_DEF_BLOCK_SIZE = 1<<15;
|
||||
|
||||
bool bsIsBigEndian( void )
|
||||
{
|
||||
return (((const int*)"\0\x1\x2\x3\x4\x5\x6\x7")[0] & 255) != 0;
|
||||
}
|
||||
|
||||
///////////////////////// RBaseStream ////////////////////////////
|
||||
|
||||
bool RBaseStream::isOpened()
|
||||
|
||||
@@ -1,44 +1,6 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
// This file is part of OpenCV project.
|
||||
// It is subject to the license terms in the LICENSE file found in the top-level
|
||||
// directory of this distribution and at http://opencv.org/license.html
|
||||
|
||||
#ifndef _BITSTRM_H_
|
||||
#define _BITSTRM_H_
|
||||
@@ -183,13 +145,6 @@ public:
|
||||
bool putDWord( int val );
|
||||
};
|
||||
|
||||
inline unsigned BSWAP(unsigned v)
|
||||
{
|
||||
return (v<<24)|((v&0xff00)<<8)|((v>>8)&0xff00)|((unsigned)v>>24);
|
||||
}
|
||||
|
||||
bool bsIsBigEndian( void );
|
||||
|
||||
}
|
||||
|
||||
#endif/*_BITSTRM_H_*/
|
||||
|
||||
@@ -1,44 +1,6 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
// This file is part of OpenCV project.
|
||||
// It is subject to the license terms in the LICENSE file found in the top-level
|
||||
// directory of this distribution and at http://opencv.org/license.html
|
||||
|
||||
#ifndef _GRFMT_BASE_H_
|
||||
#define _GRFMT_BASE_H_
|
||||
@@ -55,75 +17,228 @@ class BaseImageEncoder;
|
||||
typedef Ptr<BaseImageEncoder> ImageEncoder;
|
||||
typedef Ptr<BaseImageDecoder> ImageDecoder;
|
||||
|
||||
///////////////////////////////// base class for decoders ////////////////////////
|
||||
class BaseImageDecoder
|
||||
{
|
||||
/**
|
||||
* @brief Base class for image decoders.
|
||||
*
|
||||
* The BaseImageDecoder class provides an abstract interface for decoding various image formats.
|
||||
* It defines common functionality like setting the image source, reading image headers,
|
||||
* and handling EXIF metadata. Derived classes must implement methods for reading image headers
|
||||
* and image data to handle format-specific decoding logic.
|
||||
*/
|
||||
|
||||
class BaseImageDecoder {
|
||||
public:
|
||||
/**
|
||||
* @brief Constructor for BaseImageDecoder.
|
||||
* Initializes the object and sets default values for member variables.
|
||||
*/
|
||||
BaseImageDecoder();
|
||||
|
||||
/**
|
||||
* @brief Virtual destructor for BaseImageDecoder.
|
||||
* Ensures proper cleanup of derived classes when deleted via a pointer to BaseImageDecoder.
|
||||
*/
|
||||
virtual ~BaseImageDecoder() {}
|
||||
|
||||
/**
|
||||
* @brief Get the width of the image.
|
||||
* @return The width of the image (in pixels).
|
||||
*/
|
||||
int width() const { return m_width; }
|
||||
|
||||
/**
|
||||
* @brief Get the height of the image.
|
||||
* @return The height of the image (in pixels).
|
||||
*/
|
||||
int height() const { return m_height; }
|
||||
|
||||
/**
|
||||
* @brief Get the number of frames in the image or animation.
|
||||
* @return The number of frames in the image.
|
||||
*/
|
||||
size_t getFrameCount() const { return m_frame_count; }
|
||||
|
||||
/**
|
||||
* @brief Get the type of the image (e.g., color format, depth).
|
||||
* @return The type of the image.
|
||||
*/
|
||||
virtual int type() const { return m_type; }
|
||||
|
||||
/**
|
||||
* @brief Fetch a specific EXIF tag from the image's metadata.
|
||||
* @param tag The EXIF tag to retrieve.
|
||||
* @return The EXIF entry corresponding to the tag.
|
||||
*/
|
||||
ExifEntry_t getExifTag(const ExifTagName tag) const;
|
||||
virtual bool setSource( const String& filename );
|
||||
virtual bool setSource( const Mat& buf );
|
||||
virtual int setScale( const int& scale_denom );
|
||||
virtual bool readHeader() = 0;
|
||||
virtual bool readData( Mat& img ) = 0;
|
||||
|
||||
/**
|
||||
* @brief Set the image source from a file.
|
||||
* @param filename The name of the file to load the image from.
|
||||
* @return true if the source was successfully set, false otherwise.
|
||||
*/
|
||||
virtual bool setSource(const String& filename);
|
||||
|
||||
/**
|
||||
* @brief Set the image source from a memory buffer.
|
||||
* @param buf The buffer containing the image data.
|
||||
* @return true if the source was successfully set, false otherwise.
|
||||
*/
|
||||
virtual bool setSource(const Mat& buf);
|
||||
|
||||
/**
|
||||
* @brief Set the scale factor for the image.
|
||||
* @param scale_denom The denominator of the scale factor (image is scaled down by 1/scale_denom).
|
||||
* @return The scale factor that was set.
|
||||
*/
|
||||
virtual int setScale(const int& scale_denom);
|
||||
|
||||
/**
|
||||
* @brief Read the image header to extract basic properties (width, height, type).
|
||||
* This is a pure virtual function that must be implemented by derived classes.
|
||||
* @return true if the header was successfully read, false otherwise.
|
||||
*/
|
||||
virtual bool readHeader() = 0;
|
||||
|
||||
/**
|
||||
* @brief Read the image data into a Mat object.
|
||||
* This is a pure virtual function that must be implemented by derived classes.
|
||||
* @param img The Mat object where the image data will be stored.
|
||||
* @return true if the data was successfully read, false otherwise.
|
||||
*/
|
||||
virtual bool readData(Mat& img) = 0;
|
||||
|
||||
/**
|
||||
* @brief Set whether to decode the image in RGB order instead of the default BGR.
|
||||
* @param useRGB If true, the image will be decoded in RGB order.
|
||||
*/
|
||||
virtual void setRGB(bool useRGB);
|
||||
|
||||
/// Called after readData to advance to the next page, if any.
|
||||
/**
|
||||
* @brief Advance to the next page or frame of the image, if applicable.
|
||||
* The default implementation does nothing and returns false.
|
||||
* @return true if there is another page/frame, false otherwise.
|
||||
*/
|
||||
virtual bool nextPage() { return false; }
|
||||
|
||||
/**
|
||||
* @brief Get the length of the format signature used to identify the image format.
|
||||
* @return The length of the signature.
|
||||
*/
|
||||
virtual size_t signatureLength() const;
|
||||
virtual bool checkSignature( const String& signature ) const;
|
||||
|
||||
/**
|
||||
* @brief Check if the provided signature matches the expected format signature.
|
||||
* @param signature The signature to check.
|
||||
* @return true if the signature matches, false otherwise.
|
||||
*/
|
||||
virtual bool checkSignature(const String& signature) const;
|
||||
|
||||
/**
|
||||
* @brief Create and return a new instance of the derived image decoder.
|
||||
* @return A new ImageDecoder object.
|
||||
*/
|
||||
virtual ImageDecoder newDecoder() const;
|
||||
|
||||
protected:
|
||||
int m_width; // width of the image ( filled by readHeader )
|
||||
int m_height; // height of the image ( filled by readHeader )
|
||||
int m_type;
|
||||
int m_scale_denom;
|
||||
String m_filename;
|
||||
String m_signature;
|
||||
Mat m_buf;
|
||||
bool m_buf_supported;
|
||||
bool m_use_rgb; // flag of decode image as RGB order instead of BGR.
|
||||
ExifReader m_exif;
|
||||
size_t m_frame_count;
|
||||
int m_width; ///< Width of the image (set by readHeader).
|
||||
int m_height; ///< Height of the image (set by readHeader).
|
||||
int m_type; ///< Image type (e.g., color depth, channel order).
|
||||
int m_scale_denom; ///< Scale factor denominator for resizing the image.
|
||||
String m_filename; ///< Name of the file that is being decoded.
|
||||
String m_signature; ///< Signature for identifying the image format.
|
||||
Mat m_buf; ///< Buffer holding the image data when loaded from memory.
|
||||
bool m_buf_supported; ///< Flag indicating whether buffer-based loading is supported.
|
||||
bool m_use_rgb; ///< Flag indicating whether to decode the image in RGB order.
|
||||
ExifReader m_exif; ///< Object for reading EXIF metadata from the image.
|
||||
size_t m_frame_count; ///< Number of frames in the image (for animations and multi-page images).
|
||||
};
|
||||
|
||||
|
||||
///////////////////////////// base class for encoders ////////////////////////////
|
||||
class BaseImageEncoder
|
||||
{
|
||||
/**
|
||||
* @brief Base class for image encoders.
|
||||
*
|
||||
* The BaseImageEncoder class provides an abstract interface for encoding images in various formats.
|
||||
* It defines common functionality like setting the destination (file or memory buffer), checking if
|
||||
* the format supports a specific image depth, and writing image data. Derived classes must implement
|
||||
* methods like writing the image data to handle format-specific encoding logic.
|
||||
*/
|
||||
class BaseImageEncoder {
|
||||
public:
|
||||
/**
|
||||
* @brief Constructor for BaseImageEncoder.
|
||||
* Initializes the object and sets default values for member variables.
|
||||
*/
|
||||
BaseImageEncoder();
|
||||
virtual ~BaseImageEncoder() {}
|
||||
virtual bool isFormatSupported( int depth ) const;
|
||||
|
||||
virtual bool setDestination( const String& filename );
|
||||
virtual bool setDestination( std::vector<uchar>& buf );
|
||||
virtual bool write( const Mat& img, const std::vector<int>& params ) = 0;
|
||||
/**
|
||||
* @brief Virtual destructor for BaseImageEncoder.
|
||||
* Ensures proper cleanup of derived classes when deleted via a pointer to BaseImageEncoder.
|
||||
*/
|
||||
virtual ~BaseImageEncoder() {}
|
||||
|
||||
/**
|
||||
* @brief Checks if the image format supports a specific image depth.
|
||||
* @param depth The depth (bit depth) of the image.
|
||||
* @return true if the format supports the specified depth, false otherwise.
|
||||
*/
|
||||
virtual bool isFormatSupported(int depth) const;
|
||||
|
||||
/**
|
||||
* @brief Set the destination for encoding as a file.
|
||||
* @param filename The name of the file to which the image will be written.
|
||||
* @return true if the destination was successfully set, false otherwise.
|
||||
*/
|
||||
virtual bool setDestination(const String& filename);
|
||||
|
||||
/**
|
||||
* @brief Set the destination for encoding as a memory buffer.
|
||||
* @param buf A reference to the buffer where the encoded image data will be stored.
|
||||
* @return true if the destination was successfully set, false otherwise.
|
||||
*/
|
||||
virtual bool setDestination(std::vector<uchar>& buf);
|
||||
|
||||
/**
|
||||
* @brief Encode and write the image data.
|
||||
* This is a pure virtual function that must be implemented by derived classes.
|
||||
* @param img The Mat object containing the image data to be encoded.
|
||||
* @param params A vector of parameters controlling the encoding process (e.g., compression level).
|
||||
* @return true if the image was successfully written, false otherwise.
|
||||
*/
|
||||
virtual bool write(const Mat& img, const std::vector<int>& params) = 0;
|
||||
|
||||
/**
|
||||
* @brief Encode and write multiple images (e.g., for animated formats).
|
||||
* By default, this method returns false, indicating that the format does not support multi-image encoding.
|
||||
* @param img_vec A vector of Mat objects containing the images to be encoded.
|
||||
* @param params A vector of parameters controlling the encoding process.
|
||||
* @return true if multiple images were successfully written, false otherwise.
|
||||
*/
|
||||
virtual bool writemulti(const std::vector<Mat>& img_vec, const std::vector<int>& params);
|
||||
|
||||
/**
|
||||
* @brief Get a description of the image encoder (e.g., the format it supports).
|
||||
* @return A string describing the encoder.
|
||||
*/
|
||||
virtual String getDescription() const;
|
||||
|
||||
/**
|
||||
* @brief Create and return a new instance of the derived image encoder.
|
||||
* @return A new ImageEncoder object.
|
||||
*/
|
||||
virtual ImageEncoder newEncoder() const;
|
||||
|
||||
/**
|
||||
* @brief Throw an exception based on the last error encountered during encoding.
|
||||
* This method can be used to propagate error conditions back to the caller.
|
||||
*/
|
||||
virtual void throwOnEror() const;
|
||||
|
||||
protected:
|
||||
String m_description;
|
||||
|
||||
String m_filename;
|
||||
std::vector<uchar>* m_buf;
|
||||
bool m_buf_supported;
|
||||
|
||||
String m_last_error;
|
||||
String m_description; ///< Description of the encoder (e.g., format name, capabilities).
|
||||
String m_filename; ///< Destination file name for encoded data.
|
||||
std::vector<uchar>* m_buf; ///< Pointer to the buffer for encoded data if using memory-based destination.
|
||||
bool m_buf_supported; ///< Flag indicating whether buffer-based encoding is supported.
|
||||
String m_last_error; ///< Stores the last error message encountered during encoding.
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -81,20 +81,17 @@ PFMDecoder::~PFMDecoder()
|
||||
|
||||
PFMDecoder::PFMDecoder() : m_scale_factor(0), m_swap_byte_order(false)
|
||||
{
|
||||
m_strm.close();
|
||||
m_buf_supported = true;
|
||||
}
|
||||
|
||||
bool PFMDecoder::readHeader()
|
||||
{
|
||||
if (m_buf.empty()) {
|
||||
if (!m_strm.open(m_filename)) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!m_strm.open(m_buf)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (!m_buf.empty())
|
||||
m_strm.open(m_buf);
|
||||
else
|
||||
m_strm.open(m_filename);
|
||||
|
||||
if( !m_strm.isOpened()) return false;
|
||||
|
||||
if (m_strm.getByte() != 'P') {
|
||||
CV_Error(Error::StsError, "Unexpected file type (expected P)");
|
||||
@@ -177,6 +174,7 @@ void PFMDecoder::close()
|
||||
PFMEncoder::PFMEncoder()
|
||||
{
|
||||
m_description = "Portable image format - float (*.pfm)";
|
||||
m_buf_supported = true;
|
||||
}
|
||||
|
||||
PFMEncoder::~PFMEncoder()
|
||||
|
||||
@@ -1,44 +1,6 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
// This file is part of OpenCV project.
|
||||
// It is subject to the license terms in the LICENSE file found in the top-level
|
||||
// directory of this distribution and at http://opencv.org/license.html
|
||||
|
||||
#include "precomp.hpp"
|
||||
#include "grfmt_sunras.hpp"
|
||||
@@ -60,6 +22,7 @@ SunRasterDecoder::SunRasterDecoder()
|
||||
m_encoding = RAS_STANDARD;
|
||||
m_maptype = RMT_NONE;
|
||||
m_maplength = 0;
|
||||
m_buf_supported = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -82,7 +45,12 @@ bool SunRasterDecoder::readHeader()
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
if( !m_strm.open( m_filename )) return false;
|
||||
if (!m_buf.empty())
|
||||
m_strm.open(m_buf);
|
||||
else
|
||||
m_strm.open(m_filename);
|
||||
|
||||
if( !m_strm.isOpened()) return false;
|
||||
|
||||
try
|
||||
{
|
||||
@@ -389,6 +357,7 @@ bad_decoding_end:
|
||||
SunRasterEncoder::SunRasterEncoder()
|
||||
{
|
||||
m_description = "Sun raster files (*.sr;*.ras)";
|
||||
m_buf_supported = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -408,7 +377,18 @@ bool SunRasterEncoder::write( const Mat& img, const std::vector<int>& )
|
||||
int fileStep = (width*channels + 1) & -2;
|
||||
WMByteStream strm;
|
||||
|
||||
if( strm.open(m_filename) )
|
||||
if (m_buf) {
|
||||
if (!strm.open(*m_buf)) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
m_buf->reserve(height * fileStep + 32);
|
||||
}
|
||||
}
|
||||
else
|
||||
strm.open(m_filename);
|
||||
|
||||
if( strm.isOpened() )
|
||||
{
|
||||
CHECK_WRITE(strm.putBytes( fmtSignSunRas, (int)strlen(fmtSignSunRas) ));
|
||||
CHECK_WRITE(strm.putDWord( width ));
|
||||
|
||||
Reference in New Issue
Block a user