本文整理汇总了C#中Xwt.Clip方法的典型用法代码示例。如果您正苦于以下问题:C# Xwt.Clip方法的具体用法?C# Xwt.Clip怎么用?C# Xwt.Clip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Xwt
的用法示例。
在下文中一共展示了Xwt.Clip方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawImageSized
private void DrawImageSized(PageImage pi, Xwt.Drawing.Image im, Xwt.Drawing.Context g, Xwt.Rectangle r)
{
double height, width; // some work variables
StyleInfo si = pi.SI;
Xwt.Rectangle r2 = new Xwt.Rectangle(r.X + PixelsX(si.PaddingLeft),
r.Y + PixelsY(si.PaddingTop),
r.Width - PixelsX(si.PaddingLeft + si.PaddingRight),
r.Height - PixelsY(si.PaddingTop + si.PaddingBottom));
Xwt.Rectangle ir; // int work rectangle
switch (pi.Sizing)
{
case ImageSizingEnum.AutoSize:
float imwidth = PixelsX( (float)im.Size.Width);
float imheight = PixelsX( (float)im.Size.Height);
ir = new Xwt.Rectangle(Convert.ToInt32(r2.X), Convert.ToInt32(r2.Y),
imwidth, imheight);
im.Scale((int)r2.Width, (int)r2.Height);
g.DrawImage(im, ir);
break;
case ImageSizingEnum.Clip:
g.Save();
g.Rectangle(r2);
g.Clip();
ir = new Xwt.Rectangle(Convert.ToInt32(r2.X), Convert.ToInt32(r2.Y),
im.Size.Width, im.Size.Height);
g.DrawImage(im, ir);
g.Restore();
break;
case ImageSizingEnum.FitProportional:
double ratioIm = (float)im.Size.Height / (float)im.Size.Width;
double ratioR = r2.Height / r2.Width;
height = r2.Height;
width = r2.Width;
if (ratioIm > ratioR)
{
// this means the rectangle width must be corrected
width = height * (1 / ratioIm);
}
else if (ratioIm < ratioR)
{
// this means the ractangle height must be corrected
height = width * ratioIm;
}
r2 = new Xwt.Rectangle(r2.X, r2.Y, width, height);
g.DrawImage(im, r2);
break;
case ImageSizingEnum.Fit:
default:
g.DrawImage(im, r2);
break;
}
}