Image scaling on window resizing

7 posts / 0 new
Last post
walkero
walkero's picture
Offline
Last seen: 1 month 1 day ago
Joined: 2009-05-03 16:54
Image scaling on window resizing
Hello guys, I need your opinion on something I develop. I have a window where an image is shown. The image should keep it's aspect ratio and scale when the window is resized. There will also be a "Full width" mode, where the image will have 100% width and the height will respectively change, always respecting the aspect ratio. In full width mode, the window will use it's scrollbars to scroll the image. I used a bitmap.image object in a layout, which loads and show the image, but this had a problem. When the user tried to resize the window to a smaller size, it didn't let it become smaller. So yesterday thought to change it with a button, showing the image with a bitmap.image, because the button can be resizable, according the window. But a few problems occurred. If I have the IA_Scalable, TRUE, the image is stretched to the whole width and height of the button. With IA_Scalable, FALSE the image is show just fine, but when I resize the window to smaller size of the images, the image is drawn above the window borders, because it doesn't actually resize itself, but keeps its original dimensions. Also tried to catch the event of window resizing by the "WMHI_NEWSIZE", but unfortunately this doesn't work. I use a printf with a message, to see when this event is executed, but no message comes up. Is there a simple example code on how to do this? So, I would like to ask you guys if the button solution is good for what I want to do. If not, what should I use? A backfill would be better? What do you propose about the scaling? One more solution I thought is to use spacers, left and right of the button, and resize them while the user resizes the window. This would help to keep the button in specific WeightedWidth and calculate it's height, and also calculate, depending the image and the layout size, the width of the spacers. But to implement this it is necessary to get a window resize event while the user resizes it. Any ideas would be more than helpful.
walkero
walkero's picture
Offline
Last seen: 1 month 1 day ago
Joined: 2009-05-03 16:54
Re: Image scaling on window resizing
Also tried to catch the event of window resizing by the "WMHI_NEWSIZE", but unfortunately this doesn't work. I use a printf with a message, to see when this event is executed, but no message comes up. Is there a simple example code on how to do this?
This is solved as soon as I added to the window WA_IDCMP the IDCMP_NEWSIZE. So now I can proceed with this solution. But I still would love to read your proposals on this matter.
jabirulo
jabirulo's picture
Offline
Last seen: 1 day 3 hours ago
Joined: 2013-05-30 00:53
Re: Image scaling on window resizing
Thomas Rapp created an example (http://thomas-rapp.homepage.t-online.de/examples/scaleimg.lha) I think is somewhere in this forum, can't find it right now. You can see/compare how he does the scaling inside a button.
AOS4.1/SAM460ex/PPC460EX-1155MHZ/2048MB/RadeonHD6570/SSD120GB/DVDRW :-P
walkero
walkero's picture
Offline
Last seen: 1 month 1 day ago
Joined: 2009-05-03 16:54
Re: Image scaling on window resizing
Thank you for your reply. I found it last night at http://os4coding.net/forum/retaining-image-aspect-ratio . Thomas example codes are totally treasures. I am working on these examples now and try to make them work in my project... I tried scale as well as the scalespace, where I found the scalespace being faster on window resizing. Although I managed to make it work, there are a few problems when I change the image dynamically. For example, the new image size is not updated and it takes the size of the first loaded image.
walkero
walkero's picture
Offline
Last seen: 1 month 1 day ago
Joined: 2009-05-03 16:54
Re: Image scaling on window resizing
Managed to find the solution on the problem I had. Now the images are changing by the user dynamicaly just fine. What I have to do now is a "full width" mode where the image must have the full available width and if the height is bigger than the available of the window, it should have a scrollbat for the user to use it. I don't have a clue on how I will do this, but I am going to try it. Here it is a teaser image of the app I am developing... IMAGE(http://amiga.gr/comicami_1.jpg)
broadblues
broadblues's picture
Offline
Last seen: 2 years 3 months ago
Joined: 2012-05-02 21:48
Re: Image scaling on window resizing
Looks cool. I don't think you will be able to use bitmap.image for your full width view mode. Your are going to have to get inot some custom rendering there. Although thinking about it again you *might* be able to use a virtual gadget to hold the full width bitmap image... Looking at the layout it reminds me of a certain datatypes viewer program, you *could* actually write your application in python or ARexx and use MultiViewer to handle the display part for you :-)
walkero
walkero's picture
Offline
Last seen: 1 month 1 day ago
Joined: 2009-05-03 16:54
Re: Image scaling on window resizing
@broadblues Thank you for your comments.
Looking at the layout it reminds me of a certain datatypes viewer program, you *could* actually write your application in python or ARexx and use MultiViewer to handle the display part for you
Actually, Comicami will be much more than what it is right now. My todo list is biiiig :D But if it was just a basic viewer, as it is now, then what you propose could do the job. :D I will try the virtual gadget and try to implement this feature to the program, before the first beta release.
Log in or register to post comments