-
Notifications
You must be signed in to change notification settings - Fork 0
/
GdiPlusUtils.h
59 lines (47 loc) · 2.19 KB
/
GdiPlusUtils.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//---------------------------------------------------------------------------
#ifndef GdiPlusUtilsH
#define GdiPlusUtilsH
#include <Classes.hpp>
#include <SysUtils.hpp>
#include "VclGdiplus.h"
//---------------------------------------------------------------------------
namespace GdiplusUtils {
//---------------------------------------------------------------------------
class GdiPlusSessionManager {
public:
GdiPlusSessionManager();
~GdiPlusSessionManager() /* throw() */;
GdiPlusSessionManager( GdiPlusSessionManager const & ) = delete;
GdiPlusSessionManager& operator=( GdiPlusSessionManager const & ) = delete;
private:
Gdiplus::GdiplusStartupInput gdiplusStartupInput_;
ULONG_PTR gdiplusToken_;
};
class EGdiplusExceptionBase : public Exception {
public:
template<typename...A>
EGdiplusExceptionBase( A&&...Args ) : Exception( std::forward<A>( Args )... ) {}
};
class EGdiplusException : public EGdiplusExceptionBase {
public:
typedef EGdiplusExceptionBase inherited;
__fastcall EGdiplusException( String Msg );
__fastcall EGdiplusException( Gdiplus::Status Code );
};
extern String GetGdiplusStatusStrings( Gdiplus::Status Code );
extern void GdiplusCheck( Gdiplus::Status Code );
extern Gdiplus::Image* LoadImage( String FileName );
extern Gdiplus::Color TColorToGdiplusColor( TColor Val );
extern Gdiplus::Color TColorToGdiplusColor( TColor Val, BYTE Alpha );
extern Gdiplus::StringAlignment AlignmentToGdiplusStringAlignment( TAlignment Val );
extern Gdiplus::StringAlignment VerticalAlignmentToGdiplusStringAlignment( TVerticalAlignment Val );
extern void DrawImage( Gdiplus::Graphics& g, Gdiplus::Image& Img,
Gdiplus::RectF const & DstRect, BYTE AlphaBlend,
bool Stretched = true, bool MantainAspectRatio = false );
extern Gdiplus::RectF VCLRectToGdiPlusRectF( TRect const & Rect );
extern void GetEncoderClsid( WCHAR const * Format, CLSID* Clsid );
extern Gdiplus::Image* LoadImageFromStream( TStream* Stream, String MimeType );
//---------------------------------------------------------------------------
} // End of namespace GdiplusUtils
//---------------------------------------------------------------------------
#endif