|
本帖最后由 雨林GG 于 2016-11-25 05:26 编辑
一年级数学看图列式, 9 - 5 = ? 已知图形位置数组, $gArray[0][0]存放着图片的"行数, 宽度, 列宽, 列数, 高度, 行高", 从1行1列开始存放各个图片的位置。
减5, 就圈出5张图片,可以从左也可以从右开始,如何来计算怎么圈法?不知有没有朋友做过,请不吝赐教,给个思路或参考资料都可以,我实在是没有办法。
附例:#include <GUIConstantsEx.au3>
#include <GDIPlus.au3>
#include <Array.au3>
Global $ghGDIPDll = "GdiPlus.dll"
Global $hGUI, $hGraphic, $hPen
Global $gFile = "小鸡.png"
Global $gArray[][] = [["3,112,37,4,112,10"], _ ;行数, 宽度, 列宽, 列数, 高度, 行高
["", "", "", "319,23", "468,23"], _ ;图片的位置
["", "", "170,145", "319,145", "468,145"], _
["", "21,267", "170,267", "319,267", "468,267"]]
_ArrayDisplay($gArray)
_GDIPlus_Startup()
$hGUI = GUICreate("圈一圈", 600, 400)
$gaT = StringSplit($gArray[0][0], ",")
For $iRow = 1 To $gaT[1]
For $iCol = 1 To $gaT[4]
If $gArray[$iRow][$iCol] = "" Then ContinueLoop
$iLeft = StringRegExpReplace($gArray[$iRow][$iCol], ',\d+', "")
$iTop = StringReplace($gArray[$iRow][$iCol], $iLeft & ",", "")
$Pic = GUICtrlCreatePic("", $iLeft, $iTop, $gaT[2], $gaT[5])
_GdiImage_ToGuiPic($gFile, $Pic, $gaT[2], $gaT[5])
Next
Next
GUISetState()
$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
$hPen = _GDIPlus_PenCreate(0xFF000000, 5)
_GDIPlus_PenSetDashStyle ($hPen, $GDIP_DASHSTYLEDOT) ;点线
_GDIPlus_GraphicsDrawLine($hGraphic, 468 + $gaT[2] + 5, 23 -5, 468 + $gaT[2] + 5, 267 + $gaT[5] + 5, $hPen)
Sleep(500)
_GDIPlus_GraphicsDrawLine($hGraphic, 468 + $gaT[2] + 5, 267 + $gaT[5] + 5, 319 - 5, 267 + $gaT[5] + 5, $hPen)
Sleep(500)
_GDIPlus_GraphicsDrawLine($hGraphic, 319 - 5, 267 + $gaT[5] + 5, 319 - 5, 145 - 5, $hPen)
Sleep(500)
_GDIPlus_GraphicsDrawLine($hGraphic, 319 - 5, 145 - 5, 319 + 5 + $gaT[5] + $gaT[3]/2, 145 - 5, $hPen)
Sleep(500)
_GDIPlus_GraphicsDrawLine($hGraphic, 319 + 5 + $gaT[5] + $gaT[3]/2, 145 - 5, 319 + 5 + $gaT[5] + $gaT[3]/2, 23 -5, $hPen)
Sleep(500)
_GDIPlus_GraphicsDrawLine($hGraphic, 319 + 5 + $gaT[5] + $gaT[3]/2, 23 -5, 468 + $gaT[2] + 5, 23 -5, $hPen)
_GDIPlus_PenDispose($hPen)
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_Shutdown()
; 循环到用户退出
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
Func _GdiImage_ToGuiPic($sFile, $iCtrl, $iW_Img, $iH_Img)
If Not FileExists($sFile) Then Return SetError(1, 0, 0)
Local $hImage = _GDIPlus_ImageLoadFromFile($sFile)
If @error Then Return SetError(2, 0, 0)
;Local $iW_Img = _GDIPlus_ImageGetWidth($hImage), $iH_Img = _GDIPlus_ImageGetHeight($hImage)
Local $hBitmap = _GDIPlus_BitmapCreateFromScan0($iW_Img, $iH_Img)
Local $hGfx = _GDIPlus_ImageGetGraphicsContext($hBitmap)
;_GDIPlus_SetSmoothingMode($hGfx)
;_GDIPlus_GraphicsSetSmoothingMode($hGfx, 2) ;$GDIP_SMOOTHINGMODE_HIGHQUALITY = 2 ; Specifies that smoothing is applied using an 8 X 4 box filter.
_GDIPlus_GraphicsSetInterpolationMode($hGfx, 7)
_GDIPlus_GraphicsDrawImageRect($hGfx, $hImage, 0, 0, $iW_Img, $iH_Img)
Local $hHBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap)
_GDIPlus_GraphicsDispose($hGfx)
_GDIPlus_BitmapDispose($hBitmap)
_GDIPlus_ImageDispose($hImage)
;_WinAPI_DeleteObject(GUICtrlSendMsg($iCtrl, 0x0172, 0x0000, 0)) ;delete previous image in pic control
_WinAPI_DeleteObject(GUICtrlSendMsg($iCtrl, 0x0172, 0x0000, $hHBitmap)) ;STM_SETIMAGE = 0x0172
_WinAPI_DeleteObject($hHBitmap)
EndFunc ;==>_GdiImage_ToGuiPic
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?加入
×
|