本文整理汇总了C#中System.Windows.Media.Imaging.WriteableBitmap.WritePNG方法的典型用法代码示例。如果您正苦于以下问题:C# WriteableBitmap.WritePNG方法的具体用法?C# WriteableBitmap.WritePNG怎么用?C# WriteableBitmap.WritePNG使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Media.Imaging.WriteableBitmap
的用法示例。
在下文中一共展示了WriteableBitmap.WritePNG方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SaveChangesToImage
internal void SaveChangesToImage(InkPresenter ImageArea)
{
if (this.IsEditable)
{
WriteableBitmap wbBitmap = new WriteableBitmap(ImageArea, new TranslateTransform());
using (var stream = new MemoryStream())
{
wbBitmap.WritePNG(stream);
stream.Seek(0, System.IO.SeekOrigin.Begin);
byte[] imageBytes = new byte[stream.Length];
stream.Read(imageBytes, 0, (int)stream.Length);
this.FeedbackImage.DataBytes = imageBytes;
}
ImageArea.Strokes.Clear();
}
}
示例2: WriteTileToDisk
protected static string WriteTileToDisk(string year, string description, int width, int height, string fontSize, Thickness margins)
{
Grid container = new Grid()
{
Width = width,
Height = height,
Background = (Brush)Application.Current.Resources["TransparentBrush"]
};
container.Children.Add(GetTextBlockToRender(description, fontSize, margins));
// Force the container to render itself
container.UpdateLayout();
container.Arrange(new Rect(0, 0, width, height));
var writeableBitmap = new WriteableBitmap(container, null);
string fileName = SharedImagePath + "tile" + height + width + ".png";
using (IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication())
{
using (var stream = new IsolatedStorageFileStream(fileName, FileMode.Create, storage))
{
if (writeableBitmap.PixelHeight > 0)
{
writeableBitmap.WritePNG(stream);
}
}
}
return fileName;
}
示例3: ShowPhotoResult
internal async Task ShowPhotoResult(PhotoResult result)
{
var imageVM = new FeedbackImageVM(this.ParentVM);
imageVM.IsEditable = true;
byte[] imageBytes = null;
if (Path.GetExtension(result.OriginalFileName).ToLower().EndsWith("jpg"))
{
BitmapImage img = new BitmapImage();
img.SetSource(result.ChosenPhoto);
var wbBitmap = new WriteableBitmap(img);
using (var stream = new MemoryStream())
{
wbBitmap.WritePNG(stream);
stream.Seek(0, System.IO.SeekOrigin.Begin);
imageBytes = new byte[stream.Length];
stream.Read(imageBytes, 0, (int)stream.Length);
}
}
else //png
{
imageBytes = new byte[result.ChosenPhoto.Length];
await result.ChosenPhoto.ReadAsync(imageBytes, 0, (int)result.ChosenPhoto.Length);
}
imageVM.FeedbackImage = new FeedbackAttachment(Path.GetFileName(result.OriginalFileName), imageBytes, null);
Attachments.Add(imageVM);
this.ParentVM.SwitchToImageEditor(imageVM);
}
示例4: PinButton_Click
private void PinButton_Click(object sender, EventArgs e)
{
if (id == null) {
id = DateTime.Now.Ticks.ToString();
}
// save sticky
settings[id] = Sticky;
WriteableBitmap front = new WriteableBitmap(TilePreview, null);
CompensateForRender(front.Pixels);
string frontFilename = GetTileFilename(id);
using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication()) {
using (IsolatedStorageFileStream fs = isf.CreateFile(frontFilename)) {
front.WritePNG(fs);
}
}
StandardTileData tile = new StandardTileData {
BackgroundImage = new Uri("isostore:/" + frontFilename),
BackBackgroundImage = new Uri("IDontExist", UriKind.Relative), // UGLY HACK
BackContent = string.Empty,
BackTitle = string.Empty
};
if (EnableBack.IsChecked.GetValueOrDefault()) {
FlurryWP7SDK.Api.LogEvent("Enabling tile");
WriteableBitmap back = new WriteableBitmap(BackTilePreview, null);
CompensateForRender(back.Pixels);
string backFilename = GetTileFilename(id, true);
using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication()) {
using (IsolatedStorageFileStream fs = isf.CreateFile(backFilename)) {
back.WritePNG(fs);
}
}
tile.BackBackgroundImage = new Uri("isostore:/" + backFilename);
}
var shelltile = GetTile(id);
if (shelltile != null) {
FlurryWP7SDK.Api.LogEvent("Updated existing tile");
shelltile.Update(tile);
Focus();
MessageBox.Show("Your updated tile should be in your start screen.", "Tile updated", MessageBoxButton.OK);
} else {
FlurryWP7SDK.Api.LogEvent("Pinned new tile");
ShellTile.Create(GetTileUri(id), tile);
}
}