TNB Library
TnbGdiPlus.h
[詳解]
1#pragma once
11#ifdef new
12 #pragma push_macro("new")
13 #undef new
14 #define __TnbNEEDPOPNEW__
15#endif
16
17
18
19#include "TnbPointerHandle.h"
20#include "TnbStrLib.h"
21#include <math.h>
22#include <gdiplus.h>
23#pragma comment(lib, "gdiplus.lib")
24
25
26
27//TNB Library
28namespace TNB
29{
30
31
32
33#ifndef _TnbDOXYGEN //Document作成用シンボル
34 // HWNDとリスナーのMAP
35 _SELECTANY ULONG_PTR s_uGdiToken = 0;
36#endif
37
38
39
59{
60public:
61
70 class CPos : public Gdiplus::PointF
71 {
72 DEFSUPER(Gdiplus::PointF);
73 // 変換
74 template<typename T> Gdiplus::REAL _(T t) const
75 {
76 return static_cast<Gdiplus::REAL>(t);
77 }
78 public:
84 CPos(double x, double y) : _super(_(x), _(y)) { }
89 CPos(const POINT& pos) : _super(_(pos.x), _(pos.y)) { }
94 CPos(const SIZE& sz) : _super(_(sz.cx), _(sz.cy)) { }
95 };
96
97
98 //-----------------------------
99
100
102 virtual ~CGdiPlus(void)
103 {
104 }
105
109 CGdiPlus(void) : m_hDC(NULL)
110 {
111 Startup();
112 }
113
118 CGdiPlus(HDC hdc) : m_hDC(hdc)
119 {
120 Startup();
121 m_pGraphics = Gdiplus::Graphics::FromHDC(hdc);
122 m_pGraphics->SetTextRenderingHint(Gdiplus::TextRenderingHintAntiAlias);
123 }
124
129 CGdiPlus(const CGdiPlus& other) : m_hDC(NULL)
130 {
131 operator=(other);
132 }
133
140 {
141 if ( this != &other )
142 {
143 m_pGraphics.Null();
144 if ( m_hDC != NULL )
145 {
146 m_pGraphics = Gdiplus::Graphics::FromHDC(m_hDC);
147 m_pGraphics->SetTextRenderingHint(other.m_pGraphics->GetTextRenderingHint());
148 }
149 m_pFont = other.m_pFont;
150 m_pBrush = other.m_pBrush;
151 m_pPen = other.m_pPen;
152 m_pStringFormat = other.m_pStringFormat;
153 }
154 return *this;
155 }
156
164 bool SetDC(HDC hdc)
165 {
166 m_pGraphics.Null();
167 m_hDC = hdc;
168 m_pGraphics = Gdiplus::Graphics::FromHDC(hdc);
169 m_pGraphics->SetTextRenderingHint(Gdiplus::TextRenderingHintAntiAlias);
170 return m_Ret(m_pGraphics);
171 }
172
180 bool SetFont(HFONT hFont)
181 {
182 m_pFont = new Gdiplus::Font(m_hDC, hFont);
183 return m_Ret(m_pFont);
184 }
185
191 {
192 REGULAR = Gdiplus::FontStyleRegular,
193 BOLD = Gdiplus::FontStyleBold,
194 ITALIC = Gdiplus::FontStyleItalic,
195 UNDERLINE = Gdiplus::FontStyleUnderline,
196 STRIKEOUT = Gdiplus::FontStyleStrikeout,
197 };
198
208 bool SetFont(LPCWSTR lpszFontName, float size, int style = REGULAR)
209 {
210 Gdiplus::FontFamily fontfamily(lpszFontName);
211 m_pFont = new Gdiplus::Font(&fontfamily, size, style, Gdiplus::UnitPixel);
212 return m_Ret(m_pFont);
213 }
214
223 bool SetBrush(COLORREF color)
224 {
225 Gdiplus::Color c;
226 c.SetFromCOLORREF(color);
227 m_pBrush = new Gdiplus::SolidBrush(c);
228 return m_Ret(m_pBrush);
229 }
230
239 bool SetBrush(HBITMAP bmp)
240 {
241 HPALETTE h = NULL;
242 Gdiplus::Bitmap bm(bmp, h);
243 if ( bm.GetLastStatus() == Gdiplus::Ok )
244 {
245 m_pBrush = new Gdiplus::TextureBrush(&bm);
246 return m_Ret(m_pBrush);
247 }
248 m_pBrush.Null();
249 return false;
250 }
251
252//LinearGradientBrush
253//HatchBrush
254
255
265 bool SetPen(COLORREF color, float width)
266 {
267 Gdiplus::Color co;
268 co.SetFromCOLORREF(color);
269 m_pPen = new Gdiplus::Pen(co, width);
270 return m_Ret(m_pPen);
271 }
272
278 {
279 SYSTEM_DEFAULT = Gdiplus::TextRenderingHintSystemDefault,
280 BITPERPIXEL = Gdiplus::TextRenderingHintSingleBitPerPixelGridFit,
281 ANTIALIAS = Gdiplus::TextRenderingHintAntiAliasGridFit,
282 CLEARTYPE = Gdiplus::TextRenderingHintClearTypeGridFit
283 };
284
293 bool SetTextRenderingHint(ETextRenderingHint hint, bool boIsGridFit = false)
294 {
295 if ( m_pGraphics.IsNull() ) { return false; }
296 int i = hint;
297 if ( ! boIsGridFit && (hint == BITPERPIXEL || hint == ANTIALIAS) )
298 {
299 i++;
300 }
301 Gdiplus::TextRenderingHint h = static_cast<Gdiplus::TextRenderingHint>(i);
302 return m_Ret(m_pGraphics->SetTextRenderingHint(h));
303 }
304
312 bool SetTextStyle(DWORD drawTextStyle)
313 {
314 m_pStringFormat = ms_DtToStringFormat(drawTextStyle);
315 return m_Ret(m_pStringFormat);
316 }
317
327 bool DrawText(const RECT& rc, LPCWSTR lpsz) const
328 {
329 if ( m_pGraphics.IsNull() || m_pFont.IsNull() || m_pBrush.IsNull() ) { return false; }
330 Gdiplus::RectF rcf(_(rc.left), _(rc.top), _(rc.right - rc.left + 1), _(rc.bottom - rc.top + 1));
331 Gdiplus::Status r = m_pGraphics->DrawString(lpsz, -1, m_pFont, rcf, m_pStringFormat, m_pBrush);
332 return m_Ret(r);
333 }
334
344 bool DrawText(const CGdiPlus::CPos& po, LPCWSTR lpsz) const
345 {
346 if ( m_pGraphics.IsNull() || m_pFont.IsNull() || m_pBrush.IsNull() ) { return false; }
347 Gdiplus::Status r = m_pGraphics->DrawString(lpsz, -1, m_pFont, po, m_pStringFormat, m_pBrush);
348 return m_Ret(r);
349 }
350
356 {
357 BICUBIC = Gdiplus::InterpolationModeBicubic,
358 BILINEAR = Gdiplus::InterpolationModeBilinear,
359// I_DEFAULT = Gdiplus::InterpolationModeDefault, ///< 既定のモードを指定します。
360 HIGH = Gdiplus::InterpolationModeHighQuality,
361 HQ_BICUBIC = Gdiplus::InterpolationModeHighQualityBicubic,
362 HQ_BILINEAR = Gdiplus::InterpolationModeHighQualityBilinear,
363// I_INVALID = Gdiplus::InterpolationModeInvalid, ///< 無効なモードを指定します。
364 LOW = Gdiplus::InterpolationModeLowQuality,
365 NEAREST_NEIGHBOR = Gdiplus::InterpolationModeNearestNeighbor,
366 };
367
376 {
377 if ( m_pGraphics.IsNull() ) { return false; }
378 Gdiplus::Status r = m_pGraphics->SetInterpolationMode(static_cast<Gdiplus::InterpolationMode>(mode));
379 return m_Ret(r);
380 }
381
387 {
388 m_pImageAttr = NULL;
389 }
390
399 void SetImageTransparentColor(COLORREF colorLow, COLORREF colorHigh)
400 {
401 if ( m_pImageAttr.IsNull() )
402 {
403 m_pImageAttr = new Gdiplus::ImageAttributes();
404 }
405 Gdiplus::Color c1;
406 Gdiplus::Color c2;
407 c1.SetFromCOLORREF(colorLow);
408 c2.SetFromCOLORREF(colorHigh);
409 m_pImageAttr->SetColorKey(c1, c2);
410 }
411
419 {
420 if ( m_pImageAttr.IsNull() )
421 {
422 m_pImageAttr = new Gdiplus::ImageAttributes();
423 }
424 return m_pImageAttr;
425 }
426
437 bool DrawImage(const CGdiPlus::CPos& po, HBITMAP bmp, double mag = 1.0, bool isFlipX = false, bool isFlipY = false) const
438 {
439 if ( m_pGraphics.IsNull() ) { return false; }
440 HPALETTE h = NULL;
441 Gdiplus::Bitmap bm(bmp, h);
442 Gdiplus::PointF pos[3];
443 pos[0].X = _(po.X);
444 pos[0].Y = _(po.Y);
445 pos[1].X = _(po.X + bm.GetWidth() * mag);
446 pos[1].Y = _(po.Y);
447 pos[2].X = _(po.X);
448 pos[2].Y = _(po.Y + bm.GetHeight() * mag);
449 if ( isFlipX )
450 {
451 pos[0].X = _(po.X + bm.GetWidth() * mag); // 水平方向の反転を処理します。
452 pos[1].X = _(po.X);
453 pos[2].X = pos[0].X;
454 }
455 if ( isFlipY )
456 {
457 pos[0].Y = _(po.Y + bm.GetHeight() * mag); // 垂直方向の反転を処理します。
458 pos[1].Y = pos[0].Y;
459 pos[2].Y = _(po.Y);
460 }
461 return m_DrawImage(bm, pos, 3);
462 }
463
474 bool DrawFitImage(const RECT& rc, HBITMAP bmp, bool isFlipX = false, bool isFlipY = false) const
475 {
476 if ( m_pGraphics.IsNull() ) { return false; }
477 HPALETTE h = NULL;
478 Gdiplus::Bitmap bm(bmp, h);
479 double width = rc.right - rc.left;
480 double height = rc.bottom - rc.top;
481 double dx = width / bm.GetWidth();
482 double dy = height / bm.GetHeight();
483 CGdiPlus::CPos po(0, 0);
484 double d = 1.0;
485 if ( dx > dy )
486 {
487 //dy をベースにする
488 d = dy;
489 double x = (width - bm.GetWidth() * d);
490 po.X = static_cast<float>(x / 2.0);
491 }
492 else
493 {
494 //dx をベースにする
495 d = dx;
496 double y = (height - bm.GetHeight() * d);
497 po.Y = static_cast<float>(y / 2.0);
498 }
499 return DrawImage(po, bmp, d, isFlipX, isFlipY);
500 }
501
512 bool DrawRotateImage(const CGdiPlus::CPos& po, HBITMAP bmp, const CGdiPlus::CPos& hotSpot, double angle, double mag = 1.0) const
513 {
514 if ( m_pGraphics.IsNull() ) { return false; }
515 HPALETTE hPalette = NULL;
516 Gdiplus::Bitmap bm(bmp, hPalette);
517 Gdiplus::PointF pos[3];
518 double restW = bm.GetWidth() - hotSpot.X;
519 double restH = bm.GetHeight() - hotSpot.Y;
520 double radian = ToRadian(angle);
521 double sinVal = ::sin(radian);
522 double cosVal = ::cos(radian);
523 // 回転・拡大 & 平行移動
524 pos[0].X = _(((hotSpot.X * -cosVal) - (hotSpot.Y * -sinVal)) * mag + po.X);
525 pos[0].Y = _(((hotSpot.X * -sinVal) + (hotSpot.Y * -cosVal)) * mag + po.Y);
526 pos[1].X = _(((restW * cosVal) - (hotSpot.Y * -sinVal)) * mag + po.X);
527 pos[1].Y = _(((restW * sinVal) + (hotSpot.Y * -cosVal)) * mag + po.Y);
528 pos[2].X = _(((hotSpot.X * -cosVal) - (restH * sinVal)) * mag + po.X);
529 pos[2].Y = _(((hotSpot.X * -sinVal) + (restH * cosVal)) * mag + po.Y);
530 //
531 return m_DrawImage(bm, pos, 3);
532 }
533
544 bool DrawRotateImage(const CGdiPlus::CPos& po, HBITMAP bmp, double angle, double mag = 1.0) const
545 {
546 BITMAP bm;
547 if ( ::GetObject(bmp, sizeof(BITMAP), &bm) )
548 {
549 return DrawRotateImage(po, bmp, CPos(bm.bmWidth / 2.0, bm.bmHeight / 2.0), angle, mag);
550 }
551 return false;
552 }
553
563 bool DrawSkewImage(const CGdiPlus::CPos& po, HBITMAP bmp, const CGdiPlus::CPos& diff, double mag = 1.0) const
564 {
565 if ( m_pGraphics.IsNull() ) { return false; }
566 HPALETTE h = NULL;
567 Gdiplus::Bitmap bm(bmp, h);
568 Gdiplus::PointF pos[3];
569 pos[0].X = _(po.X);
570 pos[0].Y = _(po.Y);
571 pos[1].X = _(po.X + bm.GetWidth() * mag);
572 pos[1].Y = _(po.Y + diff.Y * mag);
573 pos[2].X = _(po.X + diff.X * mag);
574 pos[2].Y = _(po.Y + bm.GetHeight() * mag);
575 //
576 return m_DrawImage(bm, pos, 3);
577 }
578
584 {
585// S_INVALID = Gdiplus::SmoothingModeInvalid, ///< 無効なモードを指定します。
586// S_DEFAULT = Gdiplus::SmoothingModeDefault, ///< アンチエイリアス処理しないことを指定します。
587 HIGH_SPEED = Gdiplus::SmoothingModeHighSpeed,
588 HIGH_QUALITY = Gdiplus::SmoothingModeHighQuality,
589 NONE = Gdiplus::SmoothingModeNone,
590 ANTI_ALIAS = Gdiplus::SmoothingModeAntiAlias
591 };
592
601 {
602 if ( m_pGraphics.IsNull() ) { return false; }
603 Gdiplus::Status r = m_pGraphics->SetSmoothingMode(static_cast<Gdiplus::SmoothingMode>(mode));
604 return m_Ret(r);
605 }
606
615 bool DrawLine(const CPos& s, const CPos& e)
616 {
617 if ( m_pGraphics.IsNull() ) { return false; }
618 Gdiplus::Status r = m_pGraphics->DrawLine(m_pPen, s, e);
619 return m_Ret(r);
620 }
621
622 /*
623 bool DrawArc()
624 bool DrawCurve()
625 bool DrawEllipse()
626 bool DrawPie()
627 bool DrawPolygon()
628 bool DrawRectangle()
629
630 bool FillCurve()
631 bool FillEllipse()
632 bool FillPie()
633 bool FillPolygon()
634 bool FillRectangle()
635 bool FillRegion()
636 */
637
638 //------------------------------------
639
648 static bool Startup(void)
649 {
650 if ( s_uGdiToken == 0 )
651 {
652 static CReject r;
653 Gdiplus::GdiplusStartupInput startupInput;
654 Gdiplus::GdiplusStartup(&s_uGdiToken, &startupInput, NULL);
655 }
656 return s_uGdiToken != 0;
657 }
658
670 static bool DrawAntialiasText(HDC dc, HFONT hFont, DWORD drawTextStyle, COLORREF color, const CGdiPlus::CPos& po, LPCWSTR lpsz)
671 {
672 CGdiPlus g(dc);
673 g.SetFont(hFont);
674 g.SetBrush(color);
676 g.SetTextStyle(drawTextStyle);
677 return g.DrawText(po, lpsz);
678 }
679
687 static HBITMAP LoadBitmap(LPCWSTR lpsz)
688 {
689 Startup();
690 Gdiplus::Bitmap bm(lpsz);
691 if ( bm.GetLastStatus() == Gdiplus::Ok )
692 {
693 Gdiplus::Color c;
694 c.SetFromCOLORREF(RGB(255, 255, 255));
695 HBITMAP hBmp;
696 if ( bm.GetHBITMAP(c, &hBmp) == Gdiplus::Ok )
697 {
698 return hBmp;
699 }
700 }
701 return NULL;
702 }
703
711 static HBITMAP LoadThumbnail(LPCWSTR lpsz)
712 {
713 Startup();
714 Gdiplus::Bitmap bmp(lpsz);
715 if ( bmp.GetLastStatus() == Gdiplus::Ok )
716 {
717 UINT size = bmp.GetPropertyItemSize(PropertyTagThumbnailData);
718 if ( size > 0 )
719 {
720 HGLOBAL hGlobal = ::GlobalAlloc(GMEM_MOVEABLE, size);
721 BYTE* B = static_cast<BYTE *>(::GlobalLock(hGlobal));
722 Gdiplus::PropertyItem* P = reinterpret_cast<Gdiplus::PropertyItem*>(B);
723 bmp.GetPropertyItem(PropertyTagThumbnailData, size, P);
724 TNB::MemCopy(&B[0], &B[16], size - 16);
725 ::GlobalUnlock(hGlobal);
726 IStream* pis = NULL;
727 CreateStreamOnHGlobal(hGlobal, TRUE, &pis);
728 Gdiplus::Bitmap bm(pis);
729 if ( bm.GetLastStatus() == Gdiplus::Ok )
730 {
731 Gdiplus::Color c;
732 c.SetFromCOLORREF(RGB(0, 0, 0));
733 HBITMAP hBmp;
734 if ( bm.GetHBITMAP(c, &hBmp) == Gdiplus::Ok )
735 {
736 pis->Release();
737 ::GlobalFree(hGlobal);
738 return hBmp;
739 }
740 }
741 if ( pis != NULL )
742 {
743 pis->Release();
744 }
745 ::GlobalFree(hGlobal);
746 }
747 }
748 return NULL;
749 }
750
756 {
764 };
765
776 static bool SaveBitmap(LPCWSTR lpsz, Gdiplus::Bitmap& bmp, EBitmapFormat fmt = BMP, LONG jpegQuality = 80)
777 {
778 Startup();
779 LPCWSTR lpFmtDes;
780 Gdiplus::EncoderParameters encoderParameters;
781 Gdiplus::EncoderParameters* pEncoderParameters = NULL;
782 switch( fmt )
783 {
784 case BMP:
785 default: lpFmtDes = L"BMP"; break;
786 case GIF: lpFmtDes = L"GIF"; break;
787 case TIFF: lpFmtDes = L"TIFF"; break;
788 case PNG: lpFmtDes = L"PNG"; break;
789 case JPEG:
790 lpFmtDes = L"JPEG";
791 encoderParameters.Count = 1;
792 encoderParameters.Parameter[0].Guid = Gdiplus::EncoderQuality;
793 encoderParameters.Parameter[0].Type = Gdiplus::EncoderParameterValueTypeLong;
794 encoderParameters.Parameter[0].NumberOfValues = 1;
795 encoderParameters.Parameter[0].Value = &jpegQuality; //JPEGクオリティ:0〜100
796 pEncoderParameters = &encoderParameters;
797 break;
798 }
799 UINT numEncoders;
800 UINT size = 0;
801 Gdiplus::GetImageEncodersSize(&numEncoders, &size);
802 CWorkMem work(size);
803 Gdiplus::ImageCodecInfo* pEncoders = reinterpret_cast<Gdiplus::ImageCodecInfo*>(work.Ref());
804 Gdiplus::GetImageEncoders(numEncoders, size, pEncoders);
805 loop ( i, numEncoders )
806 {
807 if ( STRLIB::Compare(pEncoders[i].FormatDescription, lpFmtDes) == 0 )
808 {
809 return bmp.Save(lpsz, &(pEncoders[i].Clsid), pEncoderParameters) == Gdiplus::Ok;
810 }
811 }
812 return false;
813 }
814
825 static bool SaveBitmap(LPCWSTR lpsz, HBITMAP hBmp, EBitmapFormat fmt = BMP, LONG jpegQuality = 80)
826 {
827 HPALETTE h = NULL;
828 Gdiplus::Bitmap bm(hBmp, h);
829 return SaveBitmap(lpsz, bm, fmt, jpegQuality);
830 }
831
832private:
833
834 //GDI+ Shotdown処理用サブクラス
835 class CReject
836 {
837 public:
838 ~CReject(void)
839 {
840 if ( s_uGdiToken != 0 )
841 {
842 Gdiplus::GdiplusShutdown(s_uGdiToken);
843 s_uGdiToken = 0;
844 }
845 }
846 };
847
848 HDC m_hDC;
851 //
856// Gdiplus::Region m_region; ///< リージョン
857// Gdiplus::GraphicsPath m_graphicsPath; ///< パス?
858
860 static Gdiplus::StringFormat* ms_DtToStringFormat(DWORD drawTextStyle)
861 {
862 Gdiplus::StringFormat* P = new Gdiplus::StringFormat();
863 Gdiplus::StringAlignment alignX = Gdiplus::StringAlignmentNear;
864 if ( (drawTextStyle & DT_CENTER) != 0 )
865 {
866 alignX = Gdiplus::StringAlignmentCenter;
867 }
868 else if ( (drawTextStyle & DT_RIGHT) != 0 )
869 {
870 alignX = Gdiplus::StringAlignmentFar;
871 }
872 P->SetAlignment(alignX);
873 Gdiplus::StringAlignment alignY = Gdiplus::StringAlignmentNear;
874 if ( (drawTextStyle & DT_VCENTER) != 0 )
875 {
876 alignY = Gdiplus::StringAlignmentCenter;
877 }
878 else if ( (drawTextStyle & DT_BOTTOM) != 0 )
879 {
880 alignY = Gdiplus::StringAlignmentFar;
881 }
882 P->SetLineAlignment(alignY);
883 //
884 int formatFlags = 0;
885 if ( (drawTextStyle & DT_SINGLELINE) == 0 )
886 {
887 formatFlags |= Gdiplus::StringFormatFlagsNoClip;
888 }
889 P->SetFormatFlags(formatFlags);
890 //
891 Gdiplus::StringTrimming trim = Gdiplus::StringTrimmingNone;
892 if ( (drawTextStyle & DT_END_ELLIPSIS) != 0 )
893 {
894 trim = Gdiplus::StringTrimmingEllipsisCharacter;
895 }
896 if ( (drawTextStyle & DT_WORD_ELLIPSIS) != 0 )
897 {
898 trim = Gdiplus::StringTrimmingEllipsisWord;
899 }
900 if ( (drawTextStyle & DT_PATH_ELLIPSIS) != 0 )
901 {
902 trim = Gdiplus::StringTrimmingEllipsisPath;
903 }
904 P->SetTrimming(trim);
905 //
906 if ( (drawTextStyle & DT_NOPREFIX) != 0 )
907 {
908 P->SetHotkeyPrefix(Gdiplus::HotkeyPrefixNone);
909 }
910 else
911 {
912 P->SetHotkeyPrefix(Gdiplus::HotkeyPrefixShow);
913 }
914 return P;
915 }
916 // 変換
917 template<typename T> Gdiplus::REAL _(T t) const
918 {
919 return static_cast<Gdiplus::REAL>(t);
920 }
921 // π
922 static double PI(void)
923 {
924 return 3.141592653589793;
925 }
926 // 角度 -> ラジアン
927 static double ToRadian(double angle)
928 {
929 return angle * PI() / 180.0;
930 }
931 // ラジアン -> 角度
932 static double ToAngle(double radian)
933 {
934 return radian * 180.0 / PI();
935 }
936 // 結果判断
937 bool m_Ret(Gdiplus::Status s) const
938 {
939 return s == Gdiplus::Ok;
940 }
941 // 結果判断
942 template<typename TYP>
943 bool m_Ret(CPointerHandleT<TYP> P) const
944 {
945 return P->GetLastStatus() == Gdiplus::Ok;
946 }
950 bool m_DrawImage(Gdiplus::Bitmap& bm, Gdiplus::PointF* pPos, int posLength) const
951 {
952 ASSERT( ! ::IsBadReadPtr(pPos, sizeof(Gdiplus::PointF) * posLength) );
953 if ( ! m_pImageAttr.IsNull() )
954 {
955 Gdiplus::Status r = m_pGraphics->DrawImage( &bm, pPos, posLength, 0, 0, _(bm.GetWidth()), _(bm.GetHeight()), Gdiplus::UnitPixel, m_pImageAttr);
956 return m_Ret(r);
957 }
958 return m_Ret(m_pGraphics->DrawImage(&bm, pPos, posLength));
959 }
960};
961
962
963
964}; // TNB
965
966
967
968#ifdef __TnbNEEDPOPNEW__
969 #pragma pop_macro("new")
970#endif
#define loop(VAR, CNT)
loop構文.
Definition: TnbDef.h:343
ポインタハンドル関係のヘッダ
文字列操作ライブラリ関係のヘッダ
GDI+用座標型
Definition: TnbGdiPlus.h:71
CPos(double x, double y)
コンストラクタ.
Definition: TnbGdiPlus.h:84
CPos(const SIZE &sz)
コンストラクタ.
Definition: TnbGdiPlus.h:94
CPos(const POINT &pos)
コンストラクタ.
Definition: TnbGdiPlus.h:89
GDI+ 管理クラス
Definition: TnbGdiPlus.h:59
bool DrawRotateImage(const CGdiPlus::CPos &po, HBITMAP bmp, double angle, double mag=1.0) const
[描画] ビットマップ回転描画.
Definition: TnbGdiPlus.h:544
bool SetPen(COLORREF color, float width)
[設定] ペン設定.
Definition: TnbGdiPlus.h:265
EBitmapFormat
Saveフォーマット値
Definition: TnbGdiPlus.h:756
CGdiPlus(const CGdiPlus &other)
コピーコンストラクタ.
Definition: TnbGdiPlus.h:129
bool DrawFitImage(const RECT &rc, HBITMAP bmp, bool isFlipX=false, bool isFlipY=false) const
[描画] ビットマップフィット描画.
Definition: TnbGdiPlus.h:474
bool SetTextRenderingHint(ETextRenderingHint hint, bool boIsGridFit=false)
[設定] テキストレンダリングヒント設定.
Definition: TnbGdiPlus.h:293
void SetImageTransparentColor(COLORREF colorLow, COLORREF colorHigh)
[設定] イメージ描画透過色指定.
Definition: TnbGdiPlus.h:399
void ClearImageAttribute(void)
[設定] イメージ描画属性クリア.
Definition: TnbGdiPlus.h:386
bool SetBrush(COLORREF color)
[設定] ブラシ設定.
Definition: TnbGdiPlus.h:223
EFontStyle
フォントスタイル値.
Definition: TnbGdiPlus.h:191
@ BOLD
太字
Definition: TnbGdiPlus.h:193
@ STRIKEOUT
Strikeout
Definition: TnbGdiPlus.h:196
@ UNDERLINE
下線
Definition: TnbGdiPlus.h:195
@ ITALIC
斜め
Definition: TnbGdiPlus.h:194
@ REGULAR
通常
Definition: TnbGdiPlus.h:192
virtual ~CGdiPlus(void)
デストラクタ
Definition: TnbGdiPlus.h:102
static HBITMAP LoadBitmap(LPCWSTR lpsz)
[作成] 画像ファイル読込み.
Definition: TnbGdiPlus.h:687
bool SetFont(HFONT hFont)
[設定] フォント設定.
Definition: TnbGdiPlus.h:180
bool SetImageInterpolationMode(EInterpolationMode mode)
[設定] イメージ描画アルゴリズム設定.
Definition: TnbGdiPlus.h:375
bool DrawImage(const CGdiPlus::CPos &po, HBITMAP bmp, double mag=1.0, bool isFlipX=false, bool isFlipY=false) const
[描画] ビットマップ描画.
Definition: TnbGdiPlus.h:437
static bool DrawAntialiasText(HDC dc, HFONT hFont, DWORD drawTextStyle, COLORREF color, const CGdiPlus::CPos &po, LPCWSTR lpsz)
[表示] 文字列表示.
Definition: TnbGdiPlus.h:670
EInterpolationMode
イメージ操作アルゴリズムモード値.
Definition: TnbGdiPlus.h:356
@ HIGH
高品質補間を指定します。
Definition: TnbGdiPlus.h:360
@ NEAREST_NEIGHBOR
最近傍補間を指定します。
Definition: TnbGdiPlus.h:365
@ LOW
低品質補間を指定します。
Definition: TnbGdiPlus.h:364
@ BILINEAR
双一次補間を指定します。事前フィルタ処理は実行されません。このモードは、イメージを元のサイズの 50% 以下にするような縮小処理には適していません。
Definition: TnbGdiPlus.h:358
@ HQ_BICUBIC
高品質双三次補間を指定します。事前フィルタ処理が適用され、高品質の縮小処理が実行されます。このモードを使用すると、変換後のイメージが高品質になります。
Definition: TnbGdiPlus.h:361
@ BICUBIC
双三次補間を指定します。事前フィルタ処理は実行されません。このモードは、イメージを元のサイズの 25% 以下にするような縮小処理には適していません。
Definition: TnbGdiPlus.h:357
@ HQ_BILINEAR
高品質双一次補間を指定します。事前フィルタ処理が適用され、高品質の縮小処理が実行されます。
Definition: TnbGdiPlus.h:362
bool SetTextStyle(DWORD drawTextStyle)
[設定] テキストスタイル設定.
Definition: TnbGdiPlus.h:312
static bool SaveBitmap(LPCWSTR lpsz, HBITMAP hBmp, EBitmapFormat fmt=BMP, LONG jpegQuality=80)
[作成] 画像ファイル作成.
Definition: TnbGdiPlus.h:825
bool SetFont(LPCWSTR lpszFontName, float size, int style=REGULAR)
[設定] フォント設定.
Definition: TnbGdiPlus.h:208
bool DrawText(const CGdiPlus::CPos &po, LPCWSTR lpsz) const
[描画] テキスト描画.
Definition: TnbGdiPlus.h:344
static HBITMAP LoadThumbnail(LPCWSTR lpsz)
[作成] サムネイル画像ファイル読込み.
Definition: TnbGdiPlus.h:711
bool DrawRotateImage(const CGdiPlus::CPos &po, HBITMAP bmp, const CGdiPlus::CPos &hotSpot, double angle, double mag=1.0) const
[描画] ビットマップ回転描画.
Definition: TnbGdiPlus.h:512
CGdiPlus & operator=(const CGdiPlus &other)
コピーオペレータ.
Definition: TnbGdiPlus.h:139
bool SetBrush(HBITMAP bmp)
[設定] ブラシ設定.
Definition: TnbGdiPlus.h:239
static bool Startup(void)
[設定] GDI+ 初期化.
Definition: TnbGdiPlus.h:648
bool DrawLine(const CPos &s, const CPos &e)
[描画] ライン描画.
Definition: TnbGdiPlus.h:615
ESmoothingMode
スムージングモード値.
Definition: TnbGdiPlus.h:584
@ ANTI_ALIAS
アンチエイリアス処理されたレタリングを指定します。
Definition: TnbGdiPlus.h:590
@ HIGH_SPEED
高速で、低品質のレンダリングを指定します。
Definition: TnbGdiPlus.h:587
@ NONE
アンチエイリアス処理しないことを指定します。
Definition: TnbGdiPlus.h:589
@ HIGH_QUALITY
高品質で低速なレンダリングを指定します。
Definition: TnbGdiPlus.h:588
bool SetSmoothingMode(ESmoothingMode mode)
[設定] スムージングモード設定.
Definition: TnbGdiPlus.h:600
bool DrawText(const RECT &rc, LPCWSTR lpsz) const
[描画] テキスト描画.
Definition: TnbGdiPlus.h:327
CGdiPlus(void)
コンストラクタ.
Definition: TnbGdiPlus.h:109
bool SetDC(HDC hdc)
[設定] デバイスコンテキスト設定.
Definition: TnbGdiPlus.h:164
bool DrawSkewImage(const CGdiPlus::CPos &po, HBITMAP bmp, const CGdiPlus::CPos &diff, double mag=1.0) const
[描画] ビットマップ傾斜描画.
Definition: TnbGdiPlus.h:563
ETextRenderingHint
テキストレンダリングヒント値.
Definition: TnbGdiPlus.h:278
@ SYSTEM_DEFAULT
システムデフォルト
Definition: TnbGdiPlus.h:279
@ BITPERPIXEL
ビットマップ
Definition: TnbGdiPlus.h:280
@ ANTIALIAS
アンチエイリアス
Definition: TnbGdiPlus.h:281
@ CLEARTYPE
クリアタイプ
Definition: TnbGdiPlus.h:282
static bool SaveBitmap(LPCWSTR lpsz, Gdiplus::Bitmap &bmp, EBitmapFormat fmt=BMP, LONG jpegQuality=80)
[作成] 画像ファイル作成.
Definition: TnbGdiPlus.h:776
CPointerHandleT< Gdiplus::ImageAttributes > ReferImageAttribute(void)
[設定] イメージ描画属性参照.
Definition: TnbGdiPlus.h:418
CGdiPlus(HDC hdc)
コンストラクタ.
Definition: TnbGdiPlus.h:118
bool IsNull(void) const
[確認] NULLチェック
void Null(void)
[設定] 開放.
const TYP * Ref(void) const
[取得] ポインタ取得
Definition: TnbDef.h:712
int Compare(LPCSTR P1, LPCSTR P2, INT_PTR len=-1, DWORD dwCmpFlags=0)
[比較] 文字列比較(ASCII/SJIS用)
Definition: TnbStrLib.h:135
CRealNumber sin(const CValueDegree &d)
[計算] sin (値 = sin(角度))
CRealNumber cos(const CValueDegree &d)
[計算] cos (値 = cos(角度))
TNB Library
Definition: TnbDoxyTitle.txt:2
void MemCopy(T *_pDst, const void *pSrc, size_t len)
[複製] メモリコピー
Definition: TnbDef.h:376