现在的位置: 首页 > 综合 > 正文

gdiplus绘制带透明通道文本

2013年07月10日 ⁄ 综合 ⁄ 共 2199字 ⁄ 字号 评论关闭
  1. [list]
  2. [*]Private Sub Form_Load()
  3. [*]    InitGDIPlus
  4. [*]   
  5. [*]    Dim memBmp As Long, memGraphics As Long
  6. [*]    CreateBitmapWithGraphics memBmp, memGraphics, 200, 100, PixelFormat32bppARGB
  7. [*]   
  8. [*]    Dim gFontFamily As Long, gFont As Long, gStrFmt As Long
  9. [*]    GdipCreateFontFamilyFromName StrPtr("微软雅黑"), 0, gFontFamily
  10. [*]    GdipCreateFont gFontFamily, 13, FontStyle.FontStyleRegular, UnitPixel, gFont
  11. [*]    GdipCreateStringFormat 0, 0, gStrFmt
  12. [*]    GdipSetStringFormatAlign gStrFmt, StringAlignmentNear
  13. [*]   
  14. [*]    Dim rc As RECTF
  15. [*]    Dim Brush As Long
  16. [*]    GdipCreateSolidFill &HFF0000FF, Brush
  17. [*]   
  18. [*]    '先测试ClearType
  19. [*]    GdipSetTextRenderingHint memGraphics, TextRenderingHintClearTypeGridFit
  20. [*]    GdipDrawString memGraphics, StrPtr("ClearType 文字"), -1, gFont, rc, gStrFmt, Brush
  21. [*]   
  22. [*]    rc.Top = 20
  23. [*]    '测试AntiAlias GridFit
  24. [*]    GdipSetTextRenderingHint memGraphics, TextRenderingHintAntiAliasGridFit
  25. [*]    GdipDrawString memGraphics, StrPtr("AntiAlias GridFit 文字"), -1, gFont, rc, gStrFmt, Brush
  26. [*]   
  27. [*]    rc.Top = 40
  28. [*]    '测试AntiAlias
  29. [*]    GdipSetTextRenderingHint memGraphics, TextRenderingHintAntiAlias
  30. [*]    GdipDrawString memGraphics, StrPtr("AntiAlias 文字"), -1, gFont, rc, gStrFmt, Brush
  31. [*]
  32. [*]    rc.Top = 60
  33. [*]    '测试SingleBitPerPixel GridFit
  34. [*]    GdipSetTextRenderingHint memGraphics, TextRenderingHintSingleBitPerPixelGridFit
  35. [*]    GdipDrawString memGraphics, StrPtr("SingleBitPerPixel GridFit 文字"), -1, gFont, rc, gStrFmt, Brush
  36. [*]
  37. [*]    rc.Top = 80
  38. [*]    '测试SingleBitPerPixel
  39. [*]    GdipSetTextRenderingHint memGraphics, TextRenderingHintSingleBitPerPixel
  40. [*]    GdipDrawString memGraphics, StrPtr("SingleBitPerPixel 文字"), -1, gFont, rc, gStrFmt, Brush
  41. [*]   
  42. [*]    Dim frmGraphics As Long
  43. [*]    GdipCreateFromHDC hDC, frmGraphics
  44. [*]    GdipGraphicsClear frmGraphics, &HFFFFFFFF
  45. [*]   
  46. [*]    GdipSetTextRenderingHint frmGraphics, TextRenderingHintClearTypeGridFit
  47. [*]    rc.Top = 10
  48. [*]    rc.Left = 10
  49. [*]    GdipDeleteBrush Brush
  50. [*]    GdipCreateSolidFill &HFF000000, Brush
  51. [*]    GdipDrawString frmGraphics, StrPtr("绘制到包含透明通道的位图:"), -1, gFont, rc, gStrFmt, Brush
  52. [*]   
  53. [*]    GdipDrawImageRectI frmGraphics, memBmp, 10, 40, 200, 100
  54. [*]   
  55. [*]    GdipDeleteBrush Brush
  56. [*]    GdipDeleteStringFormat gStrFmt
  57. [*]    GdipDeleteFont gFont
  58. [*]    GdipDeleteFontFamily gFontFamily
  59. [*]    GdipDeleteGraphics frmGraphics
  60. [*]    GdipDeleteGraphics memGraphics
  61. [*]    GdipDisposeImage memBmp
  62. [*]   
  63. [*]    TerminateGDIPlus
  64. [*]End Sub
  65. [*]

抱歉!评论已关闭.