Guest Posted April 13 Hi, I am rather new to Delphi Pascal but am making rewarding progress. But I have a problem with pixelated images showing up in a listview component, and also showing up this same way in an image component. I have the stretch option enabled but it is to having no impact. Any suggestions or advice as to why the picture icons in the listview component do not display properly are highly appreciated. I have attached screenshots that show what I am running into, the source of the problem seems to be with the listview display. Thank you kindly, from Clifford Share this post Link to post
PeterBelow 238 Posted April 13 Stretching bitmaps to a larger size (e.g. a 16x16 bitmap to 64x64) has this effect. The Windows API function used by the VCL is not very good at reducing the unavoidable degradation in image quality by interpolating the new pixels added between the original ones. You get much better results using vector formats like SVG as source, which can be rendered to practically any size without quality loss as long as the aspect ratio is not too far off the original. For bitmaps used for UI elements (buttons, menus, listview items etc.) Delphi offers TImageCollection and TVirtualImagelist. The former can store multiple versions (different sizes) of an image and the latter is used to then pick the best fitting version for a particular screen resolution. Share this post Link to post
FPiette 383 Posted April 13 Your TImageList seems to contain 16x16 pixels images. That's why it is pixelated. Use the same size - in pixels - as the source image. 2 Share this post Link to post
Guest Posted April 13 My source images are all about 600 pixels on a side. One of the pictures I posted is a source image example (the one that can be understood) before I loaded it. All that I am doing is using "Add" and then picking the 600 pixel source image, but then they show up like we are speaking about. I looked into a property where I saw height and width were 16 (I will look into that again) and tried to enlarge it to 600, but it had a maximum allowable value of 256, so that did not seem to make sense either. I will study the comments here and I thank you for any responses. My original images are jpgs like the one actual size sample shown. from Clifford Share this post Link to post
Guest Posted April 13 (edited) OK, I have solved it. Very strange solution to me, but problem is definitely tied into the default setting of 16x16 height width in the imagelist component. I set to maximum allowable of 256 x 256 pix and now the images are loading quite fair. I find it surprising that a 256 pix max condition exists, and even though it is far short of rather modest image display desired of 600 pix, it will still work fine for my current need. Ok for now, but still a mystery to me why such low limits would exist for an image component, and why they are set as the default, and what is the actual resolution limit and capacity of display. Able to move on the next higher priority now though, thanks much, Best regards, from Clifford. Edited April 13 by Guest Share this post Link to post
Anders Melander 1782 Posted April 13 29 minutes ago, cecarnicom said: but still a mystery to me why such low limits would exist for an image component Maybe you should think a bit more about that. Ideally until it is no longer a mystery. What possible reason could there be for that limit? The 16x16 default is a big clue... 2 Share this post Link to post
Remy Lebeau 1394 Posted April 13 6 hours ago, cecarnicom said: My source images are all about 600 pixels on a side... My original images are jpgs Given that your images are large, and not even bitmaps to begin with, I would suggest an alternative approach - get rid of the TImageList altogether. Instead, create an array/TList of TJPGImage objects, and then owner-draw them onto your ListView/ListBox items as needed. Share this post Link to post
Guest Posted April 14 (edited) Thank you Remy for that recommendation, I will look into that suggestion on the next round. Anders, and I probably will in due time. Not everyone operates at the same level of experience or competence, however, and a less snide attitude might be more supportive in the future. It has been well over 20-25 years since I have been in the programming arena so my experience and history is different than yours. I will keep in mind your "clue" for something I am learning about for the first time, thank you. I am sure another clue, that I found curious, but from my viewpoint is also worth learning and questioning about, is that the imagelist component is accepting up to>=20 images, but does not allow sorting or manipulation beyond 20 images in the interface. I find the discovery process and programming of interest and value, and I thank you almost entirely all for your comments and help. I have found the option to ignore certain users, so all is fine, thank you. Best regards, from Clifford Edited April 14 by Guest Share this post Link to post
PeterBelow 238 Posted April 16 (edited) On 4/13/2024 at 10:50 PM, cecarnicom said: OK, I have solved it. Very strange solution to me, but problem is definitely tied into the default setting of 16x16 height width in the imagelist component. I set to maximum allowable of 256 x 256 pix and now the images are loading quite fair. I find it surprising that a 256 pix max condition exists, and even though it is far short of rather modest image display desired of 600 pix, it will still work fine for my current need. Ok for now, but still a mystery to me why such low limits would exist for an image component, and why they are set as the default, and what is the actual resolution limit and capacity of display. Able to move on the next higher priority now though, thanks much, Best regards, from Clifford. The reason is quite simple: the component is based on a Windows common control which is intended to serve as storage for small images/icons used for menu items, buttons, listview items. To reduce the consumption of GDI handles the control merges all added bitmaps into one large bitmap for storage. That's the reason all bitmaps added are forced to the same size, this way the imagelist can calculate where on the combined bitmap each image resides and then paint that part to the target location. There is a maximum size to a GDI bitmap, so this puts limits on the size and number of the images you can put into a TImagelist. Looks like the control is simply not suitable for your task. Edited April 16 by PeterBelow 2 Share this post Link to post
Anders Melander 1782 Posted April 16 16 minutes ago, PeterBelow said: The reason is quite simple - Once you think about it. Share this post Link to post
Lars Fosdal 1792 Posted April 16 On 4/13/2024 at 11:24 PM, Anders Melander said: Maybe you should think a bit more about that. Ideally until it is no longer a mystery. IMO, that was not very helpful. If you are a new user, you may need to be guided on how to do it right, not just be told that you are doing it wrong. 1 Share this post Link to post
Anders Melander 1782 Posted April 16 Sure, I could have sugar coated it better. The point was really that when the expectations turns out not to match reality then one should question the expectations first. 1 Share this post Link to post
Lars Fosdal 1792 Posted April 16 Sometimes, when entering new areas of knowledge, you might not even know what to expect. Hence, a guiding hand can go a long way. Most people appreciate those that offer help without conditions. 2 Share this post Link to post