Sign in to follow this  
Followers 0
redfenix

PNG over JPG (with trasparency)

6 posts in this topic

Hello,

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

Thanks! :)

Share this post


Link to post
Share on other sites



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

So i load png image first, then jpg?

my idea: this and this become this.

In your method i haven't this result :(

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)
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 ;)

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Ohh *.*

Thanks a lot!  :thumbsup:

EDIT: tinypic convert png to jpg :(

Edited by redfenix

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  
Followers 0