CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2002
    Posts
    756

    ImageList question

    Hi, ALL,
    An ImageList_Create() function (see here) takes 2 parameters: cx and cy which are the width and height of each image.

    Everything is good if I know in advance what size my images will have. But what if I don't?

    Let's say I select 32x32 and my images are sized as 16x16. What will happen with the image list? Or my images are 48x48 and the image list should grow to accomodate the extra space. Since on Windows image list is just one big bitmap, will the height of the image list shrink/grow to 16/48 or not? Is there a way to test such behavior?

    The problem I'm having is to check whether the actual images will be truncated when they are bigger that the image list initial size or not or whether I will see some extra space if the images are smaller.

    The closest way I see is this function, but I am not sure its the right one to apply to the image list itself and not to the image inside the list.

    Does anybody know how to test this properly and reliably on Windows XP+?

    Thank you.
    Last edited by OneEyeMan; July 31st, 2014 at 10:11 PM.

  2. #2
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    4,626

    Re: ImageList question

    unclear what you're asking, but if you create a 32x32 imagelist, then all images will be 32x32. Imagelist does not accomodate for images in varying sizes. You can 'sort of' accomodate by oversizing the request and keeping track of the subsize yourself, but that then opens the question why even use an imagelist at all.

    if you add 16x16's, then they'll only be 16x16 in a 32x32box
    if you add larger images they'll be clipped to 32x32.

    you cannot "resize" the imagelist, you have to recreate it and copy the images over if you wanted.

    you should not use the GetImageInfo to try to CHANGE the bitmap the imagelist is managing, for all intents and purposes it's a "readonly"/const return value. Messing around with the handle will make the imagelist behave strangely.
    (to be more precise, you can paint on the image handle if you want to, but changing it is a nono)

  3. #3
    Join Date
    Aug 2002
    Posts
    756

    Re: ImageList question

    Hi,
    Quote Originally Posted by OReubens View Post
    unclear what you're asking, but if you create a 32x32 imagelist, then all images will be 32x32. Imagelist does not accomodate for images in varying sizes. You can 'sort of' accomodate by oversizing the request and keeping track of the subsize yourself, but that then opens the question why even use an imagelist at all.

    if you add 16x16's, then they'll only be 16x16 in a 32x32box
    if you add larger images they'll be clipped to 32x32.
    This is what I'm asking.(last 2 sentenses).
    Which means that the mage list will not be resized...

    Is there a way to get a size of the image list image and not an individual images in it?

    Thank you.

  4. #4
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    4,626

    Re: ImageList question

    sort of...
    but "why" ?
    you should view an imagelist as a collection of individual images. The fact that 'under the hood' this is implemented as a larger bitmap (actually a DDB) is implementation details you shouldn't really be dealing with.


    the size is width = number of images x imagewidth, height = imageheight.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured