im trying to fill bitmap with pattern.
This is what i get with this code:
Can you tell me, what im doing wrong and if you suggest me some approach.
public Bitmap applyMask(Context context, int resOriginal, int maskToBeApplied) {
Bitmap original = BitmapFactory.decodeResource(context.getResources(), resOriginal);
int width = original.getWidth();
int height = original.getHeight();
// decode mask
Bitmap mask = BitmapFactory.decodeResource(context.getResources(), maskToBeApplied);
// create output bitmap
Bitmap output = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
// create canvas
Canvas canvas = new Canvas(output);
// draw original (shirt)
canvas.drawBitmap(original, 0, 0, null);
// draw mask on shirt
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_OUT));
// draw mask
canvas.drawBitmap(mask, 300, 400, paint);
// recycle used bitmaps
original.recycle();
mask.recycle();
return output;
}
Aucun commentaire:
Enregistrer un commentaire