1*b1cdbd2cSJim Jagielski /************************************************************** 2*b1cdbd2cSJim Jagielski * 3*b1cdbd2cSJim Jagielski * Licensed to the Apache Software Foundation (ASF) under one 4*b1cdbd2cSJim Jagielski * or more contributor license agreements. See the NOTICE file 5*b1cdbd2cSJim Jagielski * distributed with this work for additional information 6*b1cdbd2cSJim Jagielski * regarding copyright ownership. The ASF licenses this file 7*b1cdbd2cSJim Jagielski * to you under the Apache License, Version 2.0 (the 8*b1cdbd2cSJim Jagielski * "License"); you may not use this file except in compliance 9*b1cdbd2cSJim Jagielski * with the License. You may obtain a copy of the License at 10*b1cdbd2cSJim Jagielski * 11*b1cdbd2cSJim Jagielski * http://www.apache.org/licenses/LICENSE-2.0 12*b1cdbd2cSJim Jagielski * 13*b1cdbd2cSJim Jagielski * Unless required by applicable law or agreed to in writing, 14*b1cdbd2cSJim Jagielski * software distributed under the License is distributed on an 15*b1cdbd2cSJim Jagielski * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*b1cdbd2cSJim Jagielski * KIND, either express or implied. See the License for the 17*b1cdbd2cSJim Jagielski * specific language governing permissions and limitations 18*b1cdbd2cSJim Jagielski * under the License. 19*b1cdbd2cSJim Jagielski * 20*b1cdbd2cSJim Jagielski *************************************************************/ 21*b1cdbd2cSJim Jagielski 22*b1cdbd2cSJim Jagielski 23*b1cdbd2cSJim Jagielski 24*b1cdbd2cSJim Jagielski #ifndef THUMBVIEWER_HXX_INCLUDED 25*b1cdbd2cSJim Jagielski #define THUMBVIEWER_HXX_INCLUDED 26*b1cdbd2cSJim Jagielski 27*b1cdbd2cSJim Jagielski #if defined _MSC_VER 28*b1cdbd2cSJim Jagielski #pragma warning(push, 1) 29*b1cdbd2cSJim Jagielski #pragma warning(disable:4917) 30*b1cdbd2cSJim Jagielski #endif 31*b1cdbd2cSJim Jagielski #include <objidl.h> 32*b1cdbd2cSJim Jagielski #include <shlobj.h> 33*b1cdbd2cSJim Jagielski #ifdef __MINGW32__ 34*b1cdbd2cSJim Jagielski #include <algorithm> 35*b1cdbd2cSJim Jagielski using std::min; 36*b1cdbd2cSJim Jagielski using std::max; 37*b1cdbd2cSJim Jagielski #endif 38*b1cdbd2cSJim Jagielski #include <gdiplus.h> 39*b1cdbd2cSJim Jagielski #if defined _MSC_VER 40*b1cdbd2cSJim Jagielski #pragma warning(pop) 41*b1cdbd2cSJim Jagielski #endif 42*b1cdbd2cSJim Jagielski #include <string> 43*b1cdbd2cSJim Jagielski 44*b1cdbd2cSJim Jagielski class CThumbviewer : public IPersistFile, public IExtractImage 45*b1cdbd2cSJim Jagielski { 46*b1cdbd2cSJim Jagielski public: 47*b1cdbd2cSJim Jagielski CThumbviewer(long RefCnt = 1); 48*b1cdbd2cSJim Jagielski virtual ~CThumbviewer(); 49*b1cdbd2cSJim Jagielski 50*b1cdbd2cSJim Jagielski //----------------------------- 51*b1cdbd2cSJim Jagielski // IUnknown methods 52*b1cdbd2cSJim Jagielski //----------------------------- 53*b1cdbd2cSJim Jagielski 54*b1cdbd2cSJim Jagielski virtual HRESULT STDMETHODCALLTYPE QueryInterface( 55*b1cdbd2cSJim Jagielski REFIID riid, 56*b1cdbd2cSJim Jagielski void __RPC_FAR *__RPC_FAR *ppvObject); 57*b1cdbd2cSJim Jagielski 58*b1cdbd2cSJim Jagielski virtual ULONG STDMETHODCALLTYPE AddRef( void); 59*b1cdbd2cSJim Jagielski 60*b1cdbd2cSJim Jagielski virtual ULONG STDMETHODCALLTYPE Release( void); 61*b1cdbd2cSJim Jagielski 62*b1cdbd2cSJim Jagielski //---------------------------- 63*b1cdbd2cSJim Jagielski // IExtractImage methods 64*b1cdbd2cSJim Jagielski //---------------------------- 65*b1cdbd2cSJim Jagielski 66*b1cdbd2cSJim Jagielski virtual HRESULT STDMETHODCALLTYPE Extract(HBITMAP *phBmpImage); 67*b1cdbd2cSJim Jagielski 68*b1cdbd2cSJim Jagielski virtual HRESULT STDMETHODCALLTYPE GetLocation( 69*b1cdbd2cSJim Jagielski LPWSTR pszPathBuffer, 70*b1cdbd2cSJim Jagielski DWORD cchMax, 71*b1cdbd2cSJim Jagielski DWORD *pdwPriority, 72*b1cdbd2cSJim Jagielski const SIZE *prgSize, 73*b1cdbd2cSJim Jagielski DWORD dwRecClrDepth, 74*b1cdbd2cSJim Jagielski DWORD *pdwFlags); 75*b1cdbd2cSJim Jagielski 76*b1cdbd2cSJim Jagielski //---------------------------- 77*b1cdbd2cSJim Jagielski // IPersist methods 78*b1cdbd2cSJim Jagielski //---------------------------- 79*b1cdbd2cSJim Jagielski 80*b1cdbd2cSJim Jagielski virtual HRESULT STDMETHODCALLTYPE GetClassID(CLSID* pClassID); 81*b1cdbd2cSJim Jagielski 82*b1cdbd2cSJim Jagielski //---------------------------- 83*b1cdbd2cSJim Jagielski // IPersistFile methods 84*b1cdbd2cSJim Jagielski //---------------------------- 85*b1cdbd2cSJim Jagielski 86*b1cdbd2cSJim Jagielski virtual HRESULT STDMETHODCALLTYPE IsDirty(); 87*b1cdbd2cSJim Jagielski 88*b1cdbd2cSJim Jagielski virtual HRESULT STDMETHODCALLTYPE Load( 89*b1cdbd2cSJim Jagielski /* [in] */ LPCOLESTR pszFileName, 90*b1cdbd2cSJim Jagielski /* [in] */ DWORD dwMode); 91*b1cdbd2cSJim Jagielski 92*b1cdbd2cSJim Jagielski virtual HRESULT STDMETHODCALLTYPE Save( 93*b1cdbd2cSJim Jagielski /* [unique][in] */ LPCOLESTR pszFileName, 94*b1cdbd2cSJim Jagielski /* [in] */ BOOL fRemember); 95*b1cdbd2cSJim Jagielski 96*b1cdbd2cSJim Jagielski virtual HRESULT STDMETHODCALLTYPE SaveCompleted( 97*b1cdbd2cSJim Jagielski /* [unique][in] */ LPCOLESTR pszFileName); 98*b1cdbd2cSJim Jagielski 99*b1cdbd2cSJim Jagielski virtual HRESULT STDMETHODCALLTYPE GetCurFile( 100*b1cdbd2cSJim Jagielski /* [out] */ LPOLESTR __RPC_FAR *ppszFileName); 101*b1cdbd2cSJim Jagielski 102*b1cdbd2cSJim Jagielski private: 103*b1cdbd2cSJim Jagielski Gdiplus::Rect CalcScaledAspectRatio(Gdiplus::Rect src, Gdiplus::Rect dest); 104*b1cdbd2cSJim Jagielski 105*b1cdbd2cSJim Jagielski private: 106*b1cdbd2cSJim Jagielski long ref_count_; 107*b1cdbd2cSJim Jagielski std::wstring filename_; 108*b1cdbd2cSJim Jagielski SIZE thumbnail_size_; 109*b1cdbd2cSJim Jagielski DWORD color_depth_; 110*b1cdbd2cSJim Jagielski ULONG_PTR gdiplus_token_; 111*b1cdbd2cSJim Jagielski Gdiplus::Bitmap* signet_; 112*b1cdbd2cSJim Jagielski }; 113*b1cdbd2cSJim Jagielski 114*b1cdbd2cSJim Jagielski #endif 115