# Zoom In-Out

**URL:** <https://forum.juce.com/t/zoom-in-out/458>\
**Category:** General JUCE discussion\
**Created:** [October 25, 2005, 4:33pm UTC](https://forum.juce.com/t/zoom-in-out/458 "2005-10-25T16:33:04Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shanks](https://avatars.discourse-cdn.com/v4/letter/s/a9adbd/32.png) [@Shanks](https://forum.juce.com/u/Shanks)\
**Post date:** [October 25, 2005, 4:33pm UTC](https://forum.juce.com/t/zoom-in-out/458/1 "2005-10-25T16:33:04Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jtxx000](https://avatars.discourse-cdn.com/v4/letter/j/b5a626/32.png) [@jtxx000](https://forum.juce.com/u/jtxx000)\
**Post date:** [October 26, 2005, 12:52am UTC](https://forum.juce.com/t/zoom-in-out/458/2 "2005-10-26T00:52:33Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [October 26, 2005, 10:08am UTC](https://forum.juce.com/t/zoom-in-out/458/3 "2005-10-26T10:08:38Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Shanks](https://avatars.discourse-cdn.com/v4/letter/s/a9adbd/32.png) [@Shanks](https://forum.juce.com/u/Shanks)\
**Post date:** [November 8, 2005, 9:20am UTC](https://forum.juce.com/t/zoom-in-out/458/4 "2005-11-08T09:20:27Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [November 8, 2005, 9:47am UTC](https://forum.juce.com/t/zoom-in-out/458/5 "2005-11-08T09:47:17Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [May 12, 2017, 9:51am UTC](https://forum.juce.com/t/zoom-in-out/458/6 "2017-05-12T09:51:47Z")

</div>


