gdiplus绘制带透明通道文本
2013年07月10日
⁄ 综合
⁄ 共 2199字 ⁄ 字号
小 中 大
- [list]
- [*]Private Sub Form_Load()
- [*] InitGDIPlus
- [*]
- [*] Dim memBmp As Long, memGraphics As Long
- [*] CreateBitmapWithGraphics memBmp, memGraphics, 200, 100, PixelFormat32bppARGB
- [*]
- [*] Dim gFontFamily As Long, gFont As Long, gStrFmt As Long
- [*] GdipCreateFontFamilyFromName StrPtr("微软雅黑"), 0, gFontFamily
- [*] GdipCreateFont gFontFamily, 13, FontStyle.FontStyleRegular, UnitPixel, gFont
- [*] GdipCreateStringFormat 0, 0, gStrFmt
- [*] GdipSetStringFormatAlign gStrFmt, StringAlignmentNear
- [*]
- [*] Dim rc As RECTF
- [*] Dim Brush As Long
- [*] GdipCreateSolidFill &HFF0000FF, Brush
- [*]
- [*] '先测试ClearType
- [*] GdipSetTextRenderingHint memGraphics, TextRenderingHintClearTypeGridFit
- [*] GdipDrawString memGraphics, StrPtr("ClearType 文字"), -1, gFont, rc, gStrFmt, Brush
- [*]
- [*] rc.Top = 20
- [*] '测试AntiAlias GridFit
- [*] GdipSetTextRenderingHint memGraphics, TextRenderingHintAntiAliasGridFit
- [*] GdipDrawString memGraphics, StrPtr("AntiAlias GridFit 文字"), -1, gFont, rc, gStrFmt, Brush
- [*]
- [*] rc.Top = 40
- [*] '测试AntiAlias
- [*] GdipSetTextRenderingHint memGraphics, TextRenderingHintAntiAlias
- [*] GdipDrawString memGraphics, StrPtr("AntiAlias 文字"), -1, gFont, rc, gStrFmt, Brush
- [*]
- [*] rc.Top = 60
- [*] '测试SingleBitPerPixel GridFit
- [*] GdipSetTextRenderingHint memGraphics, TextRenderingHintSingleBitPerPixelGridFit
- [*] GdipDrawString memGraphics, StrPtr("SingleBitPerPixel GridFit 文字"), -1, gFont, rc, gStrFmt, Brush
- [*]
- [*] rc.Top = 80
- [*] '测试SingleBitPerPixel
- [*] GdipSetTextRenderingHint memGraphics, TextRenderingHintSingleBitPerPixel
- [*] GdipDrawString memGraphics, StrPtr("SingleBitPerPixel 文字"), -1, gFont, rc, gStrFmt, Brush
- [*]
- [*] Dim frmGraphics As Long
- [*] GdipCreateFromHDC hDC, frmGraphics
- [*] GdipGraphicsClear frmGraphics, &HFFFFFFFF
- [*]
- [*] GdipSetTextRenderingHint frmGraphics, TextRenderingHintClearTypeGridFit
- [*] rc.Top = 10
- [*] rc.Left = 10
- [*] GdipDeleteBrush Brush
- [*] GdipCreateSolidFill &HFF000000, Brush
- [*] GdipDrawString frmGraphics, StrPtr("绘制到包含透明通道的位图:"), -1, gFont, rc, gStrFmt, Brush
- [*]
- [*] GdipDrawImageRectI frmGraphics, memBmp, 10, 40, 200, 100
- [*]
- [*] GdipDeleteBrush Brush
- [*] GdipDeleteStringFormat gStrFmt
- [*] GdipDeleteFont gFont
- [*] GdipDeleteFontFamily gFontFamily
- [*] GdipDeleteGraphics frmGraphics
- [*] GdipDeleteGraphics memGraphics
- [*] GdipDisposeImage memBmp
- [*]
- [*] TerminateGDIPlus
- [*]End Sub
- [*]