CardMaker.Card.DrawItem.DrawGraphicOriginalSize C# (CSharp) Метод

DrawGraphicOriginalSize() приватный статический Метод

Draws the image cropped based on alignment. The image is always drawn in proper aspect by this method
private static DrawGraphicOriginalSize ( Graphics zGraphics, Bitmap zBmp, ProjectLayoutElement zElement ) : void
zGraphics System.Drawing.Graphics
zBmp System.Drawing.Bitmap
zElement CardMaker.XML.ProjectLayoutElement
Результат void
        private static void DrawGraphicOriginalSize(Graphics zGraphics, Bitmap zBmp, ProjectLayoutElement zElement)
        {
            int nSourceX = 0;
            int nSourceY = 0;

            int nX = 0;
            int nY = 0;

            // determine if the update is needed for drawing source X or target X
            if (zBmp.Width > zElement.width)
            {
                UpdateAlignmentValue(zElement.GetHorizontalAlignment(), ref nSourceX, zBmp.Width, zElement.width);
            }
            else
            {
                UpdateAlignmentValue(zElement.GetHorizontalAlignment(), ref nX, zElement.width, zBmp.Width);
            }
            // determine if the update is needed for drawing source Y or target Y
            if (zBmp.Height > zElement.height)
            {
                UpdateAlignmentValue(zElement.GetVerticalAlignment(), ref nSourceY, zBmp.Height, zElement.height);
            }
            else
            {
                UpdateAlignmentValue(zElement.GetVerticalAlignment(), ref nY, zElement.height, zBmp.Height);
            }
            zGraphics.DrawImage(zBmp, nX, nY, new Rectangle(nSourceX, nSourceY, zElement.width, zElement.height), GraphicsUnit.Pixel);
        }