Recent

Author Topic: Color problem with TListView  (Read 360 times)

zamtmn

  • Sr. Member
  • ****
  • Posts: 365
Color problem with TListView
« on: August 27, 2019, 08:17:05 am »
Ha all!
I'm just adding a png to ImageList and ListView. The colors are distorted, the black text in the png is distorted, he becomes white and is visible only when the element is selected. Please help to fix it. Original png and test project attached

ASerge

  • Hero Member
  • *****
  • Posts: 1432
Re: Color problem with TListView
« Reply #1 on: August 27, 2019, 03:22:01 pm »
I'm just adding a png to ImageList and ListView. The colors are distorted, the black text in the png is distorted, he becomes white and is visible only when the element is selected. Please help to fix it. Original png and test project attached
When I use your project, the icons are displayed without text. When I create new project and add png, but leave as you have 16x16 for ImageList, the text is visible, but blurred. If I do ImageList 32x32 and insert png, it looks like this.

wp

  • Hero Member
  • *****
  • Posts: 6621
Re: Color problem with TListView
« Reply #2 on: August 27, 2019, 04:06:27 pm »
Since TImageList still handles TBitmap images I think it still respects the old non-alpha channel transparency in which those pixels were considered to be transparent which had the color of the left-bottom corner pixel. In your image, there is a row of black pixels along the bottom and right edge of the image - I don't know if this is intended, but it has the consequence that the left-bottom pixel is black - the same color as the text. Therefore the text is rendered transparently, and on the white default Listview background it becomes white... You can avoid this when you select in the ImageList Editor a not-used color as "TransparentColor" (often the "ugly" clFuchsia).

What do you mean with "distorted" text? That the 16x16 image is no longer crisp but blurred? Since you loaded only a 32x32 image but set up the imagelist to provide also a 16x16 image, the 16x16 is calculated from the 32x32 image by a scaling transformation. If you require a crisp 16x16 image you should add this size separately (use "Replace" in the ImageList Editor); it is required to set up the image list for both 16x16 and 32x32 images - but you did this.
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

zamtmn

  • Sr. Member
  • ****
  • Posts: 365
Re: Color problem with TListView
« Reply #3 on: August 28, 2019, 08:54:14 am »
wp, ASerge
Thanks, that's because of the black stripes on the bottom. As always, the problem was elsewhere, in pngs creating procedure