[已解决]如何将“GDI+”绘制的图形保存到文件?
本帖最后由 jianganew 于 2019-1-7 16:51 编辑请教各位,如何将“GDI+”绘制的图形保存到文件?_GDIPlus_ImageSaveToFile不行。
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
Example()
Func Example()
_GDIPlus_Startup() ;初始化 GDI+
Local Const $iWidth = 600, $iHeight = 600, $iBgColor = 0x303030 ; $iBgColor 背景颜色格式: RRGGBB
Local $hGUI = GUICreate("GDI+ 示例 (" & @ScriptName & ")", $iWidth, $iHeight) ;创建一个测试 GUI
GUISetBkColor($iBgColor, $hGUI) ;设置 GUI 的背景颜色
GUISetState(@SW_SHOW)
Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;在句柄指定的窗口创建图形对象
_GDIPlus_GraphicsSetSmoothingMode($hGraphics, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;设置图形对象渲染质量(抗锯齿)
Local $hPen = _GDIPlus_PenCreate(0xFFABCDEF, 4) ;颜色格式 AARRGGBB (十六进制)
_GDIPlus_GraphicsDrawEllipse($hGraphics, 10.5, 50.1, 580.25, 500.75, $hPen)
;_GDIPlus_ImageSaveToFile($hGUI, @ScriptDir & "\1.bmp")
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
;清理 GDI+ 资源
_GDIPlus_PenDispose($hPen)
_GDIPlus_GraphicsDispose($hGraphics)
_GDIPlus_Shutdown()
GUIDelete($hGUI)
EndFunc ;==>Example
本帖最后由 水木子 于 2019-1-4 15:56 编辑
_GDIPlus_ImageSaveToFile肯定可以啊!
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
_GDIPlus_Startup()
Local Const $iWidth = 600, $iHeight = 600, $iBgColor = 0xFFEE88BB
$hGui = GUICreate('', $iWidth, $iHeight)
GUISetState()
$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGui)
$hGraphics = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $hGraphic)
$hGfxCtxt = _GDIPlus_ImageGetGraphicsContext($hGraphics)
_GDIPlus_GraphicsSetSmoothingMode($hGfxCtxt, $GDIP_SMOOTHINGMODE_HIGHQUALITY)
$hPen = _GDIPlus_PenCreate(0xFFABCDEF, 4)
$hBrush = _GDIPlus_BrushCreateSolid($iBgColor)
_GDIPlus_GraphicsFillRect($hGfxCtxt, 0, 0, $iWidth, $iHeight, $hBrush)
_GDIPlus_GraphicsDrawEllipse($hGfxCtxt, 10.5, 50.1, 580.25, 500.75, $hPen)
_GDIPlus_GraphicsDrawImage($hGraphic, $hGraphics, 0, 0)
_GDIPlus_ImageSaveToFile($hGraphics, @ScriptDir & '\1.bmp')
Do
Until GUIGetMsg() = -3
_GDIPlus_PenDispose($hPen)
_GDIPlus_BrushDispose($hBrush)
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_GraphicsDispose($hGfxCtxt)
_GDIPlus_BitmapDispose($hGraphics)
_GDIPlus_Shutdown()
多谢水版,已OK 。 多谢水版,已OK 。 路过赞金币! 刚碰到需要这方面的代码,真是巧,多谢了 路过赞金币!1
页:
[1]