qq342252004 发表于 2011-6-20 15:28:20

GDI绘制动态频谱,API可以做到这样的效果吗?

本帖最后由 qq342252004 于 2011-6-20 15:30 编辑

GDI绘制动态频谱,API可以做到这样的效果吗?

netegg 发表于 2011-6-20 16:32:47

http://www.autoitx.com/thread-14110-1-1.html
这种柱形图的不清楚,那个是官网的,可以参考下

qq342252004 发表于 2011-6-20 18:28:51

这种柱形图的不清楚,那个是官网的,可以参考下
netegg 发表于 2011-6-20 16:32 http://www.autoitx.com/images/common/back.gif
你给的连接我看过了,也是GDI。 用API可以做到这样的效果吗?

netegg 发表于 2011-6-20 18:57:57

本帖最后由 netegg 于 2011-6-20 18:59 编辑

回复 3# qq342252004
api好像一般不用来处理图像,不过看你怎么定义了,如果把gdi划到api范畴,个人认为也没什么不妥

浪迹红客 发表于 2011-6-20 20:49:46

路过。。。

qq342252004 发表于 2011-6-20 22:06:08

听说GDI绘制图CPU占用高,API绘制图CPU占用低。

netegg 发表于 2011-6-20 23:48:28

回复 6# qq342252004
大概知道lz的意思了,你指的是gdi+,不是gdi,gdi的东西都在api里,gdi+确实比gdi占资源

xrzmjz 发表于 2011-7-1 23:30:58

本质上GDI也调用了API

happytc 发表于 2011-7-2 07:02:33

GDI+学习起来有点难度。

搭车问下下面的问题:

#include <GuiConstantsEx.au3>
#include <GDIPlus.au3>

Opt('MustDeclareVars', 1)

_Main()

Func _Main()
        Local $hGUI, $hGraphic, $hPen
        $hGUI = GUICreate("GDI+", 400, 300)
        GUISetState()

        _GDIPlus_Startup ()
        $hGraphic = _GDIPlus_GraphicsCreateFromHWND ($hGUI)
        $hPen = _GDIPlus_PenCreate ()
        _GDIPlus_GraphicsDrawLine ($hGraphic, 10, 150, 390, 150, $hPen)
        _GDIPlus_GraphicsDrawLine ($hGraphic, 50, 50, 390, 390, $hPen)
        ;这时怎么删掉前面画的那条直线(就是水平的那条)?而后面那条保留(也就保留斜线)
        Do
        Until GUIGetMsg() = $GUI_EVENT_CLOSE

        _GDIPlus_PenDispose ($hPen)
        _GDIPlus_GraphicsDispose ($hGraphic)
        _GDIPlus_Shutdown ()

EndFunc

happytc 发表于 2011-7-2 07:19:12

一直在问个最简单的GDI+的问题,就是如画图里(mspaint.exe)那样,点了画“直线后,按下左键拖动鼠标,那条直线就跟着鼠标动,但始终只有一条直线,而不象下面的代码那样:鼠标一动,画了无数直线

#Include <ScreenCapture.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>


Global Const $CursorID = MouseGetCursor()
Global $hGUI, $hpen, $hGraphicBg

WhiteBoard()

Func WhiteBoard()
        Local $HBITMAP, $hBmp, $PenSize, $ColorValue
        Opt("GUIOnEventMode", 1)

        _GDIPlus_Startup()

        $HBITMAP = _ScreenCapture_Capture("", 0, 0, @DesktopWidth - 2, @DesktopHeight - 2, 0)
        $hGUI = GUICreate("WhiteBoard-LiveCapture", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP)

        GUISetState(@SW_SHOW, $hGUI)
        $hGraphicBg = _GDIPlus_GraphicsCreateFromHWND($hGUI)
        $hBmp = _GDIPlus_BitmapCreateFromHBITMAP($HBITMAP)
        _GDIPlus_GraphicsDrawImage($hGraphicBg, $hBmp, 0, 0)
        _WinAPI_DeleteObject($HBITMAP)

        $PenSize = 1
        $hPen = _GDIPlus_PenCreate(0xA0FFFF00, $PenSize)

        GUISetOnEvent(-3, "_Exit")
        OnAutoItExitRegister("_Exit")
        GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "Draw", $hGUI)

        While True
                Sleep(2000)
        WEnd
EndFunc




Func Draw()
    Local $MousePos, $MouseXOri, $MouseYOri
        GUISetCursor(0, 1, $hGUI)
    $MousePos = GUIGetCursorInfo($hGUI)
        $MouseXOri = $MousePos
        $MouseYOri = $MousePos
    Sleep(50)
    Do
      $MousePos = GUIGetCursorInfo($hGUI)
      If $MouseXOri <> $MousePos Or $MouseYOri <> $MousePos Then
            _GDIPlus_GraphicsDrawLine($hGraphicBg, $MousePos, $MousePos, $MouseXOri, $MouseYOri, $hPen)
;这里该如何写?才能不会搞动如下图那样的“刷子”样的无数直线?
      EndIf
    Until Not $MousePos
EndFunc

Func _Exit()
    GUISetCursor($CursorID, 1, $hGUI)
    GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "")
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGraphicBg)
    _GDIPlus_Shutdown()
    GUIDelete($hGUI)
    Exit
EndFunc

3mile 发表于 2011-7-2 14:45:29

回复 9# happytc
#include <GuiConstantsEx.au3>
#include <GDIPlus.au3>

Opt('MustDeclareVars', 1)

_Main()

Func _Main()
      Local $hGUI, $hGraphic, $hPen,$hPen1
      $hGUI = GUICreate("GDI+", 400, 300)
      GUISetState()

      _GDIPlus_Startup ()
      $hGraphic = _GDIPlus_GraphicsCreateFromHWND ($hGUI)
      $hPen = _GDIPlus_PenCreate ()
      _GDIPlus_GraphicsDrawLine ($hGraphic, 10, 150, 390, 150, $hPen)
                _GDIPlus_PenDispose ($hPen)
                $hPen1=_GDIPlus_PenCreate ()
                _GDIPlus_GraphicsDrawLine ($hGraphic, 50, 50, 390, 390, $hPen)
      Sleep(1000)
                _WinAPI_RedrawWindow($hGUI)
      ;这时怎么删掉前面画的那条直线(就是水平的那条)?而后面那条保留(也就保留斜线)
      Do
                        _GDIPlus_GraphicsDrawLine ($hGraphic, 50, 50, 390, 390, $hPen)
      Until GUIGetMsg() = $GUI_EVENT_CLOSE

      _GDIPlus_PenDispose ($hPen1)
      _GDIPlus_GraphicsDispose ($hGraphic)
      _GDIPlus_Shutdown ()

EndFunc

happytc 发表于 2011-7-3 21:31:12

回复 11# 3mile

谢了,但用_WinAPI_RedrawWindow($hGUI),对十楼的代码不灵了
虽然可以一直是一条直线,但背景图没有了,并且这条直线会不停地闪烁呀

ayumi502 发表于 2011-7-9 16:52:43

gdi比较难 看来要继续学习
页: [1]
查看完整版本: GDI绘制动态频谱,API可以做到这样的效果吗?