AdzT1
AdzT1

Reputation: 61

Displaying size of pictures

I want to display the size of a picture, like the canvas size and then display it in the label. I'm not really sure how to do it, can someone help me please? This is all I've got:/

CanvasSize.Text = PictureBox1.Image.Size;

Upvotes: 2

Views: 87

Answers (1)

John H
John H

Reputation: 14640

CanvasSize.Text = PictureBox1.Image.Size.ToString();

If you check the intellisense for the Size.ToString() method it says:

Creates a human-readable string that represents this System.Drawing.Size structure.

The output is of the form:

{Width=x, Height=y}

If you want to change the way the output is displayed, you can use something like this:

CanvasSize.Text = String.Format("{0}px * {1}px",
    PictureBox1.Image.Size.Width, PictureBox1.Image.Height);

Upvotes: 5

Related Questions