Android applies a special sticker to the image
I am trying to use an image editor library that allows me to stick a sticker on an image. I found two libraries, one is Aviary , but I cannot put my own stickers in it, then I tried android-image-edit , but very simple, and this is not a library, this is an application. Does anyone know of any good libraries that allow me to do what I am trying to do? Thanks in advance.
source to share
I don't know the libraries, but if you understand correctly, you want to add one Drawable per image?
You can do it yourself: (untested!)
public void putSticker(File file, Bitmap overlay) {
//Load bitmap from file:
Bitmap bitmap = BitmapFactory.decodeFile(file.getAbsolutePath());
bitmap = bitmap.copy(Bitmap.Config.RGB_565, true);
//Draw overlay:
Canvas canvas = new Canvas(bitmap);
Paint paint = new Paint(Paint.FILTER_BITMAP_FLAG);
canvas.drawBitmap(overlay, 0, 0, paint);
//Save to file:
ByteArrayOutputStream bos = new ByteArrayOutputStream();
bitmap.compress(CompressFormat.PNG, 40, bos);
byte[] bitmapdata = bos.toByteArray();
FileOutputStream fos;
try {
fos = new FileOutputStream(file);
fos.write(bitmapdata);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
Perhaps there is a better way to load and save. Anyway, drawing is the interesting part of your question.
See http://developer.android.com/reference/android/graphics/Canvas.html for details on drawBitmap () capabilities . (Offsets, scaling, ...)
source to share