ScaleTransform

  • Thread starter Thread starter Ian Lazarus
  • Start date Start date
I

Ian Lazarus

Hello,
I expected the code below to display the picture in half its normal size.
Instead, it displays it in the original size. What is the correct way to do
this?
Thanks

Form()
{
pictureBox->set_Image(new Bitmap(new String("c:\\picture.bmp")));
}

// pictureBox OnPaint event
private: System::Void OnPaintPicture(System::Object * sender,
System::Windows::Forms::PaintEventArgs * e)
{
Graphics *pgraphics = e->get_Graphics();
pgraphics->ScaleTransform(0.5, 0.5);
}
 
Don't Use a Picture Box!
It's just mean to display a picture and certainly don't play well with those
who try to trick it.

what about
=== Caution: pseudo-code from the back of my head ====
class MyPicBox : Control
{
public MyPicBox ()
{
SetStyle(Style.OptimizedDoubleBuffer, true);
BackColor = SystemColor.Control;
}
Image image;
public Image Image
{
get { return image; }
set
{
if(image == value)
return;
image = value;
Invalidate();
}
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
if(image != null)
{
e.Graphics.ScaleTransform(0.5f, 0.5f);
e.Graphics.DrawImage(image, 0, 0);
}
}
}

--
Regards,
Lloyd Dupont

NovaMind development team
NovaMind Software
Mind Mapping Software
<www.nova-mind.com>
 
Back
Top