本文整理汇总了C#中PaintDotNet.Surface.FitSurface方法的典型用法代码示例。如果您正苦于以下问题:C# Surface.FitSurface方法的具体用法?C# Surface.FitSurface怎么用?C# Surface.FitSurface使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PaintDotNet.Surface
的用法示例。
在下文中一共展示了Surface.FitSurface方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: resize
private static BitmapEx resize(Bitmap bitmap, int width, int height, Rectangle? clipRectangle)
{
using (var src = Surface.CopyFromBitmap(bitmap))
{
var dest = new Surface(width, height);
BitmapEx res = new BitmapEx();
res.surface = dest;
dest.FitSurface(ResamplingAlgorithm.SuperSampling, src);
if (clipRectangle == null)
res.Bitmap = dest.CreateAliasedBitmap();
else
res.Bitmap = dest.CreateAliasedBitmap(clipRectangle.Value);
return res;
}
}
示例2: OnSetRenderInfo
protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs)
{
Rectangle selection = EnvironmentParameters.GetSelection(srcArgs.Surface.Bounds).GetBoundsInt();
Surface selectionSurface = new Surface(selection.Width, selection.Height);
selectionSurface.CopySurface(srcArgs.Surface, selection);
Surface stretchedSurface = new Surface(selection.Width * 2, selection.Height);
stretchedSurface.FitSurface(ResamplingAlgorithm.Bicubic, selectionSurface);
processedSurface = new Surface(srcArgs.Surface.Size);
ColorBgra t;
for (int y = 0; y < stretchedSurface.Height; y++)
{
if (IsCancelRequested) return;
int v = selection.Left;
for (int x = 0; x < stretchedSurface.Width; x += 2)
{
if (x % 2 == 0)
{
t.R = stretchedSurface[x, y].R;
t.G = stretchedSurface[x + 1, y].G;
if (x != stretchedSurface.Width - 2)
{
t.B = stretchedSurface[x + 2, y].B;
}
else
{
t.B = (byte)((stretchedSurface[stretchedSurface.Width - 1, y].B + stretchedSurface[stretchedSurface.Width - 2, y].B) >> 1);
}
processedSurface[v, y + selection.Top] = ColorBgra.FromBgr(t.B, t.G, t.R);
v++;
}
}
}
base.OnSetRenderInfo(newToken, dstArgs, srcArgs);
}