so i can save the image? The image can be found only in those format its not a file its just a BitmapImage.
I know this way in c# any ideas how to make it in C++?
private static async Task<StorageFile> SaveAsJpeg(WriteableBitmap wb)
{
byte[] pixels;
using (var stream = wb.PixelBuffer.AsStream())
{
pixels = new byte[(uint)stream.Length];
await stream.ReadAsync(pixels, 0, pixels.Length);
}
var name = String.Format("{0}_{1:yyyy-MM-dd_HH-mm-ss}.jpg", "MyApp", DateTime.Now);
var outputFile = await KnownFolders.PicturesLibrary.CreateFileAsync(name, CreationCollisionOption.ReplaceExisting);
using (var writeStream = await outputFile.OpenAsync(FileAccessMode.ReadWrite))
{
var encoder = await BitmapEncoder.CreateAsync(BitmapEncoder.JpegEncoderId, writeStream);
encoder.SetPixelData(BitmapPixelFormat.Bgra8, BitmapAlphaMode.Premultiplied,
(uint)wb.PixelWidth, (uint)wb.PixelHeight,
96, 96, pixels);
await encoder.FlushAsync();
using (var outputStream = writeStream.GetOutputStreamAt(0))
{
await outputStream.FlushAsync();
}
}
return outputFile;
No need to be task it can be void no problem...