Sign in to follow this  
Followers 0
VIP

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

6 posts in this topic

#1 ·  Posted (edited)

 

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



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!

1 person likes this

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

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

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.

1 person likes this

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

[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

Good catch Trong!

1 person likes this

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