本文整理匯總了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);
}