Forum > Graphics

[SOLVED] SVG thumbnails

<< < (2/4) > >>

Pe3s:
Thank you :)

Pe3s:
I would like to ask for help. I have never drawn anything in TListView, how can I draw thumbnails in ListView


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---uses BGRABitmap, BGRAThumbnail;bgra := GetFileThumbnail('file.svg', 200, 200, BGRAWhite, true);

circular:
This is not obvious to do. However, this can be done in a few steps.

TListView will display icons that are stored in its LargeImages and SmallImages property. The two lists are used for different values of ViewStyle. If you're going to use big icons, then you just need LargeImages.

So add an ImageList to your form. Set its Width and Height to the size of the thumbnails. Using the object inspector of the ListView, select the ImageList in the LargeImages property. Set the ViewStyle to vsIcon.

To add an element to the ListView, there are two steps:
- after you load the thumbnail, add it using to the ImageList using the Add function. You can specify nil for the Mask parameter. The function will return an index for the image.
- add an item to the ListView, for example with Items.Add. Assign the image via the ImageIndex property of the item.

If you have any more question, feel free to ask for specific points.

Regards

Pe3s:
Is it possible to do this with ListBox and OwnerDraw without using ImageList?

domasz:
You can use this with ListBox.
You can use it without ImageList but it needs to store the thumbnails somewhere. It can be an array of TBitmap or array of TMemoryStream or an array of array of Byte and so on. You can't generate thumbnails on the fly and display them because for every redrew it would need to again load an SVG file, generate thumbnail and show it- and that would just take too much time.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version