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

Using a png in my program


  • Please log in to reply
81 replies to this topic

#1 AustrianOak

AustrianOak

    Almost done

  • Banned (NOT IN USE)
  • 640 posts

Posted 07 August 2008 - 06:20 PM

I really need to be able to put .pngs in my program and I've read the topics showing how to do this but it seems like a LONG DRAWN OUT process that will take a lot of code and a lot of time.

I was wondering if there is a simpler way to do this and if there is I'd appreciate it if someone told me because I'm wondering if there is a way to do this with no more than 4 or 5 lines of code.

Please help! :P







#2 Szhlopp

Szhlopp

    DC Talk JF

  • Active Members
  • PipPipPipPipPipPip
  • 469 posts

Posted 07 August 2008 - 06:44 PM

I really need to be able to put .pngs in my program and I've read the topics showing how to do this but it seems like a LONG DRAWN OUT process that will take a lot of code and a lot of time.

I was wondering if there is a simpler way to do this and if there is I'd appreciate it if someone told me because I'm wondering if there is a way to do this with no more than 4 or 5 lines of code.

Please help! :P

Here you go...

Very simple, 1 command and you have a PNG bacgkround. :P

However, it's the coding of all the buttons that takes time.


#include <PNGbackgroundUDF.au3> CreateTransparentGUI($Title)


In the SAME folder you need an image called :
"Background.png" and "Grey2.gif".
I've included the Grey image, you need to put the background image in the SAME folder as PNGUDF.au3 =)

Attached File  PNGUDF.zip   1.11KB   431 downloads

#3 AustrianOak

AustrianOak

    Almost done

  • Banned (NOT IN USE)
  • 640 posts

Posted 07 August 2008 - 06:55 PM

Wow this is great!!! Thanks! :P

Btw, what do you mean when you say the coding of all the buttons takes all the time.

And what if I want to create more than one png? Windows won't let me have 10 or so images called background.png

#4 monoceres

monoceres

    idiot, slow down

  • MVPs
  • 4,041 posts

Posted 07 August 2008 - 07:02 PM

I think I gave you a good answer in your previous thread with the same subject:
http://www.autoitscript.com/forum/index.ph...3624&hl=png
:P

And even though that code is more than 4-5 lines it definitely not a long drawn out process.

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


#5 Szhlopp

Szhlopp

    DC Talk JF

  • Active Members
  • PipPipPipPipPipPip
  • 469 posts

Posted 07 August 2008 - 07:05 PM

Wow this is great!!! Thanks! :P

Btw, what do you mean when you say the coding of all the buttons takes all the time.

And what if I want to create more than one png? Windows won't let me have 10 or so images called background.png


This was designed for a single PNG.

You would have to understand how the function worked to use more than one PNG=) Figure it out, otherwise just use normal windows for children or whatever=)

#6 AustrianOak

AustrianOak

    Almost done

  • Banned (NOT IN USE)
  • 640 posts

Posted 07 August 2008 - 07:06 PM

Monceres,

whenever I would move the window containing the png a black shadow would expand around it up to about 20 pixels.

If that wouldnt have happened, i wouldnt have started this thread...

#7 monoceres

monoceres

    idiot, slow down

  • MVPs
  • 4,041 posts

Posted 07 August 2008 - 07:12 PM

Monceres,

whenever I would move the window containing the png a black shadow would expand around it up to about 20 pixels.

If that wouldnt have happened, i wouldnt have started this thread...


If you comment out the GUICtrlCreatePic() line then no black pixel should appear.
Of course then you won't have a control that can receive events and such but that could be fixed by some manually work.

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


#8 AustrianOak

AustrianOak

    Almost done

  • Banned (NOT IN USE)
  • 640 posts

Posted 07 August 2008 - 09:09 PM

Well I've been studying the code for a while and thought that maybe I could increment the background.png name
like: (..."\Background" & 1 & ".png").

And thats all I've come up with (which is pretty sad...).

Can I have a hint? :P

Edited by IWantIt, 07 August 2008 - 09:09 PM.


#9 AustrianOak

AustrianOak

    Almost done

  • Banned (NOT IN USE)
  • 640 posts

Posted 08 August 2008 - 01:08 AM

No hint?

#10 AustrianOak

AustrianOak

    Almost done

  • Banned (NOT IN USE)
  • 640 posts

Posted 09 August 2008 - 05:37 PM

bump

#11 AustrianOak

AustrianOak

    Almost done

  • Banned (NOT IN USE)
  • 640 posts

Posted 10 August 2008 - 05:02 AM

Im still lost on this one. Can somebody offer a helpful hint?

:P

#12 davecollinsnz

davecollinsnz

    Seeker

  • Active Members
  • 40 posts

Posted 10 August 2008 - 05:09 AM

For $i=1 to 15
(..."\Background" & $i & ".png")
Next

I think thats sort of what you asked for...
Trust me to make SkyNet with AutoIt...

