- This topic has 15 replies, 4 voices, and was last updated 11 years, 11 months ago by SzakiLaci.
-
AuthorPosts
-
May 20, 2011 at 10:22 am #34564bdegliParticipant
Is it possible to resize Images (PNG) on the fly?
e.g. I have Buttons with large Images to start tasks in new dynamic Tabsheets
I have to maintain two ImageLists for the button 32×32 or 64×64 – and for the PageControl 16×16 or 24×24 (bigger consumes too much space)
When the user clicks the button, I add the buttons.image to the imageList of the tabSheet …
newImageIndex:=imgPC.AddImage(btnDBModel.Images,btnDBModel.ImageIndex);
addFrame(nil,'SQL Model','TframeModel',newButton);
it works – but the image get croped – any way to resize it?
Thanx
BD
June 5, 2011 at 2:31 pm #45907SupportKeymasterHello
TsAlphaImageList component can change Width and Height properties on the fly, maybe this feature can help you?
June 6, 2011 at 7:11 am #45912bdegliParticipantI tried to use it
Could you please give an example how to copy an image from a 32×32-imagelist to a 16×16 imagelist?
June 9, 2011 at 6:19 am #45929SupportKeymasterWhy you want to copy it? You can just change Width and Height properties in the AlphaImageList component…
June 14, 2011 at 1:19 pm #45989bdegliParticipantMy project is rather big more than 100 icons …
To have 3 different image_list in 16×16 24×24 32×32 or even a view in 128×128 …
costs a lot of memory and the management is quite diffucult to synchronize them
button List16 image index 56 equals to List32 index 56 …
If I have only one Image-List and size them at runtime … all icons change and not only a specific …
If I create a new TabSheet from a Menu Button – I just want to copy the image from the button-Image-Source to the
PageControl-Image Source and by the way adjust the size … A lot of my Forms are dynamically created at runtime…
June 14, 2011 at 1:22 pm #45990bdegliParticipantMy project is rather big more than 100 icons …
To have 3 different image_list in 16×16 24×24 32×32 or even a view in 128×128 …
costs a lot of memory and the management is quite diffucult to synchronize them
button List16 image index 56 equals to List32 index 56 …
If I have only one Image-List and size them at runtime … all icons change and not only a specific …
If I create a new TabSheet from a Menu Button – I just want to copy the image from the button-Image-Source to the
PageControl-Image Source and by the way adjust the size … A lot of my Forms are dynamically created at runtime…
[attachment=4907:menu_Scrn1.jpg]
June 14, 2011 at 2:42 pm #45992SupportKeymasterI think I understand a problem now.
I'll plan to make a new component later. This component will take icons from AlphaImageList and change size to any other on the fly.
This component will be inherited from standard ImageList and may be used as ImageList.
November 8, 2012 at 1:59 pm #49317SzakiLaciParticipant'Support' wrote:I think I understand a problem now.
I'll plan to make a new component later. This component will take icons from AlphaImageList and change size to any other on the fly.
This component will be inherited from standard ImageList and may be used as ImageList.
Hi,
I have the same problem, since I've started to use nice, big, scalable (non resized) icons with TsAlphaImageList.
I was thinking a lot about a solution, and realized, the easiest way would be to use a “Virtual Imagelist”
Solution 1.:
making a new component called TsVirtualImageList, having no images itself, but pointing to an other TsAlphaImageList.
Solution 2.:
altering the current TsAlphaImageList component by adding a:
property UseVirtually: TsAlphaImageList;
The first case is quicker, the 2th case is more elegant, but following things had to be done:
– by selecting UseVirtually >> checking if TsAlphaImageList is already using UseVirtually property ( nil) to prevent circular reference.
– rewriting procedures (maybe not all, just the Create and Destroy)
– checking if the original TsAlphaImageList is still Assigned() before making any changes trying to read from it.
Solution 3.:
Rewriting all components (like TsBitButton, …) to set unique picture drawing size and property (like: Origin=orUpperCenter; Width=16; Height=24, AutoScaled=False, Proportional=False …)
November 9, 2012 at 8:32 am #49322HamiltonParticipantHi,
If you're not concerned about image quality then this seems like something that could be implemented fairly easily. However, if the image quality is important then this concept is a *lot* of work. I use the Graphics32 libraries (http://graphics32.org) for this purpose myself because the VCL image resizing routines are *TERRIBLE*. Put it this way: if you have an image 128 pixels wide to fit into a 32 pixel wide image then Delphi routines remove every 4th pixel from the original… sometimes it works just fine other times you end up with garbage. I don't know if you could, or would want to, hook in an advanced library like that to do the resizing but if you don't you might not get a result you'd want to use.
Some graphics programs allow command line parsing for functions such as resizing images and IMO you're probably better off looking into that, or manually resizing your images in a graphics program (not Paint) and then saving them in a new list the correct size. HDD's and RAM are cheap and there isn't much benefit worrying about things like that when the OS you're building your app on doesn't.
This is all just my opinion though, who knows Serge might have some tricks for this up his sleeve, or maybe icon style images are small enough that the quality doesn't matter.
Regards,
Hamilton
EDIT: This post clicked me over from being “Advanced” to “The Aged”. I don't know if it was worth it!
November 9, 2012 at 1:31 pm #49327SupportKeymasterHello!
TsVirtualImageList will be created soon. I think, this component will work good. 🙂
November 28, 2012 at 4:00 pm #49475SzakiLaciParticipantAny progress? 😉
Thanks !
November 28, 2012 at 4:10 pm #49476SupportKeymasterYes, but component is not ready still because publishing of stable version had a highest priority.
This new component will be added in the next release, I think 🙂
December 17, 2012 at 8:24 pm #49654SzakiLaciParticipantVersion 8.12 is out, (since 2012. dec. 14.) and since 8.11 (2012. dec. 12) there's a new component: TsVirtualImageList
COOL ! 🙂 .. I was very happy about it. (first)
Today I've finished implementing the new package to my program and figured out the following:
Seems to Re-Create every each picture >>
– consuming huge amount of memory
– making Delphi7 running at 100% process time for half minute after clicking SAVE each time
– does not FREE the pictures at program ending >> making to drop Access Violation at the end.
To Test it:
ADD 50 pictures to a TsAlphImageList (ca. 100Kb each), than Drop a TsVirtualImageList to the Form too, and SET width=256, Height=256.
So this way it isn't going to work properly 🙁 because the basic idea was to Re-introducing a FEW pictures here and there from ONE BIG package in different sizes, without need of extra memory and space.
My question/recommendation would be :
– Isn't it possible to convert those pictures on the fly? I mean it would only show VIRTUALLY as if there would be any real picture, but not holding every each of them in memory pre-converted?
___________
Anyway every other component fixes in the last 4 month seems to be PERFECT ! Great Job, Thank you and Marry Christmas !!! 🙂
December 17, 2012 at 8:30 pm #49655SzakiLaciParticipant… if that's not possible, is it maybe a solution to create and convert only THOSE really needed and accessed? (And free after nothing is pointed to it…)
December 19, 2012 at 5:25 pm #49664SupportKeymasterI have changed this component today, added the UseCache property there.
Caching is not using and pictures are received directly from base ImageList if UseCache is False.
Here you can find a demo : http://www.alphaskins.com/sfiles/demos/virtualimagelist.zip
These changes will be available very soon with nearest release.
December 19, 2012 at 6:42 pm #49665SzakiLaciParticipantMan, seriously … you are my “PROGRAMMER OF THE YEAR” ! :a7:
You have done it again.
The example to test the difference between cached and non-cashed appearance is PERFECT. (And also looks cool…)
You've made my Christmas gift.
_______________
You forced me to “revenge” it by sending you a tiny Christmas donation… see my Private message 😉
-
AuthorPosts
- You must be logged in to reply to this topic.