Jump to content

setting (GDI+)image position


tomashen
 Share

Recommended Posts

_GDIPlus_Startup ()
    $hBitmap = _GDIPlus_BitmapCreateFromFile ("DataIMG.JPG")
    $hClone = _GDIPlus_BitmapCloneArea($hBitmap, 0, 0, 800, 600, $GDIP_PXF64PARGB)
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND ($pic)
;~   $MAP2 = _GDIPlus_GraphicsDrawImage($hGraphic, $hClone, 0, 0)
;~ _GDIPlus_ShutDown ()
$hMatrix = _GDIPlus_MatrixCreate()
_GDIPlus_MatrixScale($hMatrix, 1.5, 1.5)
_GDIPlus_GraphicsSetTransform($hGraphic, $hMatrix)
$MAP2 = _GDIPlus_GraphicsDrawImageRect($hGraphic, $hClone, 0, 0, 800, 600)

i got img here now like this...zoomed a bit in and certain area shown ...

but um how can i make

if i have

while 1
switch guigetmsg()
endswitch
;if presed left/right or watever arrow
;move image or in this case i uppose it would have to be redrwan ?
;to the {way which button pressed} by $x pixels... like 1 pixel or more...

wend

in other words i wana do sumtin like guictrlsetpos()

Edited by tomashen

Proud of AutoIt Proud of MySelf :)

Link to comment
Share on other sites

Somethin' like that?

;fast hack by UEZ 2011
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Opt("MustDeclareVars", 1)

_GDIPlus_Startup()
Global $nMsg
Global $hImage = _GDIPlus_ImageLoadFromFile(StringLeft(@AutoItExe, StringInStr(@AutoItExe, "", 0, -1)) & "ExamplesGUIlogo4.gif")

Global $iWidth = _GDIPlus_ImageGetWidth($hImage)
Global $iHeight = _GDIPlus_ImageGetHeight($hImage)

Global $hWnd = GUICreate("Test", 640, 480)
Global $idLabel = GUICtrlCreateLabel("This is a test", 10, 10, 400, 50)
GUICtrlSetColor(-1, 0x0000FF)
GUICtrlSetFont(-1, 40, 400, 0, "Arial", 4)
Global $frame = 50
Global $start_x = 150
Global $start_y = 150
Global $xs = $start_x - $frame
Global $ys = $start_y - $frame
Global $xw = $iWidth + $frame
Global $yh = $iHeight + $frame
Global $idGraphic = GUICtrlCreateGraphic($xs, $ys, $xw, $yh)
GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xFF0000)
GUICtrlSetGraphic(-1, $GUI_GR_RECT, $xs, $ys, $xw, $yh)
GUISetState(@SW_SHOW)

Global $iW = $iWidth + $frame - 2
Global $iH = $iHeight + $frame - 2
Global $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hWnd)
Global $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iW, $iH, $hGraphics)
Global $hBackbuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)
Global $x = $frame / 2, $y = $frame / 2

_GDIPlus_GraphicsClear($hBackbuffer, 0xFF000000)
_GDIPlus_GraphicsDrawImage($hBackbuffer, $hImage, $x, $y)
_GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap, $xs + 1, $ys + 1, $iW, $iH)

GUIRegisterMsg(0x0014, "WM_ERASEBKGND")

HotKeySet("{LEFT}", "MoveLeft")
HotKeySet("{RIGHT}", "MoveRight")
HotKeySet("{UP}", "MoveUp")
HotKeySet("{DOWN}", "MoveDown")

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            _GDIPlus_ImageDispose($hImage)
            _GDIPlus_BitmapDispose($hBitmap)
            _GDIPlus_GraphicsDispose($hBackbuffer)
            _GDIPlus_GraphicsDispose($hGraphics)
            _GDIPlus_Shutdown()
            GUIDelete($hWnd)
            Exit
    EndSwitch
WEnd

Func MoveLeft()
    If $x > 0 Then $x -= 1
    _GDIPlus_GraphicsClear($hBackbuffer, 0xFF000000)
    _GDIPlus_GraphicsDrawImage($hBackbuffer, $hImage, $x, $y)
    _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap, $xs + 1, $ys + 1, $iW, $iH)
EndFunc

Func MoveRight()
    If $x < $frame - 2 Then $x += 1
    _GDIPlus_GraphicsClear($hBackbuffer, 0xFF000000)
    _GDIPlus_GraphicsDrawImage($hBackbuffer, $hImage, $x, $y)
    _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap, $xs + 1, $ys + 1, $iW, $iH)
EndFunc

Func MoveUp()
    If $y > 0 Then $y -= 1
    _GDIPlus_GraphicsClear($hBackbuffer, 0xFF000000)
    _GDIPlus_GraphicsDrawImage($hBackbuffer, $hImage, $x, $y)
    _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap, $xs + 1, $ys + 1, $iW, $iH)
EndFunc

Func MoveDown()
    If $y < $frame - 2 Then $y += 1
    _GDIPlus_GraphicsClear($hBackbuffer, 0xFF000000)
    _GDIPlus_GraphicsDrawImage($hBackbuffer, $hImage, $x, $y)
    _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap, $xs + 1, $ys + 1, $iW, $iH)
EndFunc

Func WM_ERASEBKGND($hWnd, $uMsgm, $wParam, $lParam)
    _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap, $xs + 1, $ys + 1, $iW, $iH)
    Return True
EndFunc   ;==>WM_ERASEBKGND

Br,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...