Jump to content

How to rotate image object in GDI+


Recommended Posts

Hi, i'am making simple 2D "engine" using gdi+ and now i'am trying to make function that will be able to rotate image before i draw it to buffor.

I'am loading images by _GDIPlus_ImageLoadFromFile() then draw them to buffor by _GDIPlus_GraphicsDrawImage() and then copying that buffor to GUI's buffor.

The question is how can i rotate image object before i draw it to buffor?

Edited by MrKris1224
Link to comment
Share on other sites

3 hours ago, MrKris1224 said:

doesn't work for me

Really? Strange, but it works for me. What am I doing wrong?

#include <ScreenCapture.au3>

; create temp image file
_ScreenCapture_Capture(@ScriptDir & "\temp.png", 0, 0, 200, 200)

; ----------------

_GDIPlus_Startup()

$hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\temp.png")

$hBuffer = _GDIPlus_BitmapCreateFromScan0(400, 400)
$hGraphic = _GDIPlus_ImageGetGraphicsContext($hBuffer)

$hMatrix = _GDIPlus_MatrixCreate()
_GDIPlus_MatrixRotate($hMatrix, 20)
_GDIPlus_GraphicsSetTransform($hGraphic, $hMatrix)
_GDIPlus_GraphicsDrawImage($hGraphic, $hImage, 150, 0)

$hGUI = GUICreate("test")
GUISetState()
$hGraph = _GDIPlus_GraphicsCreateFromHWND($hGUI)
_GDIPlus_GraphicsDrawImage($hGraph, $hBuffer, 0, 0)

Do
Until GUIGetMsg() = -3

_GDIPlus_GraphicsDispose($hGraph)
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_ImageDispose($hImage)
_GDIPlus_BitmapDispose($hBuffer)
_GDIPlus_MatrixDispose($hMatrix)

_GDIPlus_Shutdown()

 

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...