Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

png files in autoit


  • Please log in to reply
13 replies to this topic

#1 AustrianOak

AustrianOak

    Almost done

  • Banned (NOT IN USE)
  • 640 posts

Posted 14 June 2008 - 04:16 PM

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?







#2 sandin

sandin

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 569 posts

Posted 14 June 2008 - 04:42 PM

PNGs are supported:
http://www.autoitscript.com/forum/index.ph...7651&hl=png
http://www.autoitscript.com/forum/index.ph...3225&hl=png

#3 monoceres

monoceres

    asdf

  • MVPs
  • 4,014 posts

Posted 14 June 2008 - 04:55 PM

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!


#4 AustrianOak

AustrianOak

    Almost done

  • Banned (NOT IN USE)
  • 640 posts

Posted 14 June 2008 - 05:07 PM

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, 14 June 2008 - 05:09 PM.


#5 monoceres

monoceres

    asdf

  • MVPs
  • 4,014 posts

Posted 14 June 2008 - 05:21 PM

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!


#6 monoceres

monoceres

    asdf

  • MVPs
  • 4,014 posts

Posted 14 June 2008 - 05:29 PM

Or you could paint the control yourself :)
Plain Text         
#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, 14 June 2008 - 05:29 PM.

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


#7 AustrianOak

AustrianOak

    Almost done

  • Banned (NOT IN USE)
  • 640 posts

Posted 14 June 2008 - 05:35 PM

That did it :)

Thanks a million.

#8 AustrianOak

AustrianOak

    Almost done

  • Banned (NOT IN USE)
  • 640 posts

Posted 26 June 2008 - 05:27 AM

Or you could paint the control yourself :)

Plain Text         
#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...?

#9 AustrianOak

AustrianOak

    Almost done

  • Banned (NOT IN USE)
  • 640 posts

Posted 26 June 2008 - 06:47 AM

Here's the code I am using:

Plain Text         
#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.

#10 AustrianOak

AustrianOak

    Almost done

  • Banned (NOT IN USE)
  • 640 posts

Posted 26 June 2008 - 09:11 PM

Bump. Does anyone need to see a screenshot?

#11 monoceres

monoceres

    asdf

  • MVPs
  • 4,014 posts

Posted 26 June 2008 - 09:20 PM

Try something like:


Plain Text         
#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!


#12 AustrianOak

AustrianOak

    Almost done

  • Banned (NOT IN USE)
  • 640 posts

Posted 27 June 2008 - 10:58 AM

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?

#13 ChangMinYang

ChangMinYang

    Adventurer

  • Active Members
  • PipPip
  • 100 posts

Posted 21 February 2009 - 05:02 PM

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.

#14 AustrianOak

AustrianOak

    Almost done

  • Banned (NOT IN USE)
  • 640 posts

Posted 22 February 2009 - 03:19 AM

this was a real old topic dude.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users