本文整理汇总了C#中SoundInTheory.DynamicImage.Util.FastBitmap.Unlock方法的典型用法代码示例。如果您正苦于以下问题:C# FastBitmap.Unlock方法的具体用法?C# FastBitmap.Unlock怎么用?C# FastBitmap.Unlock使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SoundInTheory.DynamicImage.Util.FastBitmap
的用法示例。
在下文中一共展示了FastBitmap.Unlock方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetEffect
protected override Effect GetEffect(FastBitmap source)
{
// Get curves either from Curves collection or ACV file.
CurveCollection curves = GetCurves();
// Check that there are at least 4 curves.
if (curves.Count < 4)
throw new DynamicImageException(
"At least 4 curves (corresponding to Composite, Red, Green, Blue) must be specified.");
// Convert mathematical curve definitions into 4x256 lookup texture (Composite, Red, Green, Blue are the 4 "columns").
FastBitmap curvesLookup = new FastBitmap(4, 256);
curvesLookup.Lock();
for (int x = 0; x < 4; ++x)
{
IEnumerable<CurvePoint> points = curves[x].Points.Cast<CurvePoint>();
float[] xValues = points.Select(p => (float) p.Input).ToArray();
float[] yValues = points.Select(p => (float) p.Output).ToArray();
float[] derivatives = CubicSplineUtility.CalculateSpline(xValues, yValues);
for (int y = 0; y < 256; ++y)
curvesLookup[x, y] = Color.FromRgb((byte) CubicSplineUtility.InterpolateSpline(xValues, yValues, derivatives, y), 0, 0);
}
curvesLookup.Unlock();
return new CurvesEffect
{
CurvesLookup = new ImageBrush(curvesLookup.InnerBitmap)
};
}
示例2: CreateImage
protected override void CreateImage(ImageGenerationContext context)
{
Bitmap = new FastBitmap(Width, Height);
Bitmap.Lock();
for (int y = 0; y < Height; y++)
for (int x = 0; x < Width; x++)
{
ColorHsv colorHsv = CalculateFractalColor(x, y);
var color = (Color) colorHsv;
Bitmap[x, y] = color.ToWpfColor();
}
Bitmap.Unlock();
}
示例3: GetEffect
protected override Effect GetEffect(FastBitmap source)
{
FastBitmap transferLookup = new FastBitmap(1, 256);
transferLookup.Lock();
for (int y = 0; y < 256; ++y)
{
byte colorComponent = (byte) (255 * GetTransferFunctionValue(y / 255.0f));
transferLookup[0, y] = Color.FromRgb(colorComponent, colorComponent, colorComponent);
}
transferLookup.Unlock();
return new TransferEffect
{
TransferLookup = new ImageBrush(transferLookup.InnerBitmap)
};
}
示例4: AssertEqual
public static void AssertEqual(FastBitmap expected, FastBitmap actual)
{
Assert.AreEqual(expected.Width, actual.Width);
Assert.AreEqual(expected.Height, actual.Height);
try
{
expected.Lock();
actual.Lock();
for (int y = 0, height = expected.Height; y < height; ++y)
for (int x = 0, width = expected.Width; x < width; ++x)
Assert.AreEqual(expected[x, y], actual[x, y]);
}
finally
{
actual.Unlock();
expected.Unlock();
}
}
示例5: GetEffect
protected override Effect GetEffect(FastBitmap source)
{
Color transparentColor;
if (UseFirstPixel)
{
source.Lock();
transparentColor = source[0, 0];
source.Unlock();
}
else
{
transparentColor = Color;
}
return new ColorKeyEffect
{
ColorTolerance = ColorTolerance / 255.0,
TransparentColor = transparentColor
};
}
示例6: GetEffect
protected override Effect GetEffect(ImageGenerationContext context, FastBitmap source)
{
SWMColor transparentColor;
if (UseFirstPixel)
{
source.Lock();
transparentColor = source[0, 0];
source.Unlock();
}
else
{
transparentColor = Color.ToWpfColor();
}
return new ColorKeyEffect
{
ColorTolerance = ColorTolerance / 255.0,
TransparentColor = transparentColor
};
}
示例7: ApplyFilter
public override sealed void ApplyFilter(FastBitmap bitmap)
{
OnBeginApplyFilter(bitmap);
// get destination dimensions
int destWidth, destHeight;
bool shouldContinue = GetDestinationDimensions(bitmap, out destWidth, out destHeight);
if (!shouldContinue)
return;
FastBitmap destination = new FastBitmap(destWidth, destHeight);
// copy metadata
// TODO
/*foreach (PropertyItem propertyItem in bitmap.InnerBitmap.PropertyItems)
destination.InnerBitmap.SetPropertyItem(propertyItem);*/
int width = bitmap.Width;
int height = bitmap.Height;
OriginalSpace = new Int32Rect(0, 0, width, height);
Int32Rect transformedSpace = GetTransformedSpace(OriginalSpace);
try
{
bitmap.Lock();
destination.Lock();
if (InterpolationMode == InterpolationMode.NearestNeighbor)
FilterPixelsNearestNeighbor(bitmap, destination, width, height, transformedSpace);
else
FilterPixelsBilinear(bitmap, destination, width, height, transformedSpace);
}
finally
{
destination.Unlock();
bitmap.Unlock();
}
bitmap.InnerBitmap = destination.InnerBitmap;
}
示例8: CreateImage
//.........这里部分代码省略.........
foreach (Layer layer in this.VisibleLayers)
if (!layer.HasFixedSize)
{
layer.CalculatedWidth = outputWidth;
layer.CalculatedHeight = outputHeight;
layer.Process();
}
// If any of the layers are not present, we don't create the image
foreach (Layer layer in this.VisibleLayers)
if (layer.Bitmap == null)
return null;
// Calculate X and Y for layers which are anchored.
foreach (Layer layer in this.VisibleLayers)
{
if (layer.Bitmap != null && layer.Anchor != AnchorStyles.None)
{
// Set X.
switch (layer.Anchor)
{
case AnchorStyles.BottomCenter :
case AnchorStyles.MiddleCenter :
case AnchorStyles.TopCenter :
layer.X = (outputWidth - layer.Size.Value.Width) / 2;
break;
case AnchorStyles.BottomLeft :
case AnchorStyles.MiddleLeft :
case AnchorStyles.TopLeft :
layer.X = layer.AnchorPadding;
break;
case AnchorStyles.BottomRight:
case AnchorStyles.MiddleRight:
case AnchorStyles.TopRight:
layer.X = outputWidth - layer.Size.Value.Width - layer.AnchorPadding;
break;
}
// Set Y.
switch (layer.Anchor)
{
case AnchorStyles.BottomCenter:
case AnchorStyles.BottomLeft:
case AnchorStyles.BottomRight:
layer.Y = outputHeight - layer.Size.Value.Height - layer.AnchorPadding;
break;
case AnchorStyles.MiddleCenter:
case AnchorStyles.MiddleLeft:
case AnchorStyles.MiddleRight:
layer.Y = (outputHeight - layer.Size.Value.Height) / 2;
break;
case AnchorStyles.TopCenter:
case AnchorStyles.TopLeft:
case AnchorStyles.TopRight:
layer.Y = layer.AnchorPadding;
break;
}
}
}
// Apply fill.
DrawingVisual dv = new DrawingVisual();
DrawingContext dc = dv.RenderOpen();
// Apply fill.
Fill.Apply(dc, new Rect(0, 0, outputWidth, outputHeight));
dc.Close();
// create output bitmap and lock data
RenderTargetBitmap rtb = RenderTargetBitmapUtility.CreateRenderTargetBitmap(outputWidth, outputHeight);
rtb.Render(dv);
FastBitmap output = new FastBitmap(rtb);
// Blend layers using specified blend mode.
output = LayerBlender.BlendLayers(output, VisibleLayers);
// Apply global filters.
foreach (Filter filter in Filters)
if (filter.Enabled)
filter.ApplyFilter(output);
// If image format doesn't support transparency, make all transparent pixels totally opaque.
// Otherwise WPF wants to save them as black.
if (ImageFormat == DynamicImageFormat.Bmp || ImageFormat == DynamicImageFormat.Jpeg)
{
output.Lock();
for (int y = 0; y < output.Height; ++y)
for (int x = 0; x < output.Width; ++x)
{
Color c = output[x, y];
//if (output[x, y].A == 0 && output[x, y].R == 0 && output[x, y].G == 0 && output[x, y].B == 0)
output[x, y] = Color.FromArgb(255, c.R, c.G, c.B);
}
output.Unlock();
}
return output.InnerBitmap;
}
示例9: CreateImage
protected override void CreateImage()
{
Bitmap = new FastBitmap(Width, Height);
Bitmap.Lock();
for (int y = 0; y < Height; y++)
for (int x = 0; x < Width; x++)
{
ColorHsv colourHsv = CalculateFractalColour(x, y);
Color colour = (Color) colourHsv;
Bitmap[x, y] = colour;
}
Bitmap.Unlock();
}