Jump to content

[SOLVED] _GUIImageList_Create _GUIImageList_AddIcon resolution


Recommended Posts

I would like to know how to increase the resolution of the icons in the grid.

$iColor = 5 is 32 bit DIB section.. but if I try with

$Image = _GUIImageList_Create(48,48,5,1)

the upscaling is very bad and pixelate, I have 32bit icon resolution with hight detail, how can I control or force the resolution of the icons ?

Thanks

Edited by rootx
Link to comment
Share on other sites

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $idListview, $hImage
    Local $iStylesEx = BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES)

    GUICreate("ImageList Create", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT))
    _GUICtrlListView_SetExtendedListViewStyle($idListview, $iStylesEx)
    GUISetState(@SW_SHOW)

    ; Load images
    $hImage = _GUIImageList_Create(48, 48,5,1)
   _GUIImageList_Add($hImage, _GUIImageList_AddIcon($hImage,@ScriptDir&"\ico.ico"))
 _GUICtrlListView_SetImageList($idListview, $hImage, 1)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Items", 120)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Item 1", 0)
   
    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

 

Link to comment
Share on other sites

You have to upscale the icon manually and add it afterwards to the _GUIImageList_Create.

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
#include <GDIPlus.au3>

Example()

Func Example()
    _GDIPlus_Startup()
    Local $idListview, $hImage
    Local $iStylesEx = BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES)

    GUICreate("ImageList Create", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT))
    _GUICtrlListView_SetExtendedListViewStyle($idListview, $iStylesEx)
    GUISetState(@SW_SHOW)

    ; Load images
    $hImage = _GUIImageList_Create(48, 48, 5, 1)

    ;load icon and upscale the icon to 48x48 pixels
    Local $hBitmap = _GDIPlus_BitmapCreateFromFile(@ScriptDir & "\empty.ico")
    Local $hBitmap_scaled = _GDIPlus_ImageResize($hBitmap, 48,  48)
    Local $hBitmap_GDI = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap_scaled)
    _GDIPlus_BitmapDispose($hBitmap_scaled)
    _GDIPlus_BitmapDispose($hBitmap)

    _GUIImageList_Add($hImage, $hBitmap_GDI)
    _GUICtrlListView_SetImageList($idListview, $hImage, 1)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Items", 120)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Item 1", 0)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
    _WinAPI_DeleteObject($hBitmap_GDI)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example

 

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

×
×
  • Create New...