Jump to content

Get better ico quality [SOLVED]


nend
 Share

Recommended Posts

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
Link to comment
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

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

Link to comment
Share on other sites

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

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...