1 /*
2    Source File : InputPredictorPNGOptimumStream.h
3 
4 
5    Copyright 2011 Gal Kahana PDFWriter
6 
7    Licensed under the Apache License, Version 2.0 (the "License");
8    you may not use this file except in compliance with the License.
9    You may obtain a copy of the License at
10 
11        http://www.apache.org/licenses/LICENSE-2.0
12 
13    Unless required by applicable law or agreed to in writing, software
14    distributed under the License is distributed on an "AS IS" BASIS,
15    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16    See the License for the specific language governing permissions and
17    limitations under the License.
18 
19 
20 */
21 #pragma once
22 
23 #include "IByteReader.h"
24 
25 class InputPredictorPNGOptimumStream : public IByteReader
26 {
27 public:
28 	InputPredictorPNGOptimumStream(void);
29 	// Takes ownership (use Assign(NULL,0) to unassign)
30 	InputPredictorPNGOptimumStream(IByteReader* inSourceStream,IOBasicTypes::LongBufferSizeType inColumns);
31 	virtual ~InputPredictorPNGOptimumStream(void);
32 
33 	virtual IOBasicTypes::LongBufferSizeType Read(IOBasicTypes::Byte* inBuffer,IOBasicTypes::LongBufferSizeType inBufferSize);
34 
35 	virtual bool NotEnded();
36 
37 	// Takes ownership (use Assign(NULL,0) to unassign)
38 	void Assign(IByteReader* inSourceStream,IOBasicTypes::LongBufferSizeType inColumns);
39 
40 private:
41 	IByteReader* mSourceStream;
42 	IOBasicTypes::Byte* mBuffer;
43 	IOBasicTypes::LongBufferSizeType mBufferSize;
44 	IOBasicTypes::Byte* mIndex;
45 	IOBasicTypes::Byte mFunctionType;
46 
47 	IOBasicTypes::Byte* mUpValues;
48 
49 	void DecodeNextByte(IOBasicTypes::Byte& outDecodedByte);
50 	char PaethPredictor(char inLeft,char inUp,char inUpLeft);
51 };
52