Zooming images

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

currently I am programming a control to zoom in/out images and move them
inside a frame, but when I zoom it keeps the upper left corner static making
the image growing to the lower-rigth direction... I would like to make the
the image fixed on the center of the frame expanding it to all the sides from
that point....

Guess that ou can figure out what I want (forgive my bad english)

I would like so code or tutorial if possible

Thanks in advance
 
once you have resized your image, you will have to reset it's origin, for
example

private Bitmap m_Image;
private bool m_RedrawImage = false;
private int m_Top = 0;
private int m_Left = 0;

private void SetImageSizeDifference(int origWidth, int origHeight, bool zoom)
{
m_Left -= (m_Image.Width - origWidth);
m_Top -= (m_Image.Height - origHeight);
m_RedrawImage = true;
Refresh();
}

override public void OnPaint(object sender, PaintEventArgs e)
{
if(m_RedrawImage)
{
Graphics g = this.CreateGraphics();
g.DrawImage(m_Image, m_Left, m_Top);
m_RedrawImage = false;
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top