Image crop help using multiple imageview - android

here's my problem... Would it be possible to load a picture, call the crop activity, and load the cropped images on different imageviews without changing the main image??
I have 3 imageviews. My imageview 1 is for the main image loadout, my imageview 2 is for the result of the crop activity, the same goes with imageview 3.
I am using com.theartofdev.edmodo:android-image-cropper:2.6.0....
The good thing about this one is that it already has lots of functions, but the problem is that what I want to happen is that it would load the image that I have already called in my main imageview.

Get the instances of the Views in the activity class.
Use the method below to get the image source to bitmap
Display bm returned from convertImageViewToBitmap to the second ImageView.
private Bitmap convertImageViewToBitmap(ImageView v){
Bitmap bm =
((BitmapDrawable)v.getDrawable()).getBitmap();
return bm;
}

Related

Is it possible to translate an ImageView on the android platform using Picasso?

For example, if I loaded an image into an ImageView as such:
Imeteor = (ImageView) findViewById(R.id.meteor1);
Picasso.with(this)
.load(R.drawable.red_meteor)
.resize((int) meteorWidth, (int) meteorHeight)
.into(Imeteor);
Is it then possible to translate (move across or around the screen) said ImageView using Picasso? The current method I am using is below.
Imeteor = (ImageView) findViewById(R.id.meteor1);
Imeteor.setX(meteorXPosition);
Imeteor.setY(meteorYPosition);
With the values of "meteorXPosition", and "meteorYPosition" being updated in a separate method from where the image is loaded. Also, "meteorXPosition", and "meteorYPosition" are updated every millisecond.
Or,
By the fact that the image is loaded using Picasso, does that mean that the every time the ImageView is accessed it is accessed through Picasso? For example, by the code I provided above
Imeteor = (ImageView) findViewById(R.id.meteor1);
Imeteor.setX(meteorXPosition);
Imeteor.setY(meteorYPosition);
For anyone who might read this, and doesn't bother to read the comments. Picasso only handles loading the bitmap, and performing transformations on the bitmap in the image view. For moving a bitmap within an image view an option is to use the image view's setX() and setY() function. Which moves the the image view to a new location (the bitmap is in the image view). For moving images it is best to look up how to move an image view.

Refresh image cache in ImageView

I have an imageView from which I take visible part of image with getDrawingCache(). It works well. But when I change image in imageView and try to get bitmap from it, getDrawingCache() returns bitmap of the first image. I tried to call this method buildDrawingCache() before calling getDrawingCache() but it didn't help.
How can I refresh cache or associated bitmap or I don`t know what in order to get new image?
Solution was very simple:
imageView.destroyDrawingCache();
imageView.buildDrawingCache();
imageView.getDrawingCache();

Android avoid image scalling in Imageview for Image Mapping like Html

Hi Am trying to implement image mapping as like html in android. For that i referred this project. Its work good when i access the image from drawable-nodpi folder. But when i access from other drawable folder the image get scaled as per the android concepts. Here i used drawable folder for checking purpose only. Actually i get image from back end service.
I also tried with bitmap by setting the no density.
Bitmap bm;
bm=BitmapFactory.decodeResource(getResources(), R.drawable.blueprint);
bm.setDensity(Bitmap.DENSITY_NONE);
mImageMap.setImageBitmap(bm); //mImageMap is customized view which extends Imageview
But it's not working. Am also tried as per this post. Its not working.Is there any way to load image to image view without scaling?
you can use Bitmap.createScaledBitmap with the orignal mesaures of the picture..
int width = orignal bitmap width
int height = orignal bitmap height
Bitmap bm;
bm = getBitmap... from network
bm = Bitmap.createScaledBitmap(bm,width,height,true);
this will create a image scaled properly and just place it in the ImageView.

Removing image from ImageView and load new Image

I am facing problem on removing image from ImageView.
What I want an Image is loaded in ImageView, and then a new Image is taken by the camera and now that Image should load in ImageView replacing the previous one. I have tried
invalidate();
setImageBitmap(null);
setImageResource(0);
All these 3 methods are not working. Can someone help me.
Use this for setting image in ImageView
image.setImageResource(R.drawable.image);
If you want to set the Image By Drawable Image you can use like this
your_image_view.setImageDrawable(context.getResources().getDrawable(your_drawable_Image_id));
If you want to set the image by BitMapDrawable
your_image_view.setBackgroundDrawable(your_drawable_bitmap);
edit_countflag.setBackgroundColor(0);
edit_countflag.setImageResource(R.drawable.flag_id);

Getting imageview to read image from sd

I have a imageview and a camera button in Activity A. By clicking on the camera button will go to my custom camera activity. After taking a picture and storing it into a folder, how can I reflect this newly picture taken in the imageview after finishing the camera activity? Any help will be appreciated ?
A(main) > B(camera activity) > A(main) Imageview is updated with new picture taken.
Thanks.
According to my understanding of your question, you want to know how to set an image, residing on sdCard, to an ImageView. Well, let's say you can get the image path from your camera activity and then you can do something like below:
String imageInSD = "/sdcard/img.PNG";
Bitmap bitmap = BitmapFactory.decodeFile(imageInSD);
ImageView myImageView = (ImageView)findViewById(R.id.imageview);
myImageView.setImageBitmap(bitmap);
I hope it'll serve the purpose, if this is what you want.

Categories

Resources