mirror of
https://github.com/zoriya/Opus.git
synced 2025-12-06 06:26:15 +00:00
Adding a try catch block and debug messages for the blurred bitmap creation for the queue background.
This commit is contained in:
@@ -159,7 +159,7 @@ namespace Opus
|
|||||||
{
|
{
|
||||||
drawable = Picasso.With(Application.Context).Load(current.Album).Error(Resource.Drawable.noAlbum).Placeholder(Resource.Drawable.noAlbum).Transform(new RemoveBlackBorder(true)).Get();
|
drawable = Picasso.With(Application.Context).Load(current.Album).Error(Resource.Drawable.noAlbum).Placeholder(Resource.Drawable.noAlbum).Transform(new RemoveBlackBorder(true)).Get();
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch
|
||||||
{
|
{
|
||||||
drawable = Picasso.With(Application.Context).Load(Resource.Drawable.noAlbum).Get();
|
drawable = Picasso.With(Application.Context).Load(Resource.Drawable.noAlbum).Get();
|
||||||
}
|
}
|
||||||
@@ -176,7 +176,7 @@ namespace Opus
|
|||||||
{
|
{
|
||||||
drawable = Picasso.With(Application.Context).Load(iconURI).Error(Resource.Drawable.noAlbum).Placeholder(Resource.Drawable.noAlbum).NetworkPolicy(NetworkPolicy.Offline).Get();
|
drawable = Picasso.With(Application.Context).Load(iconURI).Error(Resource.Drawable.noAlbum).Placeholder(Resource.Drawable.noAlbum).NetworkPolicy(NetworkPolicy.Offline).Get();
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch
|
||||||
{
|
{
|
||||||
drawable = Picasso.With(Application.Context).Load(Resource.Drawable.noAlbum).Get();
|
drawable = Picasso.With(Application.Context).Load(Resource.Drawable.noAlbum).Get();
|
||||||
}
|
}
|
||||||
@@ -188,25 +188,33 @@ namespace Opus
|
|||||||
|
|
||||||
if (albumArt.Width > 0)
|
if (albumArt.Width > 0)
|
||||||
{
|
{
|
||||||
//The width of the view in pixel (we'll multiply this by 0.75f because the drawer has a width of 75%)
|
try
|
||||||
int width = (int)(albumArt.Width * (float)drawable.Height / albumArt.Height);
|
{
|
||||||
int dX = (int)((drawable.Width - width) * 0.5f);
|
//The width of the view in pixel (we'll multiply this by 0.75f because the drawer has a width of 75%)
|
||||||
Console.WriteLine("&Drawable Info: Width: " + drawable.Width + " Height: " + drawable.Height);
|
int width = (int)(albumArt.Width * (float)drawable.Height / albumArt.Height);
|
||||||
Console.WriteLine("&AlbumArt Info: Width: " + albumArt.Width + " Height: " + albumArt.Height);
|
int dX = (int)((drawable.Width - width) * 0.5f);
|
||||||
Console.WriteLine("&Blur Creation: Width: " + width + " dX: " + dX);
|
Console.WriteLine("&Drawable Info: Width: " + drawable.Width + " Height: " + drawable.Height);
|
||||||
Bitmap blured = Bitmap.CreateBitmap(drawable, dX, 0, (int)(width * 0.75f), drawable.Height);
|
Console.WriteLine("&AlbumArt Info: Width: " + albumArt.Width + " Height: " + albumArt.Height);
|
||||||
Console.WriteLine("&BLured bitmap created");
|
Console.WriteLine("&Blur Creation: Width: " + width + " dX: " + dX);
|
||||||
|
Bitmap blured = Bitmap.CreateBitmap(drawable, dX, 0, (int)(width * 0.75f), drawable.Height);
|
||||||
|
Console.WriteLine("&BLured bitmap created");
|
||||||
|
|
||||||
RenderScript rs = RenderScript.Create(MainActivity.instance);
|
RenderScript rs = RenderScript.Create(MainActivity.instance);
|
||||||
Allocation input = Allocation.CreateFromBitmap(rs, blured);
|
Allocation input = Allocation.CreateFromBitmap(rs, blured);
|
||||||
Allocation output = Allocation.CreateTyped(rs, input.Type);
|
Allocation output = Allocation.CreateTyped(rs, input.Type);
|
||||||
ScriptIntrinsicBlur blurrer = ScriptIntrinsicBlur.Create(rs, Element.U8_4(rs));
|
ScriptIntrinsicBlur blurrer = ScriptIntrinsicBlur.Create(rs, Element.U8_4(rs));
|
||||||
blurrer.SetRadius(13);
|
blurrer.SetRadius(13);
|
||||||
blurrer.SetInput(input);
|
blurrer.SetInput(input);
|
||||||
blurrer.ForEach(output);
|
blurrer.ForEach(output);
|
||||||
|
|
||||||
output.CopyTo(blured);
|
output.CopyTo(blured);
|
||||||
MainActivity.instance.FindViewById<ImageView>(Resource.Id.queueBackground).SetImageBitmap(blured);
|
MainActivity.instance.FindViewById<ImageView>(Resource.Id.queueBackground).SetImageBitmap(blured);
|
||||||
|
Console.WriteLine("&Bitmap set to image view");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine("&Queue background error: " + ex.Message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bar != null)
|
if (bar != null)
|
||||||
|
|||||||
Reference in New Issue
Block a user