Path: blob/master/modules/imgcodecs/src/grfmt_tiff.hpp
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// License Agreement10// For Open Source Computer Vision Library11//12// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.13// Copyright (C) 2009, Willow Garage Inc., all rights reserved.14// Third party copyrights are property of their respective owners.15//16// Redistribution and use in source and binary forms, with or without modification,17// are permitted provided that the following conditions are met:18//19// * Redistribution's of source code must retain the above copyright notice,20// this list of conditions and the following disclaimer.21//22// * Redistribution's in binary form must reproduce the above copyright notice,23// this list of conditions and the following disclaimer in the documentation24// and/or other materials provided with the distribution.25//26// * The name of the copyright holders may not be used to endorse or promote products27// derived from this software without specific prior written permission.28//29// This software is provided by the copyright holders and contributors "as is" and30// any express or implied warranties, including, but not limited to, the implied31// warranties of merchantability and fitness for a particular purpose are disclaimed.32// In no event shall the Intel Corporation or contributors be liable for any direct,33// indirect, incidental, special, exemplary, or consequential damages34// (including, but not limited to, procurement of substitute goods or services;35// loss of use, data, or profits; or business interruption) however caused36// and on any theory of liability, whether in contract, strict liability,37// or tort (including negligence or otherwise) arising in any way out of38// the use of this software, even if advised of the possibility of such damage.39//40//M*/4142#ifndef _GRFMT_TIFF_H_43#define _GRFMT_TIFF_H_4445#include "grfmt_base.hpp"4647#ifdef HAVE_TIFF4849namespace cv50{5152// native simple TIFF codec53enum TiffCompression54{55TIFF_UNCOMP = 1,56TIFF_HUFFMAN = 2,57TIFF_PACKBITS = 3277358};5960enum TiffByteOrder61{62TIFF_ORDER_II = 0x4949,63TIFF_ORDER_MM = 0x4d4d64};656667enum TiffTag68{69TIFF_TAG_WIDTH = 256,70TIFF_TAG_HEIGHT = 257,71TIFF_TAG_BITS_PER_SAMPLE = 258,72TIFF_TAG_COMPRESSION = 259,73TIFF_TAG_PHOTOMETRIC = 262,74TIFF_TAG_STRIP_OFFSETS = 273,75TIFF_TAG_STRIP_COUNTS = 279,76TIFF_TAG_SAMPLES_PER_PIXEL = 277,77TIFF_TAG_ROWS_PER_STRIP = 278,78TIFF_TAG_PLANAR_CONFIG = 284,79TIFF_TAG_COLOR_MAP = 32080};818283enum TiffFieldType84{85TIFF_TYPE_BYTE = 1,86TIFF_TYPE_SHORT = 3,87TIFF_TYPE_LONG = 488};899091// libtiff based TIFF codec92class TiffDecoder CV_FINAL : public BaseImageDecoder93{94public:95TiffDecoder();96virtual ~TiffDecoder() CV_OVERRIDE;9798bool readHeader() CV_OVERRIDE;99bool readData( Mat& img ) CV_OVERRIDE;100void close();101bool nextPage() CV_OVERRIDE;102103size_t signatureLength() const CV_OVERRIDE;104bool checkSignature( const String& signature ) const CV_OVERRIDE;105ImageDecoder newDecoder() const CV_OVERRIDE;106107protected:108void* m_tif;109int normalizeChannelsNumber(int channels) const;110bool readData_32FC3(Mat& img);111bool readData_32FC1(Mat& img);112bool m_hdr;113size_t m_buf_pos;114115private:116TiffDecoder(const TiffDecoder &); // copy disabled117TiffDecoder& operator=(const TiffDecoder &); // assign disabled118};119120// ... and writer121class TiffEncoder CV_FINAL : public BaseImageEncoder122{123public:124TiffEncoder();125virtual ~TiffEncoder() CV_OVERRIDE;126127bool isFormatSupported( int depth ) const CV_OVERRIDE;128129bool write( const Mat& img, const std::vector<int>& params ) CV_OVERRIDE;130131bool writemulti(const std::vector<Mat>& img_vec, const std::vector<int>& params) CV_OVERRIDE;132133ImageEncoder newEncoder() const CV_OVERRIDE;134135protected:136void writeTag( WLByteStream& strm, TiffTag tag,137TiffFieldType fieldType,138int count, int value );139140bool writeLibTiff( const std::vector<Mat>& img_vec, const std::vector<int>& params );141bool write_32FC3( const Mat& img );142bool write_32FC1( const Mat& img );143144private:145TiffEncoder(const TiffEncoder &); // copy disabled146TiffEncoder& operator=(const TiffEncoder &); // assign disabled147};148149}150151#endif // HAVE_TIFF152153#endif/*_GRFMT_TIFF_H_*/154155156