Created
November 24, 2015 11:01
-
-
Save jaganjan/b0c291e0270412757ba6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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