Skip to content

Instantly share code, notes, and snippets.

@fangzhzh
Last active July 28, 2016 11:49
Show Gist options
  • Save fangzhzh/12945fc426317b6a14c2 to your computer and use it in GitHub Desktop.
Save fangzhzh/12945fc426317b6a14c2 to your computer and use it in GitHub Desktop.
android, java, draw two bitmaps with Picasso.
Picasso.with(getContext())
.load(CONST.IMAGE_SERVER + cover.image_url)
.into(new Target() {
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom loadedFrom) {
Bitmap bmOverlay = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), bitmap.getConfig());
Bitmap play= BBAppResource.bitmap(R.drawable.btn_me_account);
Canvas canvas = new Canvas(bmOverlay);
canvas.drawBitmap(bitmap, new Matrix(), null);
float left = (float)((bitmap.getWidth()-play.getWidth())/2.0);
float top = (float)((bitmap.getHeight()-play.getHeight())/2.0);
canvas.drawBitmap(BBAppResource.bitmap(R.drawable.btn_me_account), left, top, null);
setImageDrawable( new BitmapDrawable(getResources(),bmOverlay));
}
@Override
public void onBitmapFailed(Drawable drawable) {
}
@Override
public void onPrepareLoad(Drawable drawable) {
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment