Hello
I need to make DRM Image file using two image file.
originally I was use bufferedImage class, but android is not support bufferedImage.
so please help me. how to compose two image in android?
You can do that if you overlay two images. Suppose that bmp1 is bigger one (to be protected), and bmp2 is marker:
private Bitmap overlayMark(Bitmap bmp1, Bitmap bmp2)
{
Bitmap bmOverlay = Bitmap.createBitmap(bmp1.getWidth(), bmp1.getHeight(), bmp1.getConfig());
Canvas canvas = new Canvas(bmOverlay);
canvas.drawBitmap(bmp1, 0, 0, null);
canvas.drawBitmap(bmp2, distanceLeft, distanceTop, null);
return bmOverlay;
}
distanceLeft and distanceTop define position of the marker.
Related
I am developing an Android application for image processing. In that, I first need to generate an ortho image by stitching 100+ images together. I have tried it in Android using Bitmap and Canvas. I first did it for 3 images. Is it the right way to generate an ortho or is there any better solution for this? Here is the code that I have used for stitching 3 images:
private void joinImages(File first, File second , File third) throws IOException
{
Bitmap bmp1, bmp2, bmp3;
bmp1 = BitmapFactory.decodeFile(first.getPath());
bmp2 = BitmapFactory.decodeFile(second.getPath());
bmp3 = BitmapFactory.decodeFile(third.getPath());
int height = bmp1.getHeight()+bmp2.getHeight()+bmp3.getHeight();
String height1 = height+"";
Log.d(height1,"heght");
Bitmap bmOverlay = Bitmap.createBitmap(bmp1.getWidth(), height, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bmOverlay);
canvas.drawBitmap(bmp1, 0, 0, null);
canvas.drawBitmap(bmp2, bmp1.getHeight(), 0, null);
canvas.drawBitmap(bmp3,bmp1.getHeight()+bmp2.getHeight() , 0, null);
FileOutputStream out = new FileOutputStream("/storage/emulated/0/DCIM/final.jpg");
bmOverlay.compress(Bitmap.CompressFormat.JPEG, 80, out);
out.close();
}
As I am new to Android as well as image processing, I also want to know the difference between image stitching and 2D-orthomosaic generation. Kindly help me with this issue.
I am trying to rotate a bitmap and add it to a canvas. The code seems straightforward, however the image is not being rotated. I can't use canvas.rotate() since I am layering images and do not want the first image to be rotated. I have verified that the rotation degree is correct with tattoo.getRotation(), and I have also tried this with a hard coded degree but that doesn't work either.
public static Bitmap overlay(Bitmap bmp1, Bitmap bmp2) {
Bitmap bmOverlay = Bitmap.createBitmap(bmp1.getWidth(), bmp1.getHeight(), bmp1.getConfig());
Canvas canvas = new Canvas(bmOverlay);
Matrix matrix1 = new Matrix();
matrix1.setScale(imageView.getScaleX(), imageView.getScaleY());
matrix1.setTranslate(imageView.getX(), imageView.getY());
canvas.drawBitmap(bmp1, matrix1, null);
Matrix matrix2 = new Matrix();
matrix2.setTranslate(tattoo.getX(), tattoo.getY());
matrix2.postRotate(tattoo.getRotation());
matrix2.setScale(tattoo.getScaleX(), tattoo.getScaleY());
canvas.drawBitmap(bmp2, matrix2, null);
return bmOverlay;
}
I am working on an instant chat messenger .I want to create new groups now. While creating groups i am getting an array of thumbnail URLS of the members of the group.I want to display the multiple images in an imageview using Picasso as facebook messenger do.Screenshot is given below:
As we can see in the screenshot ,image view contain the pic of members of all the group.Can anybody tell me how can i load multiple pics into single image view using picasso or by any other library ?
You can do something like this! Just Try !
public static Bitmap overlay(Bitmap bmp1, Bitmap bmp2) {
Bitmap bmOverlay = Bitmap.createBitmap(bmp1.getWidth(), bmp1.getHeight(), bmp1.getConfig());
Canvas canvas = new Canvas(bmOverlay);
canvas.drawBitmap(bmp1, new Matrix(), null);
canvas.drawBitmap(bmp2, 0, 0, null);
return bmOverlay; }
Hopefully it will help you !
I am working on a project where I have used canvas and user can touch move one bitmap overlay to another bitmap. When user presses save button then both bitmaps should merge and become a single bitmap. I have done all things and now merging two bitmap at XY position remains. During my research I found following code.
private Bitmap overlay(Bitmap bmp1, Bitmap bmp2) {
Bitmap bmOverlay = Bitmap.createBitmap(bmp1.getWidth(), bmp1.getHeight(), bmp1.getConfig());
Canvas canvas = new Canvas(bmOverlay);
canvas.drawBitmap(bmp1, new Matrix(), null);
canvas.drawBitmap(bmp2, new Matrix(), null);
return bmOverlay;
}
But this code overlay bitmap at (0,0) location. I want to overlay bitmap at my given location. Please suggest some solution. Thanks in advance.
Use below code
private Bitmap overlay(Bitmap bmp1, Bitmap bmp2) {
Bitmap bmOverlay = Bitmap.createBitmap(bmp1.getWidth(), bmp1.getHeight(), bmp1.getConfig());
Canvas canvas = new Canvas(bmOverlay);
canvas.drawBitmap(bmp1, new Matrix(), null);
canvas.drawBitmap(bmp2, x,y, null);
return bmOverlay;
}
Where x and y are actual positions where you have to draw the overlay bitmap.
I would like to take one image, and then paste it onto another image using Bitmap. (Basically overlaying image 1 on top of image 2 and then being able to save it.)
I've been searching all day for this. Are there any tutorials that show this? I couldn't find any functions in the Android SDK that did this either.
you can combine two bitmaps like this
public static Bitmap overlay(Bitmap bmp1, Bitmap bmp2) {
Bitmap bmOverlay = Bitmap.createBitmap(bmp1.getWidth(), bmp1.getHeight(), bmp1.getConfig());
Canvas canvas = new Canvas(bmOverlay);
canvas.drawBitmap(bmp1, new Matrix(), null);
canvas.drawBitmap(bmp2, 0, 0, null);
return bmOverlay;
}