Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions include/cinder/ImageSourceFileWic.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,16 @@
#include "cinder/Cinder.h"
#include "cinder/ImageIO.h"
#include "cinder/Exception.h"
#include "cinder/msw/CinderMsw.h"

#include <guiddef.h>

// WIC forward declarations
struct IWICImagingFactory;
struct IWICBitmapFrameDecode;
struct IWICStream;
struct IWICComponentEnumerator;
struct IWICBitmapCodecInfo;

namespace cinder {

Expand All @@ -52,12 +55,12 @@ class ImageSourceFileWic : public ImageSource {

bool processFormat( const ::GUID &guid, ::GUID *convertGUID );

std::shared_ptr<IWICBitmapFrameDecode> mFrame;
std::shared_ptr<IWICStream> mStream;
ci::BufferRef mBuffer;
bool mRequiresConversion;
int32_t mRowBytes;
::GUID mPixelFormat, mConvertPixelFormat;
msw::ComPtr<IWICBitmapFrameDecode> mFrame;
msw::ComPtr<IWICStream> mStream;
ci::BufferRef mBuffer;
bool mRequiresConversion;
int32_t mRowBytes;
::GUID mPixelFormat, mConvertPixelFormat;
};

class ImageSourceFileWicExceptionUnsupportedData : public ImageIoException {
Expand Down
23 changes: 13 additions & 10 deletions include/cinder/ImageTargetFileWic.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,15 @@

#include "cinder/Cinder.h"
#include "cinder/ImageIo.h"
#include "cinder/msw/CinderMsw.h"

#ifndef GUID
typedef struct _GUID GUID;
#endif
struct IWICBitmapEncoder;
struct IWICBitmapFrameEncode;
struct IWICComponentEnumerator;
struct IWICBitmapCodecInfo;

namespace cinder {

Expand All @@ -38,24 +41,24 @@ typedef std::shared_ptr<class ImageTargetFileWic> ImageTargetFileWicRef;
class ImageTargetFileWic : public ImageTarget {
public:
static ImageTargetRef create( DataTargetRef dataTarget, ImageSourceRef imageSource, ImageTarget::Options options, const std::string &extensionData );

void* getRowPointer( int32_t row ) override;
void finalize() override;

static void registerSelf();

protected:
ImageTargetFileWic( DataTargetRef dataTarget, ImageSourceRef imageSource, ImageTarget::Options options, const std::string &extensionData );

void setupPixelFormat( const GUID &guid );

std::shared_ptr<uint8_t> mData;
int32_t mRowBytes;
DataTargetRef mDataTarget;
const GUID *mCodecGUID;
std::shared_ptr<IWICBitmapEncoder> mEncoder;
std::shared_ptr<IWICBitmapFrameEncode> mBitmapFrame;
std::shared_ptr<uint8_t> mData;
int32_t mRowBytes;
DataTargetRef mDataTarget;
const GUID *mCodecGUID;

msw::ComPtr<IWICBitmapEncoder> mEncoder;
msw::ComPtr<IWICBitmapFrameEncode> mBitmapFrame;
};

} // namespace cinder
12 changes: 8 additions & 4 deletions include/cinder/msw/CinderMsw.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,14 @@ CI_API inline vec2 toVec2( const ::POINTFX& p )
CI_API void ComDelete( void* p );

//! Functor version that calls Release() on a com-managed object
struct CI_API ComDeleter{ template<typename T> void operator()( T* p ){ if( p ) p->Release();
}}; // namespace cinder::msw
struct CI_API ComDeleter {
template<typename T>
void operator()( T* p )
{
if( p )
p->Release();
}
};

template<typename T>
using ManagedComRef = std::shared_ptr<T>;
Expand Down Expand Up @@ -86,8 +92,6 @@ ManagedComPtr<T> makeComUnique( T* p )
- Move operations transfer ownership without ref-counting */
template<typename T>
class CI_API ComPtr {
static_assert( std::is_base_of<IUnknown, T>::value, "ComPtr<T>: T must derive from IUnknown" );

public:
ComPtr() noexcept
: ptr( nullptr )
Expand Down
Loading