android-image

DiskLruCache from android tutorial is missing lots of methods.

若如初见. 提交于 2019-11-28 21:33:50
Here is the disk cache tutorial I'm following. I've downloaded the source code to DiskLruCache but none of the methods used in this example exist in the source code. http://developer.android.com/training/displaying-bitmaps/cache-bitmap.html#disk-cache Do I need to implement these methods myself or is there a version of DiskLruCache that I'm missing somewhere? Here is the complete implementation of DiskLruCache . First download DiskLruCache.java from AOSP. Here is my DiskCache.java a helper class for basic cache operations. /** * Created by Babar on 12-Aug-15. */ public class DiskCache {

How to add image effects in android ?

孤街浪徒 提交于 2019-11-28 21:16:56
问题 I am trying to apply effect (sepia, brightness, bloom and other image effects if API for them is available) on an image for my android app. But I am totally unable to get precise and well mannered code or concept for solving such problem. Although Android 4.0 (API 14) have build in android.media.effect api in it but I am working in Android 2.1 which have only Bitmap, Drawable, DrawableBitmap e.t.c but i am not getting which to work with. 回答1: I have written lots of image effects here, you can

Disable Android resource / image / PNG optimization

左心房为你撑大大i 提交于 2019-11-28 20:29:27
How do I prevent the Android "build process" from optimizing .png images? I have an Android project with the following res directories: - /res/ - /res/drawable - /res/drawable-hdpi - /res/drawable-hdpi-v5 - /res/drawable-ldpi - /res/drawable-ldpi-v5 - /res/drawable-mdpi - /res/drawable-mdpi-v5 These directories contain many .png files . I optimize PNG sizes with PNGOUTWin, and the overall size is reduced by more than 20%. When I build the .apk file, the images are "optimized" by the build process and the overall size is now 10% above the initial size , or 30% above my/PNGOUTWin optimized size.

How do I prepare images for all the Android resolutions?

馋奶兔 提交于 2019-11-28 16:47:51
问题 In iOS preparing graphics is simple. There are either a normal image (height x width) or a retina image which is @2x (2 times height x 2 times width). However, since I'm new to Android, I see a ton of drawable-* folders in Eclipse where the * can be "hdpi" or "ldpi" or "mdpi" or "xhdpi" or "xxhdpi". Can someone very clearly and simply list for me what I must do to satisfy each of the display possibilities so my images will look right in each instance? I'm envisioning an answer will be a

android.os.NetworkOnMainThreadException

徘徊边缘 提交于 2019-11-28 12:58:49
In my application am getting android.os.NetworkOnMainThreadException . I am trying to get images from url at that time i am getting this Exception . If i run application in 2.2 it is working fine but if i run in 4.0 am getting exception. public static Bitmap getBitmap(String url) { Bitmap bitmap = null; try { // replace space with url encoded character. url = url.replace(" ", "%20"); // System.out.println("url : " + url); URL urll = new URL(url); InputStream in = (InputStream) urll.getContent(); bitmap = BitmapFactory.decodeStream(in); } catch ( MalformedURLException e ) { e.printStackTrace();

How to scale an image down in android

谁说胖子不能爱 提交于 2019-11-28 11:50:15
I am creating an android application and I can add an image. However, what I want to do is scale down the image to fit the ImageButton size. Is there any way to do that? The code I have written so far: package awad865.project.ContactManager1; import java.io.FileNotFoundException; import java.io.InputStream; import android.app.Activity; import android.content.Intent; import android.database.SQLException; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.drawable.BitmapDrawable; import android.net.Uri; import android.os.Bundle; import android.support

Bitmap from ImageReader always blank when trying to capture screen

我是研究僧i 提交于 2019-11-28 10:26:28
问题 Using the MediaProjection API for screen capture, I create an ImageReader and feed use it as a point of access for captured screens as below: mImageReader = ImageReader.newInstance(mWidth, mHeight, ImageFormat.JPEG, 2); and mImageReader.setOnImageAvailableListener(new ImageReader.OnImageAvailableListener() { @Override public void onImageAvailable(ImageReader reader) { Image image = null; Bitmap bitmap = null; image = mImageReader.acquireLatestImage(); Image.Plane[] planes = image.getPlanes();

Crop saved Image using com.android.camera.action.CROP on android

橙三吉。 提交于 2019-11-28 09:07:45
问题 I have reads many question about this, but I still failed using this code... maybe anyone can corect my code... I want to crop an image from file that i know the location using com.android.camera.action.CROP like this... mImageCaptureUri = Uri.fromFile(f); Intent intent = new Intent("com.android.camera.action.CROP"); intent.setType("image/*"); intent.setData(mImageCaptureUri); intent.putExtra("crop", true); intent.putExtra("outputX", 200); intent.putExtra("outputY", 200); intent.putExtra(

how to reduce large image size to thumbnail size in android

筅森魡賤 提交于 2019-11-28 08:47:49
in my app, i have large images, i display it in an image view by hard code the size as 60 X 60 dp. how to reduce the image size as image thumb nail size in android. is there programmatic way. because suppose i run my app in various resolution size design layout may get differ. my need is if i run my app in any resolution device image size should not get differ. how to do that in android. please help me. i hard code image by the following code. <ImageView android:id="@+id/img" android:layout_width="60dp" android:layout_height="60dp" android:layout_centerVertical="true" /> Rohit Mandiwal Most

How To Convert A Bitmap Image To Uri

拈花ヽ惹草 提交于 2019-11-28 06:15:30
问题 I have not found the answer to this question anywhere. The Bitmap Image is processed in The application, meaning there is no File path to get the Image. Below is how to convert a Uri to Bitmap if (requestCode == RC_PHOTO_PICKER && resultCode == RESULT_OK) { Uri selectedImageUri = data.getData(); imageview.setImageURI(selectedImageUri); try { bitmap1 = MediaStore.Images.Media.getBitmap(this.getContentResolver(), selectedImageUri); } catch (IOException e) { e.printStackTrace(); Toast.makeText