Jump to content
Sign in to follow this  
VIP

[SOLVED] PNG with transparency to gif/jpg/bmp error!

Recommended Posts

VIP

 

cclogo.jpg

 

Local $hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir&"\IMGtran.png")
            Local $sCLSID = _GDIPlus_EncodersGetCLSID("JPG")
             _GDIPlus_ImageSaveToFileEx($hImage, @ScriptDir&"\imgOut.jpg", $sCLSID)
            
            Local $sCLSID = _GDIPlus_EncodersGetCLSID("GIF")
            _GDIPlus_ImageSaveToFileEx($hImage, @ScriptDir&"\imgOut.gif", $sCLSID)
             
            Local $sCLSID = _GDIPlus_EncodersGetCLSID("BMP")
            _GDIPlus_ImageSaveToFileEx($hImage, @ScriptDir&"\imgOut.bmp", $sCLSID)

 

Image ouput:

ccluogo.jpg

 

Why not:
jpg.jpg

Edited by Trong

Regards,
 

Share this post


Link to post
Share on other sites
UEZ

Try this:

#include <GDIPlus.au3>

_GDIPlus_Startup()
$hImage = _GDIPlus_BitmapCreateFromMemory(InetRead("http://lifestyle.classifiedads4free.com/wp-content/uploads/2014/06/clash-of-clans-logo-672x321.png", 8))
$iW = _GDIPlus_ImageGetWidth($hImage)
$iH = _GDIPlus_ImageGetHeight($hImage)
$hImage_new = _GDIPlus_BitmapCreateFromScan0($iW, $iH)
$hGfx = _GDIPlus_ImageGetGraphicsContext($hImage_new)
_GDIPlus_GraphicsDrawImageRect($hGfx, $hImage, 0, 0, $iW, $iH)
_GDIPlus_ImageSaveToFile($hImage_new, @ScriptDir & "\clash-of-clans-logo-672x321.jpg")
_GDIPlus_ImageSaveToFile($hImage_new, @ScriptDir & "\clash-of-clans-logo-672x321.gif")
_GDIPlus_ImageSaveToFile($hImage_new, @ScriptDir & "\clash-of-clans-logo-672x321.bmp")
_GDIPlus_GraphicsDispose($hGfx)
_GDIPlus_ImageDispose($hImage)
_GDIPlus_ImageDispose($hImage_new)
_GDIPlus_Shutdown()

I cannot tell you why this effect appears when the image is directly saved!

  • Like 1

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
VIP

Try this:

#include <GDIPlus.au3>

_GDIPlus_Startup()
$hImage = _GDIPlus_BitmapCreateFromMemory(InetRead("http://lifestyle.classifiedads4free.com/wp-content/uploads/2014/06/clash-of-clans-logo-672x321.png", 8))
$iW = _GDIPlus_ImageGetWidth($hImage)
$iH = _GDIPlus_ImageGetHeight($hImage)
$hImage_new = _GDIPlus_BitmapCreateFromScan0($iW, $iH)
$hGfx = _GDIPlus_ImageGetGraphicsContext($hImage_new)
_GDIPlus_GraphicsDrawImageRect($hGfx, $hImage, 0, 0, $iW, $iH)
_GDIPlus_ImageSaveToFile($hImage_new, @ScriptDir & "\clash-of-clans-logo-672x321.jpg")
_GDIPlus_ImageSaveToFile($hImage_new, @ScriptDir & "\clash-of-clans-logo-672x321.gif")
_GDIPlus_ImageSaveToFile($hImage_new, @ScriptDir & "\clash-of-clans-logo-672x321.bmp")
_GDIPlus_GraphicsDispose($hGfx)
_GDIPlus_ImageDispose($hImage)
_GDIPlus_ImageDispose($hImage_new)
_GDIPlus_Shutdown()

I cannot tell you why this effect appears when the image is directly saved!

 

seemed better, but the image quality is not the best?


Regards,
 

Share this post


Link to post
Share on other sites
UEZ

For BMP it should be the same as the PNG but without transparency.

For GIF it is dithered because of 8-bit (max. 256 color).

For JPG you can set the quality but not with that code.

  • Like 1

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
VIP

[SOLVED]

$hImage_new = _GDIPlus_BitmapCreateFromScan0($iW, $iH,$GDIP_PXF32RGB)

 

#include <GDIPlus.au3>

_GDIPlus_Startup()
$hImage = _GDIPlus_BitmapCreateFromMemory(InetRead("http://lifestyle.classifiedads4free.com/wp-content/uploads/2014/06/clash-of-clans-logo-672x321.png", 8))
$iW = _GDIPlus_ImageGetWidth($hImage)
$iH = _GDIPlus_ImageGetHeight($hImage)
$hImage_new = _GDIPlus_BitmapCreateFromScan0($iW, $iH,$GDIP_PXF32RGB)
$hGfx = _GDIPlus_ImageGetGraphicsContext($hImage_new)
_GDIPlus_GraphicsDrawImageRect($hGfx, $hImage, 0, 0, $iW, $iH)
_GDIPlus_ImageSaveToFile($hImage_new, @ScriptDir & "\clash-of-clans-logo-672x3211.jpg")
_GDIPlus_ImageSaveToFile($hImage_new, @ScriptDir & "\clash-of-clans-logo-672x3211.gif")
_GDIPlus_ImageSaveToFile($hImage_new, @ScriptDir & "\clash-of-clans-logo-672x3211.bmp")
_GDIPlus_GraphicsDispose($hGfx)
_GDIPlus_ImageDispose($hImage)
_GDIPlus_ImageDispose($hImage_new)
_GDIPlus_Shutdown()

 


Regards,
 

Share this post


Link to post
Share on other sites
UEZ

Good catch Trong!

  • Like 1

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  

×