Jump to content
Sign in to follow this  

PNG over JPG (with trasparency)

Recommended Posts

Check out the helpfile for GUICtrlCreatePic().  No, it can't be used directly to display a .png, but it *does* show you an example of GDI+ being used to show a .png image.  Once you've got that, you just need to display your .jpg image via GDI+ or GUICtrlCreatePic().  :) 

Share this post

Link to post
Share on other sites

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GDIPlus.au3>
#include <GuiConstantsEx.au3>
Local  $Form1_1,$Pic1,$hImage,$hGraphic
Opt("MustDeclareVars", 1)
#Region ### START Koda GUI section ### Form=c:\users\bt\desktop\autoit\png over jpg\form1.kxf
$Form1_1 = GUICreate("Form1", 152, 151, 192, 124)
$Pic1 = GUICtrlCreatePic("C:\Users\BT\Desktop\Autoit\PNG over JPG\image2.jpg", 0, 0, 150, 150)
#EndRegion ### END Koda GUI section ###
$hImage   = _GDIPlus_ImageLoadFromFile("image1.png")
$hGraphic = _GDIPlus_GraphicsCreateFromHWND($Form1_1)
_GDIPlus_GraphicsDrawImage($hGraphic, $hImage,-10, 0)
until GUIGetMsg() = $GUI_EVENT_CLOSE



You may continue resting ;)

Share this post

Link to post
Share on other sites


how can i do for draw png image over jpg image? (i know gdiplus)

Thanks! :)


If you know GDI+ where is your try?

Anyhow, here a way to do it:

#include <GDIPlus.au3>

$hBmp_Background = _GDIPlus_BitmapCreateFromFile("c:\Program Files (x86)\AutoIt3\Examples\GUI\msoobe.jpg") ;load background image
$hGfxContext = _GDIPlus_ImageGetGraphicsContext($hBmp_Background) ;get graphic context
$hBmp_Foreground = _GDIPlus_BitmapCreateFromFile("c:\Program Files (x86)\AutoIt3\Examples\GUI\Torus.png") ;load a transparent png image

_GDIPlus_GraphicsDrawImageRect($hGfxContext, $hBmp_Foreground, _
                                             _GDIPlus_ImageGetWidth($hBmp_Background) - _GDIPlus_ImageGetWidth($hBmp_Foreground), _ ;position right upper corner
                                             0, _
                                             _GDIPlus_ImageGetWidth($hBmp_Foreground), _ ;get width from foreground image
                                             _GDIPlus_ImageGetHeight($hBmp_Foreground)) ;;get height from foreground image
$sFile = @ScriptDir & "\New_Image.png"
_GDIPlus_ImageSaveToFile($hBmp_Background, $sFile)

Both images from your link in post #3 are JPGs.



Edited by 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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post

Link to post
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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...