Jump to content

PNG over JPG (with trasparency)


Go to solution Solved by Loken,

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().  :) 

Link to comment
Share on other sites

  • Solution

#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)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
_GDIPlus_StartUp()
$hImage   = _GDIPlus_ImageLoadFromFile("image1.png")
$hGraphic = _GDIPlus_GraphicsCreateFromHWND($Form1_1)
_GDIPlus_GraphicsDrawImage($hGraphic, $hImage,-10, 0)
do
until GUIGetMsg() = $GUI_EVENT_CLOSE
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_ImageDispose($hImage)
_GDIPlus_ShutDown()

 

qh6hg.jpg

You may continue resting ;)

Link to comment
Share on other sites

Hello,

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>

_GDIPlus_Startup()
$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)
_GDIPlus_GraphicsDispose($hGfxContext)
_GDIPlus_BitmapDispose($hBmp_Background)
_GDIPlus_BitmapDispose($hBmp_Foreground)
_GDIPlus_Shutdown()
ShellExecute($sFile)
Exit

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

Br,

UEZ

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

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