|
#include <APIGdiConstants.au3>
#include <FontConstants.au3>
#include <SendMessage.au3>
#include <StaticConstants.au3>
#include <WinAPIGdi.au3>
#include <WinAPIGdiDC.au3>
#include <WinAPIHObj.au3>
#include <WinAPIMisc.au3>
#include <WinAPIRes.au3>
#include <WinAPISys.au3>
#include <WinAPISysWin.au3>
#include <WindowsConstants.au3>
#include <GDIPlus.au3>
; 创建 GUI
Local $hForm = GUICreate('测试 ' & StringReplace(@ScriptName, '.au3', '()'), 400, 400)
Local $idPic = GUICtrlCreatePic('', 0, 0, 400, 400)
Local $hPic = GUICtrlGetHandle($idPic)
; 创建位图
Local $hDev = _WinAPI_GetDC($hPic)
Local $hDC = _WinAPI_CreateCompatibleDC($hDev)
Local $hSource = _WinAPI_CreateCompatibleBitmapEx($hDev, 400, 400, _WinAPI_SwitchColor(_WinAPI_GetSysColor($COLOR_3DFACE)))
Local $hSv = _WinAPI_SelectObject($hDC, $hSource)
; 绘制对象
Local $hOldBrush = _WinAPI_SelectObject($hDC, _WinAPI_GetStockObject($DC_BRUSH))
Local $hOldPen = _WinAPI_SelectObject($hDC, _WinAPI_GetStockObject($DC_PEN))
_WinAPI_SetDCBrushColor($hDC, 0x33cc33)
_WinAPI_SetDCPenColor($hDC, 0x33cc33)
Local $hPattern = _WinAPI_LoadImage(0, @ScriptDir & '\Extras\Pattern.bmp', $IMAGE_BITMAP, 0, 0, $LR_LOADFROMFILE)
; $hPattern = _WinAPI_LoadBitmap(_WinAPI_GetModuleHandle(@SystemDir & '\shell32.dll'), 138)
$hBrush = _WinAPI_CreateBrushIndirect($BS_PATTERN, 0, $hPattern)
$hObj = _WinAPI_SelectObject($hDC, $hBrush)
$tRECT = _WinAPI_CreateRect(0, 0, 240, 23)
;~ _WinAPI_OffsetRect($tRECT, 220, 279)
_WinAPI_RoundRect($hDC, $tRECT, 3, 3)
$tRECT = _WinAPI_CreateRect(0, 0, 240, 23)
_WinAPI_OffsetRect($tRECT, 0, 30)
_WinAPI_RoundRect($hDC, $tRECT, 3, 3)
_WinAPI_SelectObject($hDC, $hObj)
_WinAPI_DeleteObject($hPattern)
_WinAPI_DeleteObject($hBrush)
_WinAPI_SetTextColor($hDC, 0xffffff)
_WinAPI_SetBkMode($hDC, $TRANSPARENT)
Local $hFont = _WinAPI_CreateFont(20, 0, 0, 0, $FW_NORMAL, 0, 0, 0, $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $ANTIALIASED_QUALITY, $DEFAULT_PITCH, '微软雅黑')
$hObj = _WinAPI_SelectObject($hDC, $hFont)
_WinAPI_TextOut($hDC, 13, 1, '正常情况-----------------非常好')
_WinAPI_TextOut($hDC, 13, 31, '正常情况')
_WinAPI_SelectObject($hDC, $hObj)
_WinAPI_DeleteObject($hFont)
; 混合位图
Local $hBitmap = _WinAPI_CreateCompatibleBitmap($hDev, 400, 400)
$hBrush = _WinAPI_SelectObject($hDC, $hOldBrush)
_WinAPI_DeleteObject($hBrush)
Local $hPen = _WinAPI_SelectObject($hDC, $hOldPen)
_WinAPI_DeleteObject($hPen)
_WinAPI_SelectObject($hDC, $hBitmap)
_WinAPI_DrawBitmap($hDC, 0, 0, $hSource, $MERGECOPY)
_WinAPI_ReleaseDC($hPic, $hDev)
_WinAPI_SelectObject($hDC, $hSv)
_WinAPI_DeleteObject($hSource)
_WinAPI_DeleteDC($hDC)
; 将位图设置到控件
_SendMessage($hPic, $STM_SETIMAGE, 0, $hBitmap)
$hObj = _SendMessage($hPic, $STM_GETIMAGE)
If $hObj <> $hBitmap Then
_WinAPI_DeleteObject($hBitmap)
EndIf
_GDIPlus_ImageSaveToFile($hSource, @ScriptDir & '\1.bmp')
GUISetState(@SW_SHOW)
Do
Until GUIGetMsg() = -3
_GDIPlus_ImageSaveToFile($hSource, @ScriptDir & '\1.bmp') 保存图片不成功
太复杂了,我就想画个简单的矩形,搞几个字保存图片
例子里面乱七八糟的一大堆,这是让人学不懂啊
|
|