VideoTools
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
grpng_none.cpp
Go to the documentation of this file.
1 //
2 // Copyright (C) 2017 Graeme Walker
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 // ===
17 //
18 // grpng_none.cpp
19 //
20 
21 #include "grpng.h"
22 #include <stdexcept>
23 
24 static const char * help = ": install libpng and re-run configure" ;
25 class Gr::PngReaderImp {} ;
26 class Gr::PngWriterImp {} ;
27 bool Gr::Png::available() { return false ; }
28 Gr::PngReader::PngReader( int , bool ) {}
30 void Gr::PngReader::setup( int , bool ) { throw Png::Error( "pngreader not implemented" + std::string(help) ) ; }
31 void Gr::PngReader::decode( ImageData & , const char * , size_t ) { throw Png::Error( "pngreader not implemented" + std::string(help) ) ; }
32 void Gr::PngReader::decode( ImageData & , const G::Path & ) { throw Png::Error( "pngreader not implemented" + std::string(help) ) ; }
33 void Gr::PngReader::decode( ImageData & , const ImageBuffer & ) { throw Png::Error( "pngreader not implemented" + std::string(help) ) ; }
34 Gr::PngReader::Map Gr::PngReader::tags() const { return Map() ; }
35 Gr::PngWriter::PngWriter( const ImageData & , Map ) { throw Png::Error( "pngwriter not implemented" + std::string(help) ) ; }
36 void Gr::PngWriter::write( const G::Path & ) {}
38 
39 void Gr::PngInfo::init( std::istream & stream )
40 {
41  unsigned char buffer[31] = { 0 } ;
42  stream.get( reinterpret_cast<char*>(buffer) , sizeof(buffer) ) ;
43  std::pair<int,int> pair = parse( buffer , stream.gcount() ) ;
44  m_dx = pair.first ;
45  m_dy = pair.second ;
46 }
47 
48 void Gr::PngInfo::init( const unsigned char * p , size_t n )
49 {
50  std::pair<int,int> pair = parse( p , n ) ;
51  m_dx = pair.first ;
52  m_dy = pair.second ;
53 }
54 
55 /// \file grpng_none.cpp
~PngReader()
Destructor.
Definition: grpng_none.cpp:29
Map tags() const
Returns the text tags from the last decode().
Definition: grpng_none.cpp:34
A holder for image data, having eight bits per sample and one or three channels.
Definition: grimagedata.h:46
Vectors ImageBuffer
An ImageBuffer is used to hold raw image data, typically in more than one chunk.
Definition: grimagebuffer.h:47
PngWriter(const ImageData &, Map tags=Map())
Constructor with the raw image data prepared in a ImageData object.
Definition: grpng_none.cpp:35
A private pimple-pattern class for Gr::PngWriter.
Definition: grpng_none.cpp:26
void decode(ImageData &out, const G::Path &in)
Decodes a png file into an image. Throws on error.
Definition: grpng_none.cpp:32
A private pimple-pattern class for Gr::PngReader.
Definition: grpng_none.cpp:25
PngReader(int scale=1, bool monochrome_out=false)
Constructor.
Definition: grpng_none.cpp:28
void setup(int scale, bool monochrome_out=false)
Sets the decoding scale factor.
Definition: grpng_none.cpp:30
static bool available()
Returns true if the png library is available.
Definition: grpng_none.cpp:27
A Path object represents a file system path.
Definition: gpath.h:72
Abstract interface for Gr::PngWriter::write().
Definition: grpng.h:158
void write(const G::Path &path)
Writes to file.
Definition: grpng_none.cpp:36