Path: blob/master/modules/imgcodecs/src/grfmt_base.cpp
16337 views
/*M///////////////////////////////////////////////////////////////////////////////////////1//2// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.3//4// By downloading, copying, installing or using the software you agree to this license.5// If you do not agree to this license, do not download, install,6// copy or use the software.7//8//9// Intel License Agreement10// For Open Source Computer Vision Library11//12// Copyright (C) 2000, Intel Corporation, all rights reserved.13// Third party copyrights are property of their respective owners.14//15// Redistribution and use in source and binary forms, with or without modification,16// are permitted provided that the following conditions are met:17//18// * Redistribution's of source code must retain the above copyright notice,19// this list of conditions and the following disclaimer.20//21// * Redistribution's in binary form must reproduce the above copyright notice,22// this list of conditions and the following disclaimer in the documentation23// and/or other materials provided with the distribution.24//25// * The name of Intel Corporation may not be used to endorse or promote products26// derived from this software without specific prior written permission.27//28// This software is provided by the copyright holders and contributors "as is" and29// any express or implied warranties, including, but not limited to, the implied30// warranties of merchantability and fitness for a particular purpose are disclaimed.31// In no event shall the Intel Corporation or contributors be liable for any direct,32// indirect, incidental, special, exemplary, or consequential damages33// (including, but not limited to, procurement of substitute goods or services;34// loss of use, data, or profits; or business interruption) however caused35// and on any theory of liability, whether in contract, strict liability,36// or tort (including negligence or otherwise) arising in any way out of37// the use of this software, even if advised of the possibility of such damage.38//39//M*/4041#include "precomp.hpp"4243#include "grfmt_base.hpp"44#include "bitstrm.hpp"4546namespace cv47{4849BaseImageDecoder::BaseImageDecoder()50{51m_width = m_height = 0;52m_type = -1;53m_buf_supported = false;54m_scale_denom = 1;55}5657bool BaseImageDecoder::setSource( const String& filename )58{59m_filename = filename;60m_buf.release();61return true;62}6364bool BaseImageDecoder::setSource( const Mat& buf )65{66if( !m_buf_supported )67return false;68m_filename = String();69m_buf = buf;70return true;71}7273size_t BaseImageDecoder::signatureLength() const74{75return m_signature.size();76}7778bool BaseImageDecoder::checkSignature( const String& signature ) const79{80size_t len = signatureLength();81return signature.size() >= len && memcmp( signature.c_str(), m_signature.c_str(), len ) == 0;82}8384int BaseImageDecoder::setScale( const int& scale_denom )85{86int temp = m_scale_denom;87m_scale_denom = scale_denom;88return temp;89}9091ImageDecoder BaseImageDecoder::newDecoder() const92{93return ImageDecoder();94}9596BaseImageEncoder::BaseImageEncoder()97{98m_buf = 0;99m_buf_supported = false;100}101102bool BaseImageEncoder::isFormatSupported( int depth ) const103{104return depth == CV_8U;105}106107String BaseImageEncoder::getDescription() const108{109return m_description;110}111112bool BaseImageEncoder::setDestination( const String& filename )113{114m_filename = filename;115m_buf = 0;116return true;117}118119bool BaseImageEncoder::setDestination( std::vector<uchar>& buf )120{121if( !m_buf_supported )122return false;123m_buf = &buf;124m_buf->clear();125m_filename = String();126return true;127}128129bool BaseImageEncoder::writemulti(const std::vector<Mat>&, const std::vector<int>& )130{131return false;132}133134ImageEncoder BaseImageEncoder::newEncoder() const135{136return ImageEncoder();137}138139void BaseImageEncoder::throwOnEror() const140{141if(!m_last_error.empty())142{143String msg = "Raw image encoder error: " + m_last_error;144CV_Error( CV_BadImageSize, msg.c_str() );145}146}147148}149150/* End of file. */151152153