Jump to content

Recommended Posts

Posted

I've tried in several cases to use a p.ng file in my program and was unsuccessful.

I would try it with GUICtrlCreatePic() and GUICtrlSetImage and so forth. Everytime I would try to use a .png

it would just put a blank space wherever the image was supposed to be.

does autoit support png's?

Posted

GDI+ is the key:

#include <GDIPlus.au3>
#include <WinAPI.au3>
_GDIPlus_Startup()
$image=_GDIPlus_ImageLoadFromFile("image.png")
_GDIPlus_ImageSaveToFile($image,"image.jpg")
_WinAPI_DeleteObject($image)
GUICreate("test",300,300)
GUICtrlCreatePic("image.jpg",10,10)
GUISetState()
Do
    $msg=GUIGetMsg()
Until $msg=-3
_GDIPlus_Shutdown()

:)

Broken link? PM me and I'll send you the file!

Posted (edited)

So it converts it over to a .jpg?

My image is very deformed in the gui?...

And it lost ALL of its glossiness, and resolution...

I wanted to use .png in the first place so I could have really good looking images.

Edited by nowagain
Posted

So it converts it over to a .jpg?

My image is very deformed in the gui?...

And it lost ALL of its glossiness, and resolution...

I wanted to use .png in the first place so I could have really good looking images.

Change to .bmp :)

Broken link? PM me and I'll send you the file!

Posted (edited)

Or you could paint the control yourself :)

#include <GDIPlus.au3>
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <WinAPI.au3>
_GDIPlus_Startup()
$image = _GDIPlus_ImageLoadFromFile("image.png")


$hwnd = GUICreate("test", 300, 300)
GUICtrlCreatePic("", 10, 10, 280, 280)
GUISetState()
GUIRegisterMsg($WM_PAINT, "_ReDraw")
$graphics = _GDIPlus_GraphicsCreateFromHWND($hwnd)
_GDIPlus_GraphicsDrawImageRect($graphics, $image, 10, 10, 280, 280)

Do
    $msg = GUIGetMsg()
Until $msg = -3
_WinAPI_DeleteObject($image)
_GDIPlus_GraphicsDispose($graphics)
_GDIPlus_Shutdown()

Func _ReDraw()
    _GDIPlus_GraphicsDrawImageRect($graphics, $image, 10, 10, 280, 280)
    Return $GUI_RUNDEFMSG
EndFunc ;==>_ReDraw
Edited by monoceres

Broken link? PM me and I'll send you the file!

  • 2 weeks later...
Posted

Or you could paint the control yourself :)

#include <GDIPlus.au3>
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <WinAPI.au3>
_GDIPlus_Startup()
$image = _GDIPlus_ImageLoadFromFile("image.png")


$hwnd = GUICreate("test", 300, 300)
GUICtrlCreatePic("", 10, 10, 280, 280)
GUISetState()
GUIRegisterMsg($WM_PAINT, "_ReDraw")
$graphics = _GDIPlus_GraphicsCreateFromHWND($hwnd)
_GDIPlus_GraphicsDrawImageRect($graphics, $image, 10, 10, 280, 280)

Do
    $msg = GUIGetMsg()
Until $msg = -3
_WinAPI_DeleteObject($image)
_GDIPlus_GraphicsDispose($graphics)
_GDIPlus_Shutdown()

Func _ReDraw()
    _GDIPlus_GraphicsDrawImageRect($graphics, $image, 10, 10, 280, 280)
    Return $GUI_RUNDEFMSG
EndFunc;==>_ReDraw
When I use this method whenever I move around my window a blackish border expands around my image and stays there. then i minimize it and it goes a way, but then re-appears when i move my window again...?
Posted

Here's the code I am using:

#include <GDIPlus.au3>
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <WinAPI.au3>
_GDIPlus_Startup()
$image = _GDIPlus_ImageLoadFromFile("glass.png")


$hwnd = GUICreate("", 500, 500)
GUICtrlCreatePic("", 20, 20, 24, 26)
GUISetBkColor(0xeef2fd, $hwnd)
GUISetState()
GUIRegisterMsg($WM_PAINT, "_ReDraw")
$graphics = _GDIPlus_GraphicsCreateFromHWND($hwnd)
_GDIPlus_GraphicsDrawImageRect($graphics, $image, 20, 20, 24, 26)

Do
    $msg = GUIGetMsg()
Until $msg = -3
_WinAPI_DeleteObject($image)
_GDIPlus_GraphicsDispose($graphics)
_GDIPlus_Shutdown()

Func _ReDraw()
    _GDIPlus_GraphicsDrawImageRect($graphics, $image, 20, 20, 24, 26)
    Return $GUI_RUNDEFMSG
EndFunc;==>_ReDraw

When I run it and move the window containing my .png image a black border forms around it. Is is the re-drawing function? I'm lost and also very new with this GDI+ stuff.

Posted

Try something like:

#include <GDIPlus.au3>
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <WinAPI.au3>
_GDIPlus_Startup()
$image = _GDIPlus_ImageLoadFromFile("glass.png")


$hwnd = GUICreate("", 500, 500)
GUICtrlCreatePic("", 22, 22, 20, 22); Changed here
GUISetBkColor(0xeef2fd, $hwnd) 
GUISetState()
GUIRegisterMsg($WM_PAINT, "_ReDraw")
$graphics = _GDIPlus_GraphicsCreateFromHWND($hwnd)
_GDIPlus_GraphicsDrawImageRect($graphics, $image, 20, 20, 24, 26)

Do
    $msg = GUIGetMsg()
Until $msg = -3
_WinAPI_DeleteObject($image)
_GDIPlus_GraphicsDispose($graphics)
_GDIPlus_Shutdown()

Func _ReDraw()
    _GDIPlus_GraphicsDrawImageRect($graphics, $image, 20, 20, 24, 26)
    Return $GUI_RUNDEFMSG
EndFunc;==>_ReDraw

Broken link? PM me and I'll send you the file!

Posted

As far as I can see it looks like its solved, but I don't understand why...

You changed the width and height (24,26) to 20,22. How did that fix it?

  • 7 months later...
Posted

As far as I can see it looks like its solved, but I don't understand why...

You changed the width and height (24,26) to 20,22. How did that fix it?

Difference by 'GUI Border Width' added, or not.

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
  • Recently Browsing   0 members

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