本文整理汇总了C#中PaintDotNet.Surface.CopySurface方法的典型用法代码示例。如果您正苦于以下问题:C# Surface.CopySurface方法的具体用法?C# Surface.CopySurface怎么用?C# Surface.CopySurface使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PaintDotNet.Surface
的用法示例。
在下文中一共展示了Surface.CopySurface方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PlacedSurface
public PlacedSurface(Surface source, Rectangle roi)
{
where = roi.Location;
Surface window = source.CreateWindow(roi);
what = new Surface(window.Size);
what.CopySurface(window);
window.Dispose();
}
示例2: Draw
public void Draw(Surface dst)
{
if (disposed)
{
throw new ObjectDisposedException("PlacedSurface");
}
dst.CopySurface(what, where);
}
示例3: DoSave
//.........这里部分代码省略.........
Surface thumb;
Surface flattened = BorrowScratchSurface(this.GetType().Name + ".DoSave() preparing embedded thumbnail");
try
{
Document.Flatten(flattened);
if (Document.Width > maxDim || Document.Height > maxDim)
{
int width;
int height;
if (Document.Width > Document.Height)
{
width = maxDim;
height = (Document.Height * maxDim) / Document.Width;
}
else
{
height = maxDim;
width = (Document.Width * maxDim) / Document.Height;
}
int thumbWidth = Math.Max(1, width);
int thumbHeight = Math.Max(1, height);
thumb = new Surface(thumbWidth, thumbHeight);
thumb.SuperSamplingFitSurface(flattened);
}
else
{
thumb = new Surface(flattened.Size);
thumb.CopySurface(flattened);
}
}
finally
{
ReturnScratchSurface(flattened);
}
Document thumbDoc = new Document(thumb.Width, thumb.Height);
BitmapLayer thumbLayer = new BitmapLayer(thumb);
BitmapLayer backLayer = new BitmapLayer(thumb.Width, thumb.Height);
backLayer.Surface.Clear(ColorBgra.Transparent);
thumb.Dispose();
thumbDoc.Layers.Add(backLayer);
thumbDoc.Layers.Add(thumbLayer);
MemoryStream thumbPng = new MemoryStream();
PropertyBasedSaveConfigToken pngToken = PdnFileTypes.Png.CreateDefaultSaveConfigToken();
PdnFileTypes.Png.Save(thumbDoc, thumbPng, pngToken, null, null, false);
byte[] thumbBytes = thumbPng.ToArray();
string thumbString = Convert.ToBase64String(thumbBytes, Base64FormattingOptions.None);
thumbDoc.Dispose();
string thumbXml = "<thumb png=\"" + thumbString + "\" />";
Document.CustomHeaders = thumbXml;
}
}
// save!
bool success = false;
Stream stream = null;
示例4: AddToMruList
/// <summary>
/// Takes the current Document from this DocumentWorkspace instance and adds it to the MRU list.
/// </summary>
/// <param name="fileName"></param>
public void AddToMruList()
{
using (new PushNullToolMode(this))
{
string fullFileName = Path.GetFullPath(this.FilePath);
int edgeLength = AppWorkspace.MostRecentFiles.IconSize;
Surface thumb1 = RenderThumbnail(edgeLength, true, true);
// Put it inside a square bitmap
Surface thumb = new Surface(4 + edgeLength, 4 + edgeLength);
thumb.Clear(ColorBgra.Transparent);
Rectangle dstRect = new Rectangle((thumb.Width - thumb1.Width) / 2,
(thumb.Height - thumb1.Height) / 2, thumb1.Width, thumb1.Height);
thumb.CopySurface(thumb1, dstRect.Location);
using (RenderArgs ra = new RenderArgs(thumb))
{
// Draw black border
Rectangle borderRect = new Rectangle(dstRect.Left - 1, dstRect.Top - 1, dstRect.Width + 2, dstRect.Height + 2);
--borderRect.Width;
--borderRect.Height;
ra.Graphics.DrawRectangle(Pens.Black, borderRect);
Rectangle shadowRect = Rectangle.Inflate(borderRect, 1, 1);
++shadowRect.Width;
++shadowRect.Height;
Utility.DrawDropShadow1px(ra.Graphics, shadowRect);
thumb1.Dispose();
thumb1 = null;
MostRecentFile mrf = new MostRecentFile(fullFileName, Utility.FullCloneBitmap(ra.Bitmap));
if (AppWorkspace.MostRecentFiles.Contains(fullFileName))
{
AppWorkspace.MostRecentFiles.Remove(fullFileName);
}
AppWorkspace.MostRecentFiles.Add(mrf);
AppWorkspace.MostRecentFiles.SaveMruList();
}
}
}
示例5: Render
void Render(Surface dst, Surface src, Rectangle rect)
{
dst.CopySurface(processedSurface, rect.Location, rect);
}
示例6: 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);
}
示例7: Clone
/// <summary>
/// Creates a new surface with the same dimensions and pixel values as this one.
/// </summary>
/// <returns>A new surface that is a clone of the current one.</returns>
public Surface Clone()
{
if (disposed)
{
throw new ObjectDisposedException("Surface");
}
Surface ret = new Surface(this.Size);
ret.CopySurface(this);
return ret;
}
示例8: OnSetRenderInfo
protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs)
{
Amount1 = newToken.GetProperty<Int32Property>(PropertyNames.Amount1).Value;
if (selectionSurface == null)
{
selectionSurface = new Surface(srcArgs.Surface.Size);
PdnRegion selectionRegion = EnvironmentParameters.GetSelection(srcArgs.Bounds);
selectionSurface.CopySurface(srcArgs.Surface, selectionRegion);
// Increase absolute Transparency within selection to 1 to ensure clamping happens at selection edge
ColorBgra alphaTest;
foreach (Rectangle r in selectionRegion.GetRegionScansInt())
{
for (int y = r.Top; y < r.Bottom; y++)
{
if (IsCancelRequested) return;
for (int x = r.Left; x < r.Right; x++)
{
alphaTest = selectionSurface[x, y];
if (alphaTest.A == 0)
alphaTest.A = 1;
selectionSurface[x, y] = alphaTest;
}
}
}
}
Rectangle selection = EnvironmentParameters.GetSelection(srcArgs.Surface.Bounds).GetBoundsInt();
int left = Math.Max(0, selection.Left - 200);
int right = Math.Min(srcArgs.Surface.Width, selection.Right + 200);
int top = Math.Max(0, selection.Top - 200);
int bottom = Math.Min(srcArgs.Surface.Height, selection.Bottom + 200);
if (nearestPixels == null)
{
nearestPixels = new NearestPixelTransform(left, top, right - left, bottom - top);
nearestPixels.Include((x, y) => selectionSurface[x, y].A >= 1);
nearestPixels.Transform();
}
if (clampedSurface == null)
clampedSurface = new Surface(srcArgs.Surface.Size);
ColorBgra cp;
for (int y = top; y < bottom; y++)
{
if (IsCancelRequested) return;
for (int x = left; x < right; x++)
{
cp = selectionSurface[x, y];
if (cp.A > 1)
{
clampedSurface[x, y] = cp;
}
else
{
Point p = nearestPixels[x, y];
cp = selectionSurface[p];
clampedSurface[x, y] = cp;
}
}
}
base.OnSetRenderInfo(newToken, dstArgs, srcArgs);
}
示例9: Render
void Render(Surface dst, Surface src, Rectangle rect)
{
if (Amount3 != 0)
{
// Setup for calling the Gaussian Blur effect
GaussianBlurEffect blurEffect = new GaussianBlurEffect();
PropertyCollection blurProps = blurEffect.CreatePropertyCollection();
PropertyBasedEffectConfigToken BlurParameters = new PropertyBasedEffectConfigToken(blurProps);
BlurParameters.SetPropertyValue(GaussianBlurEffect.PropertyNames.Radius, Amount3);
blurEffect.SetRenderInfo(BlurParameters, new RenderArgs(dst), new RenderArgs(shadowSurface));
// Call the Gaussian Blur function
blurEffect.Render(new Rectangle[1] { rect }, 0, 1);
}
else
{
dst.CopySurface(shadowSurface, rect.Location, rect);
}
Rectangle selection = EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt();
ColorBgra sourcePixel, shadowPixel;
for (int y = rect.Top; y < rect.Bottom; y++)
{
if (IsCancelRequested) return;
for (int x = rect.Left; x < rect.Right; x++)
{
sourcePixel = src[x, y];
shadowPixel = dst[x, y];
if (x < selection.Left + Amount1 + Amount6 || x > selection.Right - Amount1 - 1 + Amount6|| y < selection.Top + Amount1 + Amount7|| y > selection.Bottom - Amount1 - 1 + Amount7)
{
// Erase the margins
shadowPixel.A = 0;
}
else
{
shadowPixel.A = Int32Util.ClampToByte(shadowPixel.A * Amount5 / 255);
}
dst[x, y] = normalOp.Apply(sourcePixel, shadowPixel);
}
}
}