I was wondering, if there is a way of scaling the entire component graphics just for display purposes. I am writing an imaging application which needs to allow the user to zoom in or zoom out on the component without actually having to resize it. The problem is if I resize, all mouse points on the original image is gone and it creates a problems when communicating between other windows (which need the information of the mouse click and rotation and actual scaling that might have been done on the image etc.) can you suggest how I could implement the same? thanks
I don’t know of any direct way of doing this, but you could always just put all the graphics stuff in one component and then use that inside the main component. The main component would pick up all the mouse events and such and act as a clipping rectangle for the child component, and the child could be resized as needed without problems.
Can’t you just use a component’s createComponentSnapshot() method to generate an image and then rescale that when you draw it to the screen?
thanks for that Jules… that’s exactly what I did, but I basically added a small change with createComponentSnapshot() where instead of creating a Image everytime (which seemed hell a lot costly in speed) I made a copySnapshot call and passed in the image which I kept reusing.
Can you add this to your long list of tasks to have “Image*” passed in and copied or scaled which could help some people like me to manage memories… thanks…
I’m sorry for a late reply as I had been on vacation last week…
In fact creating an image is a very quick operation - it only involves doing a malloc, so won’t take more than a few microseconds. The slow bits are clearing it before painting onto it, and actually doing the drawing.