Bug Report Q181609
Visible to All Users

cxImageList - Loading image into a Glyph property using the GetBitmap method gives a low-quality image

created 17 years ago

Please find attached a sample project to demonstrate my question/problem
Button 1 loads an image from the imagelist using GETIMAGE the quality of the image is poor
Button 2 loads an image from the imagelist using GETBITMAP the quality of the image if GOOD (apart from the white background)
Clicking on the buttons should then change the image to the 2nd one in the image list. It does using GETIMAGE but not using GETBITMAP - I thought this had been fixed ?
Mark

Comments (2)
Serge (DevExpress Support) 17 years ago

    Hi Mark,
    Basically, it's necessary to use the TcxImageList.GetImage method … as suggested in the following reports:
     - B18929 ("TcxButton - Glyph loaded from an ImageList looks corrupted")
     - B20170 ("Button glyphs are painted incorrectly")
     - Q106588 ("How to properly change the ribbons application button glyph image at runtime?")
    If you need to use the GetBitmap method, please apply the code modification, suggested in report B18452 ("Loading a glyph from an ImageList, image isn't displayed in dxBarButton").
    In any case, I see that the GetBitmap method returns a low-quality image. Our developers will research the problem. Thanks for your patience.
    Regards,
    Serge

    Serge (DevExpress Support) 16 years ago

      Dear Mark,
      We apologize for the late response. It took us significant time to research the situation. Here are the results of our investigation:
      The main difference between the GetBitmap and GetImage methods is:
       - TImageList.GetBitmap paints an image on the destination bitmap;
       - TcxImageList.GetImage copies an image to the destination bitmap, WITHOUT its mask and WITHOUT the TransparentColor.
      Both methods adjust the size of the resulting bitmap, but do NOT adjust its PixelFormat.
      You must take these peculiarities into account to avoid problems like this. In particular:
       1) the cxButton.Glyph.PixelFormat value may be "wrong" - ideally, it should match the original color depth of the image loaded from the cxImageList;
       2) when the GetBitmap method is used, you should prepare the background of the cxButton.Glyph, because the cxImageList will paint on this background. This is important especially for 32bit images. This is why it's better to use the GetImage method for these images.
       3) when the GetImage method is used, you should take the settings of the image, stored in the cxImageList, into account. In particular, whether it was saved with or without mask and/or TransparentColor. A mask is added if an image was imported from an ImageList, or if it was added to an old-format cxImageList (version < 1). If an image has a mask or TransparentColor, it's better to use the GetBitmap method.
      Once you've read this, you may treat using of the TcxImageList very complex, and even unacceptable. However, this is only the first impression:
       1) In fact, the TcxImageList is mostly intended to work with 32bit images. We've specially designed this components to serve user requests for the alpha-blending support best.
       2) If you add similar images (with the same color depth) to your cxImageList, you won't encounter such problems when retrieving them.
      Thanks,
      Serge

      Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

      Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.