I have a Rectangle which is defined as (0,40,475,244) into which I want to draw a 128x128 Image. I am calling DrawImage as follows:
The resulting Image ends up drawing in the wrong place.
Should have been more like this:
I know it must be something obvious, but I can't see what's wrong with the calculation of the Image location...
C#:
Point pImage = new Point();
pImage.X = (rPanel.Right - rPanel.Left) / 2 - this.BackgroundImage.Size.Width / 2;
pImage.Y = (rPanel.Bottom - rPanel.Top) / 2 - this.BackgroundImage.Size.Height / 2;
g.DrawImage(this.BackgroundImage, pImage.X, pImage.Y);
The resulting Image ends up drawing in the wrong place.
Should have been more like this:
I know it must be something obvious, but I can't see what's wrong with the calculation of the Image location...