cloudflare / cloudflare/worker-emscripten-template

canvas.drawbitmap error

Open
#30 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
68
Forks
16
PR merge metrics
No merged PRs in 30d

Description

``` csharp
@page "/drawing"
@using SkiaSharp
@using SkiaSharp.Views.Blazor
@rendermode InteractiveWebAssembly
@inject HttpClient http

Drawing


更新绘图

@code {

private SKCanvasView canvasView;
private void OnClickImg()
{
//引发画布更新绘图
canvasView.Invalidate();
}

async void OnPaintSurface(SKPaintSurfaceEventArgs e)
{
var canvas = e.Surface.Canvas;

canvas.Clear(SKColors.SkyBlue);

try
{
var imageStream = await http.GetStreamAsync("http://localhost:5158/2.BMP");
byte[] buffers = new byte[imageStream.Length];
imageStream.Read(buffers, 0, buffers.Length);

SKBitmap bitmap = SKBitmap.Decode(buffers);
canvas.DrawBitmap(bitmap, 1, 1);
}
catch (Exception ex)
{

}

}
}
```

MONO_WASM: Exception marshalling result of JS promise to CS: RuntimeError: memory access out of bounds
at SkCanvas::drawImage(SkImage const*, float, float, SkPaint const*) (wasm://wasm/0585664e:wasm-function[8982]:0x368e95)
at sk_canvas_draw_image (wasm://wasm/0585664e:wasm-function[13141]:0x4da50f)
at wasm_invoke_viiffi (wasm://wasm/0585664e:wasm-function[29423]:0x7d95f4)
at ves_pinvoke_method (wasm://wasm/0585664e:wasm-function[14435]:0x529b84)
at mono_interp_exec_method (wasm://wasm/0585664e:wasm-function[14426]:0x51b931)
at interp_runtime_invoke (wasm://wasm/0585664e:wasm-function[14466]:0x52b1e6)
at mono_jit_runtime_invoke (wasm://wasm/0585664e:wasm-function[19000]:0x640276)
at do_runtime_invoke (wasm://wasm/0585664e:wasm-function[17847]:0x600b5a)
at mono_runtime_try_invoke (wasm://wasm/0585664e:wasm-function[17856]:0x6015da)
at mono_runtime_invoke (wasm://wasm/0585664e:wasm-function[17892]:0x604157) {stack: 'RuntimeError: memory access out of bounds
…/wasm/0585664e:wasm-function[17892]:0x604157)', message: 'memory access out of bounds'}

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.