本文整理汇总了C#中PaintDotNet.Surface.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# Surface.Dispose方法的具体用法?C# Surface.Dispose怎么用?C# Surface.Dispose使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PaintDotNet.Surface
的用法示例。
在下文中一共展示了Surface.Dispose方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RenderThumbnail
public override Surface RenderThumbnail(int maxEdgeLength)
{
Size thumbSize = Utility.ComputeThumbnailSize(this.Size, maxEdgeLength);
Surface thumb = new Surface(thumbSize);
thumb.SuperSamplingFitSurface(this.surface);
Surface thumb2 = new Surface(thumbSize);
thumb2.ClearWithCheckboardPattern();
UserBlendOps.NormalBlendOp nbop = new UserBlendOps.NormalBlendOp();
nbop.Apply(thumb2, thumb);
thumb.Dispose();
thumb = null;
return thumb2;
}
示例2: DrawGradient
//.........这里部分代码省略.........
int ap = Utility.Clamp((int)Math.Round(at * 255.0), 0, 255);
int rp = Utility.Clamp((int)Math.Round(rt * 255.0), 0, 255);
int gp = Utility.Clamp((int)Math.Round(gt * 255.0), 0, 255);
int bp = Utility.Clamp((int)Math.Round(bt * 255.0), 0, 255);
for (int y = 0; y < gradientSurface.Height; ++y)
{
ColorBgra src = gradientSurface[x, y];
// we are assuming that src.A = 255
int rd = ((rp * ap) + (src.R * (255 - ap))) / 255;
int gd = ((gp * ap) + (src.G * (255 - ap))) / 255;
int bd = ((bp * ap) + (src.B * (255 - ap))) / 255;
// TODO: proper alpha blending!
gradientSurface[x, y] = ColorBgra.FromBgra((byte)bd, (byte)gd, (byte)rd, 255);
}
}
g.DrawImage(ra.Bitmap, gradientRect, ra.Bounds, GraphicsUnit.Pixel);
}
else if (Orientation == Orientation.Vertical)
{
// TODO
}
else
{
throw new InvalidEnumArgumentException();
}
}
gradientSurface.Dispose();
}
else
{
using (LinearGradientBrush lgb = new LinearGradientBrush(this.ClientRectangle,
maxColor, minColor, gradientAngle, false))
{
g.FillRectangle(lgb, gradientRect);
}
}
// fill background
using (PdnRegion nonGradientRegion = new PdnRegion())
{
nonGradientRegion.MakeInfinite();
nonGradientRegion.Exclude(gradientRect);
using (SolidBrush sb = new SolidBrush(this.BackColor))
{
g.FillRegion(sb, nonGradientRegion.GetRegionReadOnly());
}
}
// draw value triangles
for (int i = 0; i < this.vals.Length; i++)
{
int pos = ValueToPosition(vals[i]);
Brush brush;
Pen pen;
if (i == highlight)
{
brush = Brushes.Blue;
示例3: RenderCompositionTo
protected void RenderCompositionTo(Surface dst, bool highQuality, bool forceUpToDate)
{
if (forceUpToDate)
{
UpdateComposition(false);
}
if (dst.Width == this.compositionSurface.Width &&
dst.Height == this.compositionSurface.Height)
{
dst.ClearWithCheckboardPattern();
new UserBlendOps.NormalBlendOp().Apply(dst, this.compositionSurface);
}
else if (highQuality)
{
Surface thumb = new Surface(dst.Size);
thumb.SuperSamplingFitSurface(this.compositionSurface);
dst.ClearWithCheckboardPattern();
new UserBlendOps.NormalBlendOp().Apply(dst, thumb);
thumb.Dispose();
}
else
{
this.surfaceBox.RenderTo(dst);
}
}
示例4: ResizeDocument
private void ResizeDocument()
{
this.pleaseStop = false;
// This is only sort of a hack: we must try and allocate enough for 2 extra layer-sized buffers
// Then we free them immediately. This is just so that if we don't have enough memory that we'll
// fail sooner rather than later.
Surface s1 = new Surface(this.newSize);
Surface s2 = new Surface(this.newSize);
try
{
foreach (Layer layer in src.Layers)
{
if (this.pleaseStop)
{
this.returnVal = false;
return;
}
if (layer is BitmapLayer)
{
Layer newLayer = ResizeLayer((BitmapLayer)layer, this.newSize.Width, this.newSize.Height, this.algorithm,
this.tilesPerLayer, new Procedure(RenderedRectHandler), ref this.pleaseStop);
if (newLayer == null)
{
this.returnVal = false;
return;
}
dst.Layers.Add(newLayer);
}
else
{
throw new InvalidOperationException("Resize does not support Layers that are not BitmapLayers");
}
}
}
finally
{
s1.Dispose();
s2.Dispose();
}
this.returnVal = true;
}
示例5: ResizeLayer
private static BitmapLayer ResizeLayer(BitmapLayer layer, int width, int height, ResamplingAlgorithm algorithm,
int tileCount, Procedure progressCallback, ref bool pleaseStopMonitor)
{
Surface surface = new Surface(width, height);
surface.Clear(ColorBgra.FromBgra(255, 255, 255, 0));
PaintDotNet.Threading.ThreadPool threadPool = new PaintDotNet.Threading.ThreadPool();
int rectCount;
if (tileCount == 0)
{
rectCount = Processor.LogicalCpuCount;
}
else
{
rectCount = tileCount;
}
Rectangle[] rects = new Rectangle[rectCount];
Utility.SplitRectangle(surface.Bounds, rects);
FitSurfaceContext fsc = new FitSurfaceContext(surface, layer.Surface, rects, algorithm);
if (progressCallback != null)
{
fsc.RenderedRect += progressCallback;
}
WaitCallback callback = new WaitCallback(fsc.FitSurface);
for (int i = 0; i < rects.Length; ++i)
{
if (pleaseStopMonitor)
{
break;
}
else
{
threadPool.QueueUserWorkItem(callback, BoxedConstants.GetInt32(i));
}
}
threadPool.Drain();
threadPool.DrainExceptions();
if (pleaseStopMonitor)
{
surface.Dispose();
surface = null;
}
BitmapLayer newLayer;
if (surface == null)
{
newLayer = null;
}
else
{
newLayer = new BitmapLayer(surface, true);
newLayer.LoadProperties(layer.SaveProperties());
}
if (progressCallback != null)
{
fsc.RenderedRect -= progressCallback;
}
return newLayer;
}
示例6: OnPreRenderComplete
protected virtual void OnPreRenderComplete(RenderArgs dstArgs, RenderArgs srcArgs)
{
Rectangle[] rois;
Surface surfaceCopy;
RenderArgs args;
RenderArgs currentSourceArgs;
RenderArgs currentDestinationArgs;
Rectangle boundingTile;
if (FullImageSelected(srcArgs.Bounds))
{
boundingTile = dstArgs.Bounds;
}
else
{
boundingTile = this.EnvironmentParameters.GetSelection(dstArgs.Bounds).GetBoundsInt();
boundingTile.Inflate(base.ApronSize, base.ApronSize);
boundingTile.Intersect(dstArgs.Bounds);
}
rois = base.SliceRectangles(new Rectangle[] { boundingTile });
surfaceCopy = new Surface(dstArgs.Width, dstArgs.Height, SurfaceCreationFlags.DoNotZeroFillHint); //dstArgs.Surface.Clone();
args = new RenderArgs(surfaceCopy);
currentSourceArgs = srcArgs;
currentDestinationArgs = args;
this.pass = 1;
OnBeginPass(this.pass, currentDestinationArgs, currentSourceArgs);
OnRenderRegion(rois, currentDestinationArgs, currentSourceArgs);
if (Passes == 1)
{
CopyRois(this.EnvironmentParameters.GetSelection(dstArgs.Bounds).GetRegionScansInt(),
dstArgs.Surface,
surfaceCopy);
surfaceCopy.Dispose();
}
else
{
if (base.tmr != null)
{
base.tmr = new System.Diagnostics.Stopwatch();
base.tmr.Start();
}
this.pass = 2;
if (FullImageSelected(srcArgs.Bounds))
{
currentSourceArgs = args;
currentDestinationArgs = dstArgs;
OnBeginPass(this.pass, currentDestinationArgs, currentSourceArgs);
OnRenderRegion(rois, currentDestinationArgs, currentSourceArgs);
surfaceCopy.Dispose();
}
else
{
Surface surfaceCopy2;
RenderArgs args2;
surfaceCopy2 = new Surface(dstArgs.Width, dstArgs.Height, SurfaceCreationFlags.DoNotZeroFillHint);
args2 = new RenderArgs(surfaceCopy2);
currentSourceArgs = args;
currentDestinationArgs = args2;
OnBeginPass(this.pass, currentDestinationArgs, currentSourceArgs);
OnRenderRegion(rois, currentDestinationArgs, currentSourceArgs);
surfaceCopy.Dispose();
CopyRois(this.EnvironmentParameters.GetSelection(dstArgs.Bounds).GetRegionScansInt(),
dstArgs.Surface,
surfaceCopy2);
surfaceCopy2.Dispose();
}
}
}