ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

pict.h

Go to the documentation of this file.
00001 /* ScummVM - Graphic Adventure Engine
00002  *
00003  * ScummVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the COPYRIGHT
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00031 #ifndef IMAGE_PICT_H
00032 #define IMAGE_PICT_H
00033 
00034 #include "common/array.h"
00035 #include "common/rect.h"
00036 #include "common/scummsys.h"
00037 
00038 #include "image/image_decoder.h"
00039 
00040 namespace Common {
00041 class SeekableReadStream;
00042 }
00043 
00044 namespace Graphics {
00045 struct Surface;
00046 }
00047 
00048 namespace Image {
00049 
00050 #define DECLARE_OPCODE(x) void x(Common::SeekableReadStream &stream)
00051 
00052 class PICTDecoder : public ImageDecoder {
00053 public:
00054     PICTDecoder();
00055     ~PICTDecoder();
00056 
00057     // ImageDecoder API
00058     bool loadStream(Common::SeekableReadStream &stream);
00059     void destroy();
00060     const Graphics::Surface *getSurface() const { return _outputSurface; }
00061     const byte *getPalette() const { return _palette; }
00062     uint16 getPaletteColorCount() const { return _paletteColorCount; }
00063 
00064     struct PixMap {
00065         uint32 baseAddr;
00066         uint16 rowBytes;
00067         Common::Rect bounds;
00068         uint16 pmVersion;
00069         uint16 packType;
00070         uint32 packSize;
00071         uint32 hRes;
00072         uint32 vRes;
00073         uint16 pixelType;
00074         uint16 pixelSize;
00075         uint16 cmpCount;
00076         uint16 cmpSize;
00077         uint32 planeBytes;
00078         uint32 pmTable;
00079         uint32 pmReserved;
00080     };
00081 
00082     static PixMap readPixMap(Common::SeekableReadStream &stream, bool hasBaseAddr = true);
00083 
00084 private:
00085     Common::Rect _imageRect;
00086     byte _palette[256 * 3];
00087     uint16 _paletteColorCount;
00088     Graphics::Surface *_outputSurface;
00089     bool _continueParsing;
00090 
00091     // Utility Functions
00092     void unpackBitsRect(Common::SeekableReadStream &stream, bool withPalette);
00093     void unpackBitsLine(byte *out, uint32 length, Common::SeekableReadStream *stream, byte bitsPerPixel, byte bytesPerPixel);
00094     void skipBitsRect(Common::SeekableReadStream &stream, bool withPalette);
00095     void decodeCompressedQuickTime(Common::SeekableReadStream &stream);
00096     void outputPixelBuffer(byte *&out, byte value, byte bitsPerPixel);
00097 
00098     // Opcodes
00099     typedef void (PICTDecoder::*OpcodeProcPICT)(Common::SeekableReadStream &stream);
00100     struct PICTOpcode {
00101         PICTOpcode() { op = 0; proc = 0; desc = 0; }
00102         PICTOpcode(uint16 o, OpcodeProcPICT p, const char *d) { op = o; proc = p; desc = d; }
00103         uint16 op;
00104         OpcodeProcPICT proc;
00105         const char *desc;
00106     };
00107     Common::Array<PICTOpcode> _opcodes;
00108 
00109     // Common Opcodes
00110     void setupOpcodesCommon();
00111     DECLARE_OPCODE(o_nop);
00112     DECLARE_OPCODE(o_clip);
00113     DECLARE_OPCODE(o_txFont);
00114     DECLARE_OPCODE(o_txFace);
00115     DECLARE_OPCODE(o_pnSize);
00116     DECLARE_OPCODE(o_txSize);
00117     DECLARE_OPCODE(o_txRatio);
00118     DECLARE_OPCODE(o_versionOp);
00119     DECLARE_OPCODE(o_longText);
00120     DECLARE_OPCODE(o_longComment);
00121     DECLARE_OPCODE(o_opEndPic);
00122     DECLARE_OPCODE(o_headerOp);
00123 
00124     // Regular-mode Opcodes
00125     void setupOpcodesNormal();
00126     DECLARE_OPCODE(on_packBitsRect);
00127     DECLARE_OPCODE(on_directBitsRect);
00128     DECLARE_OPCODE(on_compressedQuickTime);
00129 
00130     // QuickTime-mode Opcodes
00131     void setupOpcodesQuickTime();
00132     DECLARE_OPCODE(oq_packBitsRect);
00133     DECLARE_OPCODE(oq_directBitsRect);
00134     DECLARE_OPCODE(oq_compressedQuickTime);
00135 };
00136 
00137 #undef DECLARE_OPCODE
00138 
00139 } // End of namespace Image
00140 
00141 #endif


Generated on Sat Mar 16 2019 05:01:49 for ResidualVM by doxygen 1.7.1
curved edge   curved edge