Jump to content
Sign in to follow this  
CyRius

Help for GDI+ and alpha background

Recommended Posts

CyRius

Hey.

I want to save a part of an image to a file, which have alpha (transparent) background color, but when i save the file the alpha background becomes black colored.

The icons size is decreased too from 30,7KB to 9,05KB, however the size didnt changed.

"$GDIP_PXF32ARGB = 32 bits per pixel; 8 bits for each RGB and alpha component"

So $GDIP_PXF32ARGB should create a 32 bit RGB and 8 bit alpha image, but it creates a 24 bit RGB and 1 bit alpha image.

Can anyone tell me what is the problem with my source code or any idea how could i copy a part from the file in other way?

Here it is my source:

#include <GDIPlus.au3>

$filePath = RegRead('HKLM\SOFTWARE\AutoIt v3\AutoIt','InstallDir');checks the AutoIt's InstallDir
FileCopy($filePath & '\Icons\au3.ico','au3.ico',1);copy an icon to @ScriptDir

_GDIPlus_StartUp()
$hImage = _GDIPlus_ImageLoadFromFile('au3.ico');load the image
$CLSID = '{557CF400-1A04-11D3-9A73-0000F81EF32E}';GUID string of ICO encoder
$hClone = _GDIPlus_BitmapCloneArea($hImage,0,0,48,48,$GDIP_PXF32ARGB);copy a 48x48 part from the file
_GDIPlus_ImageSaveToFileEx($hClone,'NewIcon.ico',$CLSID);saves the file
_GDIPlus_ImageDispose($hImage)
_GDIPlus_ImageDispose($hClone)
_GDIPlus_ShutDown()

NewIcon.ico

au3.ico

Edited by CyRius

[font="Courier New"][size="3"]CyRius Developments[/size][/font][list][*]CO Proxy[*]CO Assembly tool[*]CO PacketSniffer[*]Larkinor proxy[*]BoIM Messenger[*]Encrypt/Decrypt[*]Hashtables[*]Slowest, but greatest skins ever xD[/list]

Share this post


Link to post
Share on other sites
CyRius

Bump#

I cant believe it, that nobody can help me -.-


[font="Courier New"][size="3"]CyRius Developments[/size][/font][list][*]CO Proxy[*]CO Assembly tool[*]CO PacketSniffer[*]Larkinor proxy[*]BoIM Messenger[*]Encrypt/Decrypt[*]Hashtables[*]Slowest, but greatest skins ever xD[/list]

Share this post


Link to post
Share on other sites
UEZ

Your code is creating a BMP and not an ico file and BMP cannot save alpha channel as fas as I know!

I don't know yet whether _GDIPlus_ImageSaveToFileEx() can create ico files!

You can use e.g. $sCLSID = _GDIPlus_EncodersGetCLSID ("JPG") function to set correct CLSID.

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
CyRius

@UEZ

Thank you. As i know JPG cannot have alpha layer, or any transparent layer. But i will try it.

Greetz, CyRius


[font="Courier New"][size="3"]CyRius Developments[/size][/font][list][*]CO Proxy[*]CO Assembly tool[*]CO PacketSniffer[*]Larkinor proxy[*]BoIM Messenger[*]Encrypt/Decrypt[*]Hashtables[*]Slowest, but greatest skins ever xD[/list]

Share this post


Link to post
Share on other sites
UEZ

This was just an example about the output format, not for transparency.

You can use $sCLSID = _GDIPlus_EncodersGetCLSID ("PNG") for transparency.

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
CyRius

@UEZ

I didnt find any UDFs, how could i add a PNG image to a GuiCtrlCreatePic() control ^_^ So i cant use the PNG format.


[font="Courier New"][size="3"]CyRius Developments[/size][/font][list][*]CO Proxy[*]CO Assembly tool[*]CO PacketSniffer[*]Larkinor proxy[*]BoIM Messenger[*]Encrypt/Decrypt[*]Hashtables[*]Slowest, but greatest skins ever xD[/list]

Share this post


Link to post
Share on other sites
UEZ

@UEZ

I didnt find any UDFs, how could i add a PNG image to a GuiCtrlCreatePic() control ^_^ So i cant use the PNG format.

There is a nice example in AutoIt Help -> look for GuiCtrlCreatePic()

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
CyRius

Thanks UEZ, i found it, i was just "noob" ^_^)

Greetz, CyRius:)


[font="Courier New"][size="3"]CyRius Developments[/size][/font][list][*]CO Proxy[*]CO Assembly tool[*]CO PacketSniffer[*]Larkinor proxy[*]BoIM Messenger[*]Encrypt/Decrypt[*]Hashtables[*]Slowest, but greatest skins ever xD[/list]

Share this post


Link to post
Share on other sites
CyRius

Ohm:) I'm here again, because i have a new question.

I made this function to create the image array and the MY_WM_PAINT() draws the images from this array. ($sGraphic is global variable).

Is there any way to get the PNG image's handle, so i can use image like a button (like GuiCtrlCreatePic() or GuiCtrlCreateIcon() )?

Func GuiCtrlCreatePNGImage($hGUI,$hFile,$hXpos,$hYPos)
    If $hGUI = $hGUIlast Then
        $sGraphic[0][0] += 1
    Else
        $sGraphic[0][0] = 1
        $hGUIlast = $hGUI
    EndIf
    $sGraphic[$sGraphic[0][0]][0] = $hGUI
    $sGraphic[$sGraphic[0][0]][1] = _GDIPlus_ImageLoadFromFile($hFile)
    $hControlHwnd = $sGraphic[$sGraphic[0][0]][2] = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    $sGraphic[$sGraphic[0][0]][3] = $hXpos
    $sGraphic[$sGraphic[0][0]][4] = $hYPos
        Return $hControlHwnd
EndFunc

Greetz, CyRius


[font="Courier New"][size="3"]CyRius Developments[/size][/font][list][*]CO Proxy[*]CO Assembly tool[*]CO PacketSniffer[*]Larkinor proxy[*]BoIM Messenger[*]Encrypt/Decrypt[*]Hashtables[*]Slowest, but greatest skins ever xD[/list]

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.