RenderScript allocation crashing with UIL

75 views Asked by At

I am getting my bitmap I want to blur with the UniversalImageLoader. But this way this method will crash and I don't know why.

private Bitmap createBlurredImage(int radius, string imageUrl)
{
    Bitmap originalBitmap = ImageLoader.Instance.LoadImageSync(imageUrl); 
    Bitmap blurredBitmap = Bitmap.CreateBitmap(originalBitmap);

    RenderScript rs = RenderScript.Create(this);
    // Crashing here
    Allocation input = Allocation.CreateFromBitmap(rs, originalBitmap, Allocation.MipmapControl.MipmapFull, AllocationUsage.Script);
    Allocation output = Allocation.CreateTyped(rs, input.Type);

    ScriptIntrinsicBlur script = ScriptIntrinsicBlur.Create(rs, Element.U8_4(rs));
    script.SetInput(input);
    script.SetRadius(radius);
    script.ForEach(output);
    output.CopyTo(blurredBitmap);

    return blurredBitmap;
}

When I load the originalBitmap from Resources (any image in drawable), it will work. But not this way. How can I fix this?

0

There are 0 answers