移动图像的原点以将其带回 C# 中的中心

move the origin of an image to bring it back to the center in c#

我正在开发 Windows 表单应用程序,我已将图像加载到 pictureBox 中。我想知道是否可以移动图像的原点并将其带回中心。

我有这个:image1 我想要这个:image2 谢谢

您可以捕捉图像的一个区域并显示它。这可能如下所示:

var nX = bmpOriginalImage.Width / 2;
var nY = bmpOriginalImage.Height / 2;
var nWidth = bmpOriginalImage.Width - nX;
var nHeight = bmpOriginalImage.Height - nY;

var rect = new Rectangle(nX, nY, nWidth, nHeight);

var bmpSnapImage = bmpOriginalImage.Clone(rect, bmpOriginalImage.PixelFormat);

m_pbxPictureBox.Image = bmpSnapImage;