RowImageAt not using ImageSets

It looks like ImageRowAt is not using ImageSets.
When adding an image to a ListBox Row the image becomes very jagged and blurry.

If you create an ImageSet yourself it looks fine.

It can be tried with a Canvas (16x16) and two ListBoxes all showing the same picture added to the project. Original @ 512x512 and 1024x1024.

Paint event for the Canvas:

g.DrawPicture(Logo, 0, 0, g.Width, g.Height, 0, 0, Logo.Width, Logo.Height)

Opening Event for ListBox1:

Var p As New Picture(16, 16)
p.Graphics.DrawPicture(Logo, 0, 0, p.Width, p.Height, 0, 0, Logo.Width, Logo.Height)

For i As Integer = 0 to 10
  Me.AddRow("Row " + i.ToString)
  Me.RowImageAt(i) = p
Next

Opening Event for ListBox 2:

Var px1 As New Picture(16, 16)
Var px2 As New Picture(32, 32)
Var BitMaps() As Picture

px1.Graphics.DrawPicture(Logo, 0, 0, px1.Width, px1.Height, 0, 0, Logo.Width, Logo.Height)
px2.Graphics.DrawPicture(Logo, 0, 0, px2.Width, px2.Height, 0, 0, Logo.Width, Logo.Height)

BitMaps.Add(px1)
BitMaps.Add(px2)

Var PicSet As New Picture(16, 16, BitMaps())

For i As Integer = 0 to 10
  Me.AddRow("Row " + i.ToString)
  Me.RowImageAt(i) = PicSet
Next

The Canvas produces a nicely scaled logo.
ListBox1 produces a poor result while ListBox2 does fine just like the canvas.

Is this by design or is it a bug that you have to create an ImageSet yourself when using RowImageAt?

macOS Monterey 12.1
XOJO 2021 Version 3

You want to get a 16 x 16 image from a 512 x 512 original (or worst: 1024 x 1024) ?

Unless impossible, I would suggest you design your 16 x 16 image and load it in Xojo (either in a ImageSet or load the appropriate resolution dynamically when needed).

I know that people use all the time large to larger image reduced to micro-stamp nowadays, but this (as you noted) is not efficient nor nice.

HiDPI/Retina does not means FullHD images to display a 16 x 16 or 32 x 32 “button sized” icon.

You are absolutely right Emile. I would never use a 512x512 or 1024x1024 image for a 16x16 icon in a real application. I would choose a more appropriate resolution.
I chose the large image in this situation to show that XOJO is perfectly capable of scaling and that’s not the issue here. I think the issue here is that ImageSets are not used in conjunction with RowImageAt.

Yes, you are right, but what about the quality ?

The larger the image is and the lower thre quality can be if you resize to small to very small.

And in some cases (do not resize images with text inside), the result is… far from nice. Using macOS Preview (or GIMP ?) is often a good idea.

Or… do the resize down in two steps; say 1024 to 512 and then 512 to 128 (examples) can help.

.ico files (Windows) are limited to 256 x 256; when I generate custom folders ico, I often have to do that by hand (macOS Preview to resize the cover) instead of using my custom application.

I experienced this with Xojo… until 2021r2.1 (2021r3 and > are “persona non grata” here).

ImageSets are not used in conjunction with RowImageAt
This is perfectly possible. The LMistBox is a very old Control, so… did you tried DesktopListBox ?

Yes, the experiment is made with DesktopCanvas and DesktopListBox. And it seems that XOJO ignores the ImageSet in DesktopListBox and ImagerowAt

Forum for Xojo Programming Language and IDE. Copyright © 2021 Xojo, Inc.