I've been trying to figure out how to display a photo on Android. I can create an ImageView and display a picture, but the functionality is limited (no zoom, pan or share). Is there a demo or tutorial with code out there on how to do this? I've been searching all week with no luck.
Thanks.
P.S.> Please No Snark!
Maybe I don't understand how to create a uri correctly or how to make my resource available to the viewer. I have a resource ID, R.drawable.opal, I'm using to display different minerals and gems for a science project. If the student clicks the small sample photo, then I want to bring up a bigger and better viewer for the photo to allow them to compare to their collected rock.
Unless you really need to build your own you should probably just use the gallery's viewer. Send it the picture by using the view intent like so:
Intent viewImageIntent = new Intent(android.content.Intent.ACTION_VIEW, uri);
startActivity(viewImageIntent);
Replace "uri" with the image's uri of course. Writing your own viewer is really involved and would include threading, physics calculations and handling touch inputs.
Related
I'm developing a EBookreading application, EBookDroid is a library which we are using for the PDF reading. If we have any links in the PDF like www.stackoverflow.com, when the user clicks on it, it supposed to open the link, for that i need to find out the coordinates of that link in the Document.
I am writing like the below.
final RectF linkRect = page.getLinkSourceRect(pageBounds, link);
But it's always giving the null back.
Try this may be use full
THIS EXAMPLE
I'm creating an app where the user will use the camera or choose some photos from the gallery.
I'm trying to put some rules when the user chooses the photo from the album but I don't know all the properties and I tried to search some site or tutorial but I didn't found anything.
Someone knows where I can find this or learn the properties.
Properties like this
intent.putExtra("crop","true");
intent.putExtra("aspectX",10);
intent.putExtra("aspectY",10);
intent.putExtra("outputX",256);
intent.putExtra("outputY",256);
intent.putExtra("return-data",true);
I need to disable the resize function from the crop screen and I want to learn more about working with an android camera.
Thanks and regards to everyone.
"return-data"
"cropped-rect"
"aspectX"
"aspectY"
"spotlightX"
"spotlightY"
"outputX"
"outputY"
"scale"
"data"
"scaleUIfNeeded"
"outputFormat"
"set-as-wallpaper"
"noFaceDetection"
I refer you to Mr. Murphy's post here: http://commonsware.com/blog/2013/01/23/no-android-does-not-have-crop-intent.html
I am working on camera based application.
I want to normalize image that is captured by device's camera.
Is it possible to normalize image in android? any idea how can i do that?
Thanks...
Try to use Catalano Framework. Here contains the article that you can learn how to use.
I implemented Image Normalization using this approach.
FastBitmap fb = new FastBitmap("image.jpg");
fb.toGrayscale();
ImageNormalization in = new ImageNormalization();
in.applyInPlace(fb);
I am searching an ImageViewer library that opens an image in my application for a given URI (the image fetched by a webservice is already stored within my application in a secured place). I really like the "Samsung Galaxy S" ImageViewer-Activity because it uses pinch-zoom and "scrolling" vertical/horizontal. Also it scales the picture very fast on my samsung phone :)
I know that I can open an image with an intent like this:
Intent i = new Intent(Intent.ACTION_VIEW);
i.setDataAndType(uri, "image/*");
startActivity(i);
The best suitable viewer is being called, when none is found an ActivityNotFoundException is raised. So thats cool!
But the problem is that I am not allowed to open an image with an external intent (for security purposes). i.e: The user should not have the posibility to save the opened image via a menu option to his external sd-card or send this picture to another service (email/twitter or s.o.). So I have to write my own ImageViewer-Class (Activity) that can only be called within my application...
Unfortunately I am not very skilled transforming images, so is there any open source project (or library) that covers this use case?
I already asked google and found this one http://code.google.com/p/android-pinch/ but it didnt work very well (also it has no scroll-functionality).
Thanks for your tips :)
At this moment I'm too use WebView. But this is conceptually wrong, WebView is not for displaying images, it for displaying web content. WebView is bulky and cumbersome. You restricted in customizing it. For example, I need scaling, but I don't want to see zoom controls, or I want to move them in other place then default.
Therefore, I searched about this problem and found some solutions:
PhotoView widget from Chris Banes
Also, you can look at this tutorial from Sony Ericsson (sources available) and can implement your own widget: part1, part2, part3
And another one library ImageViewZoom at github
UPDATE
Chris Banes was created awesome library which supports gestures for zooming pictures, see first point above
The easiest way to handle images is using a WebView, if the image is stored local or somewhere online. WebView supports pinch to zoom and other functions.
Example Java:
String imageUrl = "file:///local/dir/image.jpg"; // http://example.com/image.jpg
WebView wv = (WebView) findViewById(R.id.yourwebview);
wv.getSettings().setBuiltInZoomControls(true);
wv.loadUrl(imageUrl);
XML source:
<WebView android:id="#+id/yourwebview"
android:layout_width="match_parent"
android:layout_height="match_parent" />
I guess this question has been asked before, but I can't seem to find a proper answer/solution.
Have a note-taking app, which allows to take pictures. For that I start an intent, that starts up the built-in camera-app. So far so good.
But when I show that image in my app, it's in a much smaller format :(
The funny/weird thing is, that the camera-app did take a full-resolution picture! But for some reason I can't get the full version to show in my app???
So, when I use the standard Android Gallery app, and go to that picture, it is very obvious that it's full size (I can zoom in and see details I really can't see when I zoom in, in my own app). Also, the dimensions are really those of the original picture, taken with the 5MP camera.
In my app, they are very small. My phone has Android 2.2, but the same happens on my emulator (Android 2.1).
How should I retrieve the pictures in my app??? Tried a couple of ways, but none works :( Don't need a complete example (allthough that's very welcome), just a few clues are enough to search for myself.
Tx in advance!!
Greetingz,
Koen<
Very weird, I found the solution/answer by looking at the _ID-values that were being inserted in my own database. First I noticed that when I selected an existing image (via the build-in Android Gallery), I did get the full size image.
When I first took a picture, I got a scaled image. So where was the difference. Apparantly at the location where the _ID of the picture got stored in my database. In my case, and probably most cases, this happens in the onActivityResult procedure.
First take a look at what I initially had:
if(requestCode == REQUEST_CAMERA && resultCode == RESULT_OK){
String timestamp = Long.toString(System.currentTimeMillis());
// get the picture
mPicture = (Bitmap)result.getExtras().get("data");
//save image to gallery
String pictureUrl = MediaStore.Images.Media.insertImage(getContentResolver(), mPicture, getResources().getString(R.string.app_name_short), timestamp);
insertPictureAttachment(mRowId.intValue(), Integer.parseInt(Uri.parse(pictureUrl).getLastPathSegment()));
The "insertPictureAttachment"-method does the actual inserting into the database.
Looking backwards, this was a bit weird anyway ... make a picture, so I could make an URI of it, and then get the last path segment (which is the _ID), so I could insert that into my database.
Eventually, it turns out that I can replace the above code with just one line:
insertPictureAttachment(mRowId.intValue(), Integer.parseInt(result.getData().getLastPathSegment()));
Much shorter, and actually makes more sense ... rather than getting the info from result.getExtras().get("data"), I get my info from result.getData(), which gives the _ID of the original, full-size image.
I will do some further research on this though, cause it's not clear to me yet why I actually don't have to call MediaStore.Images.Media.insertImage(...) ... maybe I will have to if I want specific features (like a custom file location or something like that).
Greetingz,
Koen<