nend Posted January 21, 2017 Share Posted January 21, 2017 (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. Edited January 21, 2017 by nend Link to comment Share on other sites More sharing options...
Rex Posted January 21, 2017 Share Posted January 21, 2017 https://www.autoitscript.com/autoit3/docs/libfunctions/_WinAPI_SaveHICONToFile.htm Reading helpfile for _WinAPI_SaveHICONToFile I think that for a better quantity it should be _WinAPI_SaveHICONToFile($file_out, $hIcon, True) Cheers /Rex Link to comment Share on other sites More sharing options...
nend Posted January 21, 2017 Author Share Posted January 21, 2017 I read that to, but it won't make any difference. Link to comment Share on other sites More sharing options...
Rex Posted January 21, 2017 Share Posted January 21, 2017 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 Link to comment Share on other sites More sharing options...
nend Posted January 21, 2017 Author Share Posted January 21, 2017 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. Link to comment Share on other sites More sharing options...
UEZ Posted January 21, 2017 Share Posted January 21, 2017 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 More sharing options...
nend Posted January 21, 2017 Author Share Posted January 21, 2017 (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 January 21, 2017 by nend Link to comment Share on other sites More sharing options...
UEZ Posted January 21, 2017 Share Posted January 21, 2017 (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 January 21, 2017 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 More sharing options...
nend Posted January 21, 2017 Author Share Posted January 21, 2017 Ok I will try it again, thanks for the anwser. Link to comment Share on other sites More sharing options...
nend Posted January 21, 2017 Author Share Posted January 21, 2017 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 Link to comment Share on other sites More sharing options...
nend Posted January 21, 2017 Author Share Posted January 21, 2017 I think there are 2 problems the first bad qaulity. I think this has to do because it has been resize so much. The second one is a border around the icon and this I have solved bij doing this, see this link http://superuser.com/questions/956531/how-to-remove-borders-around-desktop-shortcut-icons-windows-10 Thanks all for al the help. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now