Recent

Author Topic: Display issues for 32bpp glyphs on Ubuntu  (Read 8063 times)

wp

  • Hero Member
  • *****
  • Posts: 12787
Display issues for 32bpp glyphs on Ubuntu
« on: January 02, 2014, 01:14:09 am »
In one of my programs I am using the Fugue icon collection (http://p.yusukekamiyamane.com/) for toolbar glyphs. These are 16x16 png images with 32 bits per pixel. On Windows, they display nicely, but when transferred to Ubuntu they look strange as if some pixels are missing.

The attached project (png-bmp-32-24-bpp.zip) demonstrates the problem. I took one of the icons of that collection ("border.png") and converted it to bmp format and to 24 bits per pixel in order to learn whether the display issues are an issue of data format or color depth. The project displays these four icons in a toolbar, and, in addition, in four separate small TImage components. See the attached screen shots: In the windows version of the demo, all image look the same as I would expect. But in the Ubuntu version, the upper part of the 32bpp images is missing.

Since using icons in toolbars is such a typical programming task I am sure that someone must have seen this before and that I am doing something wrong. But what?
« Last Edit: January 02, 2014, 01:16:23 am by wp »

engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: Display issues for 32bpp glyphs on Ubuntu
« Reply #1 on: January 02, 2014, 06:21:05 am »
I don't think you are doing any thing wrong because the the 32 BPP images are converted to black and white images, the white became transparent showing the background color. Notice how in the visible lower half there are two missing corners. They are not missing, they became white (transparent) because the value of their RGB components is $84, more than $7F.

wp

  • Hero Member
  • *****
  • Posts: 12787
Re: Display issues for 32bpp glyphs on Ubuntu
« Reply #2 on: January 02, 2014, 05:05:33 pm »
I am not sure if I understand your posting correctly since 32bpp images definitely are not converted to b&w - see attachment showing the pale blue "thermometer" icon of the collection - and since it does not explain why Ubuntu behaves differently from Windows.

In the newly attached Windows screenshot the 32bpp and 24bpp look fine only on gray background, on the darker blue background, however, the 24 bpp glyph suffers from a strong bright border. This is because there seem to be some semi-transparent pixels along the outline of the thermometer and waterdrops. The image processing program used for converting the original 32bpp image to 24 bpp (xnview) assumes a white background when reducing color depth. Therefore, this background shines through for the outer pixels. Since there is no more transparency for the 24 bpp these icons look very strange on the dark background, but are okay on the bright background.

The 32 bpp icons are perfect in case of Windows. But in Ubuntu, the outline of the 32bpp images is missing (the 24 bpp images look the same as in Windows). Obviously, Ubuntu does not handle the alpha channel in the same way as Windows.

The question is: Is this an issue of Ubuntu (I am using 12.04 in a VirtualBox), or of my program? An argument against blaming Ubuntu is that is shows very strong transparency effects in relation with the Dash window indicating that it can handle transparency very well. So again, what is wrong with my program?

engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: Display issues for 32bpp glyphs on Ubuntu
« Reply #3 on: January 03, 2014, 03:31:07 am »
You are right, they did not get converted to b/w. I should have double checked the black pixels because they have TWO values 0 and 1. My previous post was trying to interpret the missing two corners in the lower half.

The problem with 32 BPP images on Ubuntu seems to me that the alpha component value is not taken into consideration, if a pixel has an alpha value less than 128 then it is considered totally transparent (as if alpha = 0). On the other hand, 24 BPP images show no problem and what I see is exactly what I expect.

I don't have Ubuntu. Following the source code lead me to:
Code: Text  [Select][+][-]
  1. procedure TRasterImage.Draw(DestCanvas: TCanvas; const DestRect: TRect);
  2. ..
  3.   StretchMaskBlt(DestDC,
  4.           DestRect.Left,DestRect.Top,
  5.           DestRect.Right-DestRect.Left,DestRect.Bottom-DestRect.Top,
  6.           SrcDC,0,0,Width,Height, UseMaskHandle,0,0,DestCanvas.CopyMode);
  7. ..
  8.  

StretchMaskBlt implementation on Windows is in:
$(LazarusDir)\lcl\interfaces\win32\win32winapi.inc

StretchMaskBlt implementation on GTK2 is in:
$(LazarusDir)/lcl/interfaces/gtk2/gtk2winapi.inc


wp

  • Hero Member
  • *****
  • Posts: 12787
Re: Display issues for 32bpp glyphs on Ubuntu
« Reply #4 on: January 04, 2014, 12:43:11 am »

Rails

  • Guest
Re: Display issues for 32bpp glyphs on Ubuntu
« Reply #5 on: January 04, 2014, 02:59:48 am »
They display properly in Debian. I pasted the small cross into an image list without modification. It's the one on the right.

Edit: I added a second attachment which has a different icon from the "Shadowless" group.

Edit 2: I was able to more or less duplicate your missing bits icons by pasting 32x32 icons from the bonus folder into my application's image list which is set for 16x16.

FWIW, I am compiling for QT, not GTK-2, but my Laz IDE is GTK-2 and they display properly in the designer, too.
« Last Edit: January 04, 2014, 04:24:40 am by Rails »

wp

  • Hero Member
  • *****
  • Posts: 12787
Re: Display issues for 32bpp glyphs on Ubuntu
« Reply #6 on: January 05, 2014, 12:03:10 am »
Has been fixed today by Kostas Michalopoulos (http://mantis.freepascal.org/view.php?id=25491). Exellent work - that's why I love Lazarus.

 

TinyPortal © 2005-2018