nend

Get better ico quality [SOLVED]

11 posts in this topic

#1 ·  Posted (edited)

Hi all,

I've found a udf wich convert a jpg into a ico file.

It works ok but the quality of the ico is very low, is it possible to make this better.

If I use a ico editor software the ico file has a much better quality.

#include <GDIPlus.au3>

_GDIPlus_Startup()
_CreateIconFile(@ScriptDir & "\Q-music.jpg", @ScriptDir & "\Test.ico")
_GDIPlus_Shutdown()


Func _CreateIconFile($file_in, $file_out)
    Local $a_hBitmap[2]

    Local $hPng = _GDIPlus_ImageLoadFromFile($file_in)
    Local $aDim = _GDIPlus_ImageGetDimension($hPng)

    Local $tData = _GDIPlus_BitmapLockBits($hPng, 0, 0, $aDim[0], $aDim[1], $GDIP_ILMREAD, $GDIP_PXF32PARGB)
    Local $pBits = DllStructGetData($tData, 'Scan0')
    If Not $pBits Then Return 0

    $a_hBitmap[0] = _WinAPI_CreateDIB($aDim[0], $aDim[1])
    If Not @error Then
        _WinAPI_SetBitmapBits($a_hBitmap[0], $aDim[0] * $aDim[1] * 4, $pBits)
    EndIf
    _GDIPlus_BitmapUnlockBits($a_hBitmap, $tData)
    _GDIPlus_ImageDispose($hPng)

    $a_hBitmap[1] = _WinAPI_CreateANDBitmap($a_hBitmap[0])

    Local $hIcon = _WinAPI_CreateIconIndirect($a_hBitmap[0], $a_hBitmap[1])
    If $hIcon Then
        _WinAPI_SaveHICONToFile($file_out, $hIcon)
        _WinAPI_DestroyIcon($hIcon)
    EndIf
EndFunc

I use this to make automaticly shortcuts for a program wich uses image (jpg files), It has to be converted to a ico file to use it with a shortcut. 

Q-music.jpg

Edited by nend

Share this post


Link to post
Share on other sites



I read that to, but it won't make any difference.

Share this post


Link to post
Share on other sites

I just tested with your file

Test is with your image direct in/out

Test1 is thru a image editor where I changed the image dimensions to 32x32

One can see that there is a slight difference between those two.

Cheers

/Rex

Test.ico

Test1.ico

Share this post


Link to post
Share on other sites

I see what's wrong it is poorly displayed as I use it as a shortcut.

If I take a origenal ico file it looks good on a shortcut but not If I converted it with the code above.

See the image below the chain is normal ico file use as shortcut and the qmusic logo is a ico made with code above and use as shortcut.

See the difference between them.

I think it's something easy but can find out what it is.

Knipsel.JPG

Share this post


Link to post
Share on other sites

I cannot see the low quality ico file. The ico file looks like the jpg image.


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

#7 ·  Posted (edited)

Can you see it on the image screenshot I've posted just before your message?

The low quality is getting vissilbe when you used it as a shortcut.

Edited by nend

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

That is windows related not the result of the code. Reduce the size from 200x200 for e.g. 64x64 and try again.

 

What is the resolution of the chain icon?

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

Ok I will try it again, thanks for the anwser.

Share this post


Link to post
Share on other sites

#10 ·  Posted

The resolution of the chain icon is 256X256 if I see it right.

I attached the icon.

I also think it has something todo with Windows but I dont understand why the chain ico wil show up alright.

icon.ico

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