本文整理汇总了C#中System.Windows.Media.Imaging.WriteableBitmap.GetStream方法的典型用法代码示例。如果您正苦于以下问题:C# WriteableBitmap.GetStream方法的具体用法?C# WriteableBitmap.GetStream怎么用?C# WriteableBitmap.GetStream使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Media.Imaging.WriteableBitmap
的用法示例。
在下文中一共展示了WriteableBitmap.GetStream方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnCreateAndUploadImage
public void OnCreateAndUploadImage(object obj)
{
EA.GetEvent<SetCompositionWidthHeight>().Publish(string.Empty);
var document = HtmlPage.Document;
var txtArea = document.GetElementById("MainContent_txtPNGBytes");
if (txtArea != null)
{
try
{
const double scale = 1;
var bmp = new WriteableBitmap(CompositionGrid, null);
var buffer = bmp.ToByteArray();
bmp = new WriteableBitmap(int.Parse(Width.ToString()), int.Parse(Height.ToString()));
bmp.FromByteArray(buffer);
var transform = new ScaleTransform();
transform.ScaleX = scale;
transform.ScaleY = scale;
bmp.Render(CompositionGrid, (Transform)transform);
bmp.Invalidate();
var stream = bmp.GetStream();
var binaryData = new Byte[stream.Length];
var bytesRead = stream.Read(binaryData, 0, (int)stream.Length);
var base64 = Convert.ToBase64String(binaryData, 0, binaryData.Length);
RawSize = base64.Length.ToString();
Message message = Composer.Messaging.Compression.Compress(base64);
base64 = message.Text;
CompressedSize = base64.Length.ToString();
txtArea.SetProperty("value", base64);
UploadDetailsVisibility = Visibility.Visible;
SendImage();
}
catch (Exception ex)
{
Exceptions.HandleException(ex, "Error in: OnCreateAndUploadImage");
}
}
}