Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #pragma once
00024
00025 #include "cinder/Cinder.h"
00026 #include "cinder/Url.h"
00027 #include "cinder/Surface.h"
00028 #include "cinder/ImageIo.h"
00029
00030 #include <string>
00031
00032 #if defined( CINDER_MAC )
00033 #if ! defined( __LP64__ )
00034 #include <QuickTime/QuickTime.h>
00035 #else
00036 #include <CoreVideo/CoreVideo.h>
00037 #endif
00038 #else
00039 #pragma push_macro( "__STDC_CONSTANT_MACROS" )
00040 #pragma push_macro( "_STDINT_H" )
00041 #undef __STDC_CONSTANT_MACROS
00042 #if _MSC_VER >= 1600 // VC10 or greater
00043 #define _STDINT_H
00044 #endif
00045 #include <QTML.h>
00046 #include <Movies.h>
00047 #pragma pop_macro( "_STDINT_H" )
00048 #pragma pop_macro( "__STDC_CONSTANT_MACROS" )
00049 #endif
00050
00051 namespace cinder { namespace qtime {
00052
00053 #if ! defined( __LP64__ )
00054
00055 bool dictionarySetValue( CFMutableDictionaryRef dict, CFStringRef key, SInt32 value );
00056 bool dictionarySetPixelBufferPixelFormatType( bool alpha, CFMutableDictionaryRef dict );
00057 bool dictionarySetPixelBufferSize( const unsigned int width, const unsigned int height, CFMutableDictionaryRef dict );
00058 bool dictionarySetPixelBufferBytesPerRowAlignment( CFMutableDictionaryRef dict );
00059 void dictionarySetPixelBufferOpenGLCompatibility( CFMutableDictionaryRef dict );
00060 bool dictionarySetPixelBufferOptions( unsigned int width, unsigned int height, bool alpha, CFMutableDictionaryRef *pixelBufferOptions );
00061 CFMutableDictionaryRef initQTVisualContextOptions( int width, int height, bool alpha );
00062
00063 ::Movie openMovieFromUrl( const Url &url );
00064 ::Movie openMovieFromPath( const fs::path &path );
00065 ::Movie openMovieFromMemory( const void *data, size_t dataSize, const std::string &fileNameHint, const std::string &mimeTypeHint );
00066
00068
00070 static void CVPixelBufferDealloc( void *refcon );
00072 Surface8u convertCVPixelBufferToSurface( CVPixelBufferRef pixelBufferRef );
00073
00074 #endif // ! defined( __LP64__ )
00075
00076 typedef std::shared_ptr<class ImageTargetCvPixelBuffer> ImageTargetCvPixelBufferRef;
00077
00078 class ImageTargetCvPixelBuffer : public ci::ImageTarget {
00079 public:
00080 static ImageTargetCvPixelBufferRef createRef( ImageSourceRef imageSource, bool convertToYpCbCr = false );
00081 ~ImageTargetCvPixelBuffer();
00082
00083 virtual void* getRowPointer( int32_t row );
00084 virtual void finalize();
00085
00086 ::CVPixelBufferRef getCvPixelBuffer() const { return mPixelBufferRef; }
00087
00088 protected:
00089 ImageTargetCvPixelBuffer( ImageSourceRef imageSource, bool convertToYpCbCr );
00090
00091 void convertDataToYpCbCr();
00092 void convertDataToAYpCbCr();
00093
00094 ::CVPixelBufferRef mPixelBufferRef;
00095 size_t mRowBytes;
00096 uint8_t *mData;
00097 bool mConvertToYpCbCr;
00098 };
00099
00101 CVPixelBufferRef createCvPixelBuffer( ImageSourceRef imageSource, bool convertToYpCbCr = false );
00102
00103 #if defined( CINDER_MSW )
00104 typedef std::shared_ptr<class ImageTargetGWorld> ImageTargetGWorldRef;
00105
00106 class ImageTargetGWorld : public ci::ImageTarget {
00107 public:
00108 static ImageTargetGWorldRef createRef( ImageSourceRef imageSource );
00109
00110 virtual void* getRowPointer( int32_t row );
00111 virtual void finalize();
00112
00113 ::GWorldPtr getGWorld() const { return mGWorld; }
00114
00115 protected:
00116 ImageTargetGWorld( ImageSourceRef imageSource );
00117
00118 ::GWorldPtr mGWorld;
00119 ::PixMapHandle mPixMap;
00120 size_t mRowBytes;
00121 uint8_t *mData;
00122 };
00123
00125 GWorldPtr createGWorld( ImageSourceRef imageSource );
00126 #endif // defined( CINDER_MSW )
00127
00128 } }