#13 AustrianOak

AustrianOak

    Almost done

  • Banned (NOT IN USE)
  • 640 posts

Posted 10 August 2008 - 05:25 AM

yes, but that is only part of the solution to this problem. i will need someway to tell it to display each of the fifteen different images whenever called upon. (dont even know if im saying this right...)
@PsaltyDS: whenever you get back, it'd be really helpful if you could help...

here's the updated code (not much updated)

AutoIt         
#include <GDIPlus.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> #include <GuiConstantsEx.au3> Global Const $AC_SRC_ALPHA      = 1 Global $hImage, $gui1, $controlGui Func CreateTransparentGUI($Title) ;if FileExists(@ScriptDir & '\grey.gif') = 0 then _GDIPlus_Startup() For $i=1 to 15 $hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\Background" & $i & ".png") Next $ImageHeight = _GDIPlus_ImageGetHeight($hImage) $ImageWidth = _GDIPlus_ImageGetWidth($hImage) $gui1 = GUICreate($Title, $ImageWidth, $ImageHeight, -1, -1, $WS_popup, $WS_EX_LAYERED) SetBitMap($gui1, $hImage, 255) GUISetState() $controlGui = GUICreate("ControlGUI", $ImageWidth, $ImageHeight, -1, -1, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $GUI1) GUICtrlCreatePic(@ScriptDir & "\grey2.gif", 0, 0, $ImageWidth, $ImageHeight) GUICtrlSetState(-1, $GUI_DISABLE) GUISetState() GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST") EndFunc Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam)   if ($hWnd = $gui1) and ($iMsg = $WM_NCHITTEST) then Return $HTCAPTION EndFunc Func SetBitmap($hGUI, $hImage, $iOpacity)   Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend   $hScrDC  = _WinAPI_GetDC(0)   $hMemDC  = _WinAPI_CreateCompatibleDC($hScrDC)   $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)   $hOld    = _WinAPI_SelectObject($hMemDC, $hBitmap)   $tSize   = DllStructCreate($tagSIZE)   $pSize   = DllStructGetPtr($tSize  )   DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth ($hImage))   DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($hImage))   $tSource = DllStructCreate($tagPOINT)   $pSource = DllStructGetPtr($tSource)   $tBlend  = DllStructCreate($tagBLENDFUNCTION)   $pBlend  = DllStructGetPtr($tBlend)   DllStructSetData($tBlend, "Alpha" , $iOpacity    )   DllStructSetData($tBlend, "Format", $AC_SRC_ALPHA)   _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA)   _WinAPI_ReleaseDC   (0, $hScrDC)   _WinAPI_SelectObject($hMemDC, $hOld)   _WinAPI_DeleteObject($hBitmap)   _WinAPI_DeleteDC    ($hMemDC) EndFunc


#14 davecollinsnz

davecollinsnz

    Seeker

  • Active Members
  • 40 posts

Posted 10 August 2008 - 05:50 AM

NextBG() Global $bgcount=1 Func NextBG() $hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\Background" & $bgcount & ".png") $bgcount+=1 if $bgcount>15 then $bgcount=1; reset Endfunc

How about this?
Trust me to make SkyNet with AutoIt...

#15 AustrianOak

AustrianOak

    Almost done

  • Banned (NOT IN USE)
  • 640 posts

Posted 10 August 2008 - 06:04 AM

Im a confused ass retard. But out of all my confusion I think your first example was fine. Its just even though we are incrementing the picture file name, we still have to find a way to load them all on command and right now its only loading $hImage.

#16 davecollinsnz

davecollinsnz

    Seeker

  • Active Members
  • 40 posts

Posted 10 August 2008 - 06:24 AM

You could try updating the graphic by deleting it and creating a new one each time. I saw a graphic that updates that way here. It should be able to be adapted to show a different png each time.
Trust me to make SkyNet with AutoIt...

#17 AustrianOak

AustrianOak

    Almost done

  • Banned (NOT IN USE)
  • 640 posts

Posted 24 August 2008 - 05:56 PM

This was designed for a single PNG.

You would have to understand how the function worked to use more than one PNG=) Figure it out, otherwise just use normal windows for children or whatever=)


Schzlopp:

Hi, I've been trying to figure it out for a long time now, whats the way to use it for multiple pngs?

Edited by IWantIt, 13 September 2008 - 05:05 PM.


#18 AustrianOak

AustrianOak

    Almost done

  • Banned (NOT IN USE)
  • 640 posts

Posted 26 August 2008 - 08:40 PM

Bump

#19 AustrianOak

AustrianOak

    Almost done

  • Banned (NOT IN USE)
  • 640 posts

Posted 31 August 2008 - 04:36 PM

Bump

#20 AustrianOak

AustrianOak

    Almost done

  • Banned (NOT IN USE)
  • 640 posts

Posted 12 September 2008 - 04:12 PM

Bump.

Edited by IWantIt, 12 September 2008 - 04:13 PM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users