root/OpenSceneGraph/trunk/src/osgPlugins/quicktime/QTImportExport.h @ 13041

Revision 13041, 2.2 kB (checked in by robert, 3 years ago)

Ran script to remove trailing spaces and tabs

  • Property svn:eol-style set to native
Line 
1/*
2 *  QTImportExport.h
3 *  cefix
4 *
5 *  Created by Stephan Huber on 07.02.08.
6 *  Copyright 2008 StephanMaximilianHuber, digitalmind. All rights reserved.
7 *
8 */
9
10#include <osg/Image>
11
12#ifndef QT_IMPORT_EXPORT_HEADER
13#define QT_IMPORT_EXPORT_HEADER
14
15/** small helper class handling the im- and export of image data via quicktime */
16class QuicktimeImportExport {
17
18    public:
19        /** ctor */
20        QuicktimeImportExport();
21
22        /** readFromString tries to read a chunk of bytes and interpret it as an image.
23         *  @param istream the input stream
24         *  @param fileTypeHint you can speed up the conversion by providing a filename with extension, so quicktime has not to guess the image's type
25         *  @param sizeHint useful, if you are streaming data, if you provide a sizeHint ony sizeHint bytes are read from the stream
26         */
27        osg::Image* readFromStream(std::istream & inStream, const std::string& fileTypeHint, long sizeHint = 0);
28
29        /** writes an osg::Image to a stream, using fileTypeHint as a hint whar format you want to write. */
30        void writeToStream(std::ostream& outStream, osg::Image* image, const std::string& fileTypeHint) ;
31
32        /** get the last error-message */
33        const std::string getLastErrorString() { return _lastError; }
34
35        /** return true if no error occured */
36        bool success() { return (_error == false); }
37
38    protected:
39
40        /** flips an image */
41        void flipImage(unsigned char* buffer, int bytesPerPixel, unsigned int width, unsigned height);
42
43        /** do some swizzling, so osg can use the image */
44        unsigned char* pepareBufferForOSG(unsigned char * buffer, int bytesPerPixel, unsigned int width, unsigned height);
45
46        /** do some swizzling, so quicktime can use the image */
47        unsigned char* prepareBufferForQuicktime(unsigned char* buffer, GLenum pixelFormat, int bytesPerPixel, unsigned int width, unsigned int height)  ;
48
49        /** sets an error-msg */
50        void setError(const std::string& msg) { _lastError = msg; _error = true; }
51
52        /** do the import */
53        osg::Image* doImport(unsigned char* buffer, unsigned int dataSize, const std::string& fileTypeHint);
54
55
56    private:
57        bool            _error;
58        std::string _lastError;
59
60
61};
62
63
64
65#endif
Note: See TracBrowser for help on using the browser.