本文整理汇总了C#中System.Windows.Media.Imaging.BitmapSource.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# BitmapSource.Clone方法的具体用法?C# BitmapSource.Clone怎么用?C# BitmapSource.Clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Media.Imaging.BitmapSource
的用法示例。
在下文中一共展示了BitmapSource.Clone方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExecuteFilter
public override BitmapSource ExecuteFilter(BitmapSource inputImage)
{
locked = true;
BitmapSource blurred = inputImage.Clone();
int pixelCount = inputImage.PixelWidth * inputImage.PixelHeight;
int[] b = new int[pixelCount];
int[] g = new int[pixelCount];
int[] r = new int[pixelCount];
int[] b2 = new int[pixelCount];
int[] g2 = new int[pixelCount];
int[] r2 = new int[pixelCount];
int width = inputImage.PixelWidth;
int height = inputImage.PixelHeight;
byte[] srcPixels = new byte[width * height * 4];
byte[] destPixels = new byte[width * height * 4];
inputImage.CopyPixels(srcPixels, width * 4, 0);
blurred.CopyPixels(destPixels, width * 4, 0);
for (int i = 0, j = 0; i < pixelCount * 4; i += 4, j++)
{
b[j] = srcPixels[i];
g[j] = srcPixels[i + 1];
r[j] = srcPixels[i + 2];
}
int index = 0;
int bsum;
int gsum;
int rsum;
int sum;
int read;
int start = 0;
index = 0;
for (int i = 0; i < height; i++)
{
for (int j = 0; j < width; j++)
{
bsum = gsum = rsum = sum = 0;
read = index - _radius;
for (int z = 0; z < _kernel.Length; z++)
{
if (read >= start && read < start + width)
{
bsum += _multable[z, b[read]];
gsum += _multable[z, g[read]];
rsum += _multable[z, r[read]];
sum += _kernel[z];
}
++read;
}
b2[index] = (bsum / sum);
g2[index] = (gsum / sum);
r2[index] = (rsum / sum);
++index;
}
start += width;
}
int tempy;
int pixelIndex = 0;
for (int i = 0; i < height; i++)
{
int y = i - _radius;
start = y * width;
for (int j = 0; j < width; j++)
{
bsum = gsum = rsum = sum = 0;
read = start + j;
tempy = y;
for (int z = 0; z < _kernel.Length; z++)
{
if (tempy >= 0 && tempy < height)
{
bsum += _multable[z, b2[read]];
gsum += _multable[z, g2[read]];
rsum += _multable[z, r2[read]];
sum += _kernel[z];
}
read += width;
++tempy;
}
destPixels[pixelIndex] = (byte)(bsum / sum);
destPixels[pixelIndex + 1] = (byte)(gsum / sum);
destPixels[pixelIndex + 2] = (byte)(rsum / sum);
pixelIndex += 4;
}
}
blurred = BitmapSource.Create(blurred.PixelWidth, blurred.PixelHeight, 96, 96,
//.........这里部分代码省略.........
示例2: MetaOrientation
private static BitmapSource MetaOrientation(BitmapMetadata meta, BitmapSource ret)
{
double angle = 0;
if ((meta != null) && (ret != null)) //si on a des meta, tentative de récupération de l'orientation
{
if (meta.GetQuery("/app1/ifd/{ushort=274}") != null)
{
orientation =
(ExifOrientations)
Enum.Parse(typeof (ExifOrientations), meta.GetQuery("/app1/ifd/{ushort=274}").ToString());
}
switch (orientation)
{
case ExifOrientations.Rotate90:
angle = -90;
break;
case ExifOrientations.Rotate180:
angle = 180;
break;
case ExifOrientations.Rotate270:
angle = 90;
break;
}
if (angle != 0) //on doit effectuer une rotation de l'image
{
ret = new TransformedBitmap(ret.Clone(), new RotateTransform(angle));
ret.Freeze();
}
}
return ret;
}
示例3: GetByteData
/// <summary>
/// creates a byte array from a bitmapImage
/// </summary>
/// <param name="source">the image for creating the byte array</param>
/// <returns>a byte array</returns>
public static byte[] GetByteData(BitmapSource source)
{
try
{
using (MemoryStream ms = new MemoryStream())
{
PngBitmapEncoder encoder = new PngBitmapEncoder();
BitmapFrame frame = BitmapFrame.Create(source.Clone());
encoder.Frames.Add(frame);
encoder.Save(ms);
ms.Seek(0, SeekOrigin.Begin);
return ms.GetBuffer();
}
}
catch
{
return null;
}
}
示例4: MetaOrientation
private static BitmapSource MetaOrientation(BitmapMetadata meta, BitmapSource ret)
{
double angle = 0.0;
if (meta != null && ret != null)
{
if (meta.GetQuery("/app1/ifd/{ushort=274}") != null)
Picture.orientation = (Picture.ExifOrientations)Enum.Parse(typeof(Picture.ExifOrientations), meta.GetQuery("/app1/ifd/{ushort=274}").ToString());
switch (Picture.orientation)
{
case Picture.ExifOrientations.Rotate180:
angle = 180.0;
break;
case Picture.ExifOrientations.Rotate270:
angle = 90.0;
break;
case Picture.ExifOrientations.Rotate90:
angle = -90.0;
break;
}
if (angle != 0.0)
{
ret = (BitmapSource)new TransformedBitmap(ret.Clone(), (Transform)new RotateTransform(angle));
ret.Freeze();
}
}
return ret;
}
示例5: Apply
public BitmapSource Apply(BitmapSource image)
{
return (BitmapSource) image.Clone();
}