Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ ios/build/
example/android/build/
example/ios/build/
**/build/
windows/**/bin/
windows/**/obj/
example-windows/windows/**/bin/
example-windows/windows/**/obj/
**/.gradle/
**/.cxx/

Expand Down
16 changes: 14 additions & 2 deletions windows/RNViewShot/ViewShot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,19 @@ public static async Task<string> Execute(FrameworkElement view, string extension
throw new InvalidOperationException("Capture is too large to base64-encode (" + ras.Size + " bytes)");
}
var imageBytes = new byte[(int)ras.Size];
await ras.AsStream().ReadAsync(imageBytes, 0, imageBytes.Length);
using (var input = ras.GetInputStreamAt(0).AsStreamForRead())
{
var offset = 0;
while (offset < imageBytes.Length)
{
var read = await input.ReadAsync(imageBytes, offset, imageBytes.Length - offset);
if (read == 0)
{
throw new EndOfStreamException("Capture stream ended before all image bytes were read");
}
offset += read;
}
}
var data = Convert.ToBase64String(imageBytes);
if (result == "data-uri")
{
Expand Down Expand Up @@ -77,7 +89,7 @@ private static async Task CaptureView(FrameworkElement view, IRandomAccessStream
{
var propertySet = new BitmapPropertySet
{
{ "ImageQuality", new BitmapTypedValue(quality, Windows.Foundation.PropertyType.Single) },
{ "ImageQuality", new BitmapTypedValue((float)quality, Windows.Foundation.PropertyType.Single) },
};
encoder = await BitmapEncoder.CreateAsync(BitmapEncoder.JpegEncoderId, stream, propertySet);
}
Expand Down
Loading