I have two situations/projects where I have to use a large bitmap as background activity.
The first project ports a WP7 application to Android! The WP7 app is using a panorama control with a bitmap as large as 3 screens. I would like to reuse the large bitmap similar in a way that I use the left part for the first activity, the middle part for the second activity and the right part for the third activity. In other words I would like to define which part to crop.
In the second project we try to develop an app which should run on various screen sizes (including tablet), the app should also use a background image. Is it a good idea to provide only one picture with a quadratic size (as long as the largest screen width) and use this picture through every resolution and just crop the background image depending on the actual size of the display?
Is it possible to crop pictures on Android?
Is it possible to define the part of the picture which is kept?
Is it possible to use this croped pictures as background image or may I encounter performance penalties?
What do you think of this technique? Is it a good idea?
Thanks for your help!
answering your questions:
yes it is possible to crop pictures in Android (I've done so)
you can define wich part of the picture is shown in each activity
with a canvas and only drawing the rect that corresponds to the part
of the image that you want to display (eventough I wouldnt suggest
the approach of having diferent activities with the "same" content)
yes, you can use cropped pictures as background image for whatever
you want. Once you cropped the image use that bitmap and save it in
the device and then you might use it as you wish, and eventought is not recommended to have the whole image as background you can do so.
I suggest that you use a SurfaceView since you will be able to move it (the image) all around the screen without having to create a new activity. Here is a good tutorial to SurfaceView Playing with graphics in Android – Part I and this approach will also work with Tablets.
Related
I am writing a Android app which need to display some high quality picture(took from professional DSLR). The problem is it can't be display from gallery.
I choose a photo in Gallery first. The target picture is 2464*1632 JPEG, roughly 4.5M;
Then I just need to compress it to 800*600 and display it in imageview:
image.setImageBitmap(this.bmp);
Thing is that I have tested other image I downloaded form internet(really low quality), and it works without any problem. Can anybody tell me why it can't be displayed? I will be really appericiated
Large images are tricky to handle due to limited memory. You have several choices:
Use a WebView (this allows you to have pinch and zoom functionality to make use of those extra pixels
Decode the image down to the size of the display and then put it in an ImageView using BitmapOpts http://developer.android.com/reference/android/graphics/BitmapFactory.Options.html and changing inSampleSize. It seems you may be having difficulty with that, so consider using createScaledBitmap which just needs the dest width and height.
I have to make my app capable of taking pictures of only whatever it fits a squared frame that is superimposed on the preview.
The idea is: the client wants the app to send pictures of 600x600px tops. To avoid cropping important parts of the picture, he decided to put this superimposed squared frame (similar to the one in QR-reading apps) and to crop out everything out of said frame.
To do this I need two things.
1) How do I set the frame dimensions for multiple screens while getting the output within the required dimensions?
2) Once the frame is up and running... how do I crop out the rest of the picture?
Thanks in advance.
Update
What I want to do is something similar to what is explained here http://www.londatiga.net/featured-articles/how-to-select-and-crop-image-on-android/
Thing is:
This how-to checks if there's an image-cropper app installed, it
doesn't do the cropping by itself (or so I understand, maybe I'm
wrong?).
The frame seems to be 200x200... px? dp? Would that frame take up the
same portion of screen on xhdpi screens that on ldpi screens?
What's the size of the resulting image? Can I decide it somehow?
I have a background png in my Android application. I would like to support lots of displays, but I have this one obstacle - many displays have many resolutions and many ratios. I would like to make sure my background is displayed properly and make it more ellegant, than just creating 10+ cropped png files in Photoshop.
My idea would be - a fairly large picture imported in the project. The app would find out screen dimensions and simply say starting points(x,y) and ending points, that would "crop" the picture and display it without any deformations.
Is there a way of doing it?
I think bitmap.createBitmap() is the method your looking after. The method simply lets you cut out a defined portion of the bitmap.
I'm working on an application in which I need to download lots of images. The images are to be seen in the fullscreen mode. Therefore, I wanted to know how to load an image, speedily, to make the application more responsive and enhance user experience. I would like to, atleast, show a blurred image first and than make it sharp. Thanks.
use BitmapFactory.Options.inSamleSize to load a downsampled version of the image. Then load the bigger image and do a fade transition using a TransitionDrawable
You're looking for "progressive image rendering", which can be done in a variety of different image formats, including png, jpeg, gif, etc. The next time you're going to save an image in a good graphics program, select one of those formats and take a look at your save options. You should have an option to save an "interlaced" image.
Jeff Atwood of Coding Horror has a nice write up here: http://www.codinghorror.com/blog/2005/12/progressive-image-rendering.html
Pardon the basic question, but I don't quite get how to work with Android Camera class and Parameters.
What I am trying to use Android API to take a picture that will display in a fixed area of my activity. Its about 3inches by 2inches on screen.
Lets say I know that I want a picture that displays in a 360x220px area? I am talking about on the activity size. So I how do I match this up to the accepted picture size of the camera. I mean I see it supports 480x800 and 800x480. This seems to actually be the closest size but its hard to find one thats really matches the display area I have?
So I don't know where to specify that size of picture to take that will look good in that area. Do I specify this during preview? I mean I guess what I thought I could do is preview in same size somehow as the display area I wanted to finally show the picture in? Also how to save it off properly. Should I just pick closest, save and then try to scale? Are there any libraries I should be using for this beside Android SDK?
Sorry about rant. I just have a specific size(I can change it somewhat but I have to fix it and I don't think its 480x800) and I just want to take a picture that will fit in that area, save it load and display it there? How do I do this? I would like a preview that does not take up a bigger area, and a picture that looks just like what is previewed.
Whats happening now is pictures displaying that looked zoomed etc or two small, too big everything but what I want to display.