SharpDX RenderTarget2D DrawBitmap缩放到中心

时间:2019-01-04 10:51:32

标签: image zoom sharpdx

我使用SharpDX在图像查看器中显示位图,并且具有ZoomFactor。 我要在缩放时放大到图像的中心,但标准是缩放到SharpDX的左上角。缩放可以通过“变换”来完成:

RenderTarget2D.Transform = Matrix3x2.Transformation(zoomFactor, zoomFactor, 0, xCenter * 0.5f * (1 - zoomFactor), yCenter * 0.5f * (1 - zoomFactor));

或通过sourceRectangle和destinationRectangle。

RenderTarget2D.DrawBitmap(_bitmap, destinationRectangle, 1.0f, BitmapInterpolationMode.NearestNeighbor, sourceRectangle);

如何放大图像的中心?

我知道这些

float ZoomFactor; //between 1/32 and 32
float imageWidth=bitmapToDisplay.Width;
float imageHeight=bitmapToDisplay.Height;
float sceneWidth=RenderTarget2D.Size.Width;
float sceneHeight=RenderTarget2D.Size.Height;

Zooming towards center explanation as image

0 个答案:

没有答案