Skip to content

Instantly share code, notes, and snippets.

@jaganjan
Created November 24, 2015 11:01
Show Gist options
  • Save jaganjan/b0c291e0270412757ba6 to your computer and use it in GitHub Desktop.
Save jaganjan/b0c291e0270412757ba6 to your computer and use it in GitHub Desktop.
private class Target : Java.Lang.Object, ITarget
{
// Bitmap PlaceHolder { get; set; }
private ImageView View { get; set; }
// Bitmap ErrorHolder { get; set; }
private Bitmap Overlay { get; set; }
public Target(ImageView view, Bitmap overlay)
{
//PlaceHolder = placeholder;
View = view;
Overlay = overlay;
}
public void OnBitmapFailed(Drawable drawable)
{
View.SetImageDrawable(drawable);
}
public void OnBitmapLoaded(Bitmap source, Picasso.LoadedFrom p1)
{
var result = PutOverlay(source, Overlay);
View.SetImageBitmap(result);
}
public void OnPrepareLoad(Drawable drawable)
{
View.SetImageDrawable(drawable);
}
private Bitmap PutOverlay(Bitmap bmp1, Bitmap overlay)
{
Bitmap bmOverlay = Bitmap.CreateBitmap(bmp1.Width, bmp1.Height, Bitmap.Config.Argb8888);
Canvas canvas = new Canvas(bmOverlay);
Paint paint = new Paint(PaintFlags.FilterBitmap);
int x = (bmp1.Width - overlay.Width) / 2;
int y = (bmp1.Height - overlay.Height) / 2;
canvas.DrawBitmap(bmp1, new Matrix(), null);
canvas.DrawBitmap(overlay, x, y, new Paint());
return bmOverlay;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment