本文整理汇总了C#中System.Windows.Media.Imaging.WriteableBitmap.SaveToFile方法的典型用法代码示例。如果您正苦于以下问题:C# WriteableBitmap.SaveToFile方法的具体用法?C# WriteableBitmap.SaveToFile怎么用?C# WriteableBitmap.SaveToFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Media.Imaging.WriteableBitmap
的用法示例。
在下文中一共展示了WriteableBitmap.SaveToFile方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DisplaySmilieResult
private void DisplaySmilieResult(WriteableBitmap writeableBitmap, FaceRestAPI.FaceAPI result)
{
int countHappy = 0;
int countSad = 0;
foreach (var tag in result.photos[0].tags)
{
// Uses the segment's center and half width, height
var c = tag.center;
Debug.WriteLine("Center ({0} ,{1}), size ({2}, {3})", c.x, c.y, tag.width,
tag.height);
var destRect = new Rect(writeableBitmap.PixelWidth * 0.01 * (tag.center.x - tag.width / 2),
writeableBitmap.PixelHeight * 0.01 * (tag.center.y - tag.height / 2),
writeableBitmap.PixelWidth * 0.01 * tag.width,
writeableBitmap.PixelHeight * 0.01 * tag.height);
var whichFace = ChooseFace(tag.attributes);
if (whichFace == _smilieWriteableBitmap)
countHappy++;
else
countSad++;
var sourceRect = new Rect(0, 0, whichFace.PixelWidth, whichFace.PixelHeight);
writeableBitmap.Blit(destRect, whichFace, sourceRect);
}
writeableBitmap.Invalidate();
SelectedImage.Source = writeableBitmap;
writeableBitmap.SaveToFile(AppConstants.IsoFileName, (stream) => { /* do nothing */ });
ShowDisplay(DisplayState.Finished);
NavigateToPhotoPage(countHappy, countSad);
}
示例2: ProcessImage
private void ProcessImage(WriteableBitmap writeable)
{
var verySimpleBitmap = new VerySimpleBitmap(writeable.PixelWidth, writeable.PixelHeight);
writeable.Pixels.CopyTo(verySimpleBitmap.Pixels, 0);
var detectedSegments = faceLight.Process(verySimpleBitmap);
var percentage = 0;
switch (detectedSegments.Count())
{
case 0:
percentage = 0;
break;
case 1:
percentage = 90;
break;
default:
percentage = 99;
break;
}
Debug.WriteLine("{0} segments detected", detectedSegments.Count());
foreach (var segment in detectedSegments)
{
if (segment.Width > 0 && segment.Height > 0)
{
// Uses the segment's center and half width, height
var c = segment.Center;
Debug.WriteLine("Center ({0} ,{1}), size ({2}, {3})", c.X, c.Y, segment.Width,
segment.Height);
var destRect = new Rect(segment.Center.X - segment.Width / 2,
segment.Center.Y - segment.Height / 2,
segment.Width,
segment.Height);
var sourceRect = new Rect(0, 0, _chimpWriteableBitmap.PixelWidth, _chimpWriteableBitmap.PixelHeight);
writeable.Blit(destRect, _chimpWriteableBitmap, sourceRect);
}
}
writeable.Invalidate();
SelectedImage.Source = writeable;
writeable.SaveToFile(AppConstants.IsoFileName, (stream) => { /* do nothing */ });
ShowDisplay(DisplayState.Finished);
NavigateToPhotoPage(percentage);
}