Menu
  • HOME
  • TAGS

Formats supported by BitmapFactory.decodeByteArray(…)

android,android-image

Yes, it's reasonable to assume (a bit more so if you take a peek at the source code of AOSP). The JNI native methods for BitmapFactory are in BitmapFactory.cpp. https://github.com/android/platform_frameworks_base/blob/master/core/jni/android/graphics/BitmapFactory.cpp Since both BitmapFactory.decodeByteArray() and the BitmapDrawable(InputStream) constructor end up calling doDecode(), and since this constructor is used when loading resources...

Android - find image link API

android,android-imageview,android-image

Apparently the Google Search API never was fully deprecated it's still up and running. It provides JSON data and is easily parsed with Android. If anyone else needs an image API here's a test search: https://ajax.googleapis.com/ajax/services/search/images?v=1.0&q=searchquery&rsz=8&start=1&imgsz=small|medium And the JSON reference: https://developers.google.com/image-search/v1/jsondevguide...

android autoscaling images vs custom scaling

android,performance,android-image

I found the best solution for my case. I decided that i will use percentage measurements for my UI elements, so my UI elements won´t be the same physical size on all devices, but my UI will fit on all screens - which is my single goal! Thanks for the...

Issue in Posting Image on php Server in android

android,base64,android-image

encodeToString is not a function in BitmapFactory. You should encode to base64 in a different way. I would like to suggest this answer

Move ImageView To Center Of Screen in android

android,android-animation,android-imageview,android-image,android-windowmanager

I also did something like that and i can manage to do it in onWindowsFocusChanged function. Code is below, I know that you already tried it but maybe you can find something useful from it. @Override public void onWindowFocusChanged(boolean hasFocus) { // TODO Auto-generated method stub super.onWindowFocusChanged(hasFocus); AnimationSet set =...

Download image and resize to avoid OOM errors, Picasso fit() distorts image

android-image,picasso

You can combine fit() with centerCrop() or centerInside(), depending on how you want the image to fit your View: Picasso.with(context) .load(url) .fit() .centerCrop() .into(imgDisplay); Picasso.with(context) .load(url) .fit() .centerInside() .into(imgDisplay); ...

bitmap size exceeds VM budget in some devices

android,android-drawable,android-image,android-bitmap

1. For dealing with Bitmap objects: BitmapFactory.Options options=new BitmapFactory.Options(); options.inSampleSize = 8; options.inDither = false; options.inPurgeable = true; options.inInputShareable = true; Bitmap bitmap = BitmapFactory.decodeStream(is, null, options); Also, you need to use bitmap.recycle(); before you make your Bitmap instances null. This will help save memory. 2. For dealing with images...

How to share both text and image in the share intent (email and gmail)

android,email,android-intent,android-image

You can find ans from below code: Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType("image/jpeg"); emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] {""}); emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, EMAIL_SUBJECT); emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, EMAIL_BODY); emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://"+fileName)); startActivity(Intent.createChooser(emailIntent, "Sharing Options")); Hope this helps.....

Android - Retrieve a path of an picked image

java,android,android-intent,android-image,android-file

You don't necessarily need the absolute file path in order to copy the file, because you can open an InputStream from the Uri directly and copy the contents from that: void copyFileFromUri(Uri sourceUri, String destFilePath) throws IOException { InputStream in = getContentResolver().openInputStream(sourceUri); File outFile = new File(destFilePath); OutputStream out =...

Android Image Compression Without Res Change

android,android-image,image-compression

try Bitmap original = BitmapFactory.decodeStream(getAssets().open("1024x768.jpg")); ByteArrayOutputStream out = new ByteArrayOutputStream(); original.compress(Bitmap.CompressFormat.PNG, 100, out); Bitmap decoded = BitmapFactory.decodeStream(new ByteArrayInputStream(out.toByteArray())); from How to make Bitmap compress without change the bitmap size?...

How to get ImageView image size (Android)

android,android-imageview,android-image

Don't use image sizes as a validation for similarity. Instead compare the images. The simplest way is to iterate over every pixel and compare the RGB value. But this will give you only a valid answer if the images are really to 100% equal. If you like to detect similarity...

Converting Image to bytearray in order to upload image to server Android

android,android-image,android-bitmap,android-service-binding

public static byte[] toByteArray (Bitmap raw) { byte[] byteArray = null; try { ByteArrayOutputStream stream = new ByteArrayOutputStream (); raw.compress (Bitmap.CompressFormat.JPEG, 100, stream); byteArray = stream.toByteArray (); } catch (Exception e) { e.printStackTrace (); } return byteArray; } ...

Display captured image

android,eclipse,android-intent,android-image

Instead of this: Bundle extras = intent.getExtras(); Bitmap bBitMap = (Bitmap) extras.get("data"); Try using: File file = new File(Environment.getExternalStorageDirectory(),"breakfast.jpg"); ImageView bThumbnail = (ImageView)findViewById(R.id.bThumbnail); Bitmap bBitMap = decodeSampledBitmapFromFile(file.getAbsolutePath(), 1000, 700); bThumbnail.setImageBitmap(bBitMap); decodeSampleBitmapFromFile method: public static Bitmap decodeSampledBitmapFromFile(String path, int reqWidth, int reqHeight) { // BEST QUALITY MATCH // First decode with...

load image with image-chooser-library

android,android-image

That is a Uri. A Uri is not a file, and so you cannot pass it to decodeFile() on BitmapFactory. Either use an image loading library like Picasso or Universal Image Loader, or have your own background thread that uses openInputStream() on a ContentResolver to read in the contents of...

fetch the path of an image stored in gallery after camera capture

android,android-image

Define custom methods for set and get captured image path : private String imgPath; public Uri setImageUri() { // Store image in dcim File file = new File(Environment.getExternalStorageDirectory() + "/DCIM/", "image" + new Date().getTime() + ".jpg"); Uri imgUri = Uri.fromFile(file); imgPath = file.getAbsolutePath(); return imgUri; } public String getImagePath() {...

How to zip multiple images and post to server using google recommended HTTPURLConnection? [closed]

android,httpurlconnection,android-image

Gzip compresses only streams and doesn't maintain a directory of files. You could use "java.util.zip.*" or JTar to tar the files and then Gzip. Depends on what you have server-side. This should be restricted only by bandwidth. Restrictions might exist on server-side (php.ini e.g.), not for Android Multi-Part might...

Android Image Slider cannot hide page indicator

android,slideshow,android-image

I solved this issue by writing my a custom ImageSlider, as specified here I love this library!

android reservation system app

android,android-imageview,android-image,android-imagebutton

I'm adding this as an answer, as it seems this is really the right way to go. Set up a relative layout. You don't need an actual graphic of the floor plan. That would complicate things in terms of screen sizes. You will almost certainly have to allow for landscape/portrait...

Switching images with a delay

android,loops,delay,android-image

You should restart your Handler.postDelayed inside the runnable to make it work. Something like: final Handler handler = new Handler(); handler.postDelayed(new Runnable() { private boolean useDiceOne; @Override public void run() { ImageView image = (ImageView)findViewById(R.id.imgView_dice0); if (!useDiceOne) { image.setImageResource(R.drawable.dice_6); } else { image.setImageResource(R.drawable.dice_1); } useDiceOne = !useDiceOne; handler.postDelayed(this, 3000); }...

Android Image Zoom and Pan in jelly bean

android,android-image,android-4.2-jelly-bean

in jelly bean i have to invalidate my image view once i set a new matrix for it. ImageView.postInvalidate(); in kitkat no need of invaliding....

Image loading using picasso on disk

android,caching,android-image,picasso

Try removing .networkPolicy(NetworkPolicy.NO_CACHE) and adding NO_STORE to memoryPolicy .memoryPolicy(MemoryPolicy.NO_CACHE, MemoryPolicy.NO_STORE)

Show image in textview using Html.fromhtml();

android,html,android-image

You can draw an Image in TextView using the Html img tag with Html.ImageGetter. But make sure your image is available in resource drawable folder Here is a sample , The image will be loaded from the resource. String htmlText = "Hai <img src=\"ic_launcher\"> Hello"; textView.setText(Html.fromHtml(htmlText, new Html.ImageGetter() { @Override...

Convert encoded base64 image to File object in Android

java,android,image,blob,android-image

You'll need to save the File object to disk for that to work. This method will save the imageData string to disk and return the associated File object. public static File saveImage(final Context context, final String imageData) { final byte[] imgBytesData = android.util.Base64.decode(imageData, android.util.Base64.DEFAULT); final File file = File.createTempFile("image", null,...

The method startActivityForResult(Intent, int) is undefined for the type ABC

android,android-layout,android-image,android-alarms,android-layout-weight

Accept the context inside the non-activity class and cast it into Activity private Context context; private Activity activity; public Example(Context context) { this.context = context; this.activity = (Activity) context; } Then call it where ever you want activity.startActivityForResult() And if you want to get result later there itself, define a...

How to compress image before uploading to server

android,android-image

You can use below to compress bitmap for jpeg images Bitmap original = BitmapFactory.decodeStream(getAssets().open("imagg1.jpg")); ByteArrayOutputStream out = new ByteArrayOutputStream(); original.compress(Bitmap.CompressFormat.JPEG, 100, out); Bitmap decoded = BitmapFactory.decodeStream(new ByteArrayInputStream(out.toByteArray())); and for png images Bitmap original = BitmapFactory.decodeStream(getAssets().open("imagg1.png")); ByteArrayOutputStream out = new ByteArrayOutputStream(); original.compress(Bitmap.CompressFormat.PNG, 100,...

Should we set background in LayoutView or ImageView in Android?

android,android-layout,android-imageview,android-drawable,android-image

I would stick with approach #1, if I just wanted to have a simple background for my layout. Note that you have more than just that method you are referring for applying a background over a LayoutView, like: myLayout.setBackgroundColor(int color); myLayout.setBackgroundDrawable(Drawable d); myLayout.setBackgroundResource(int resid); Now, the reasons for choosing approach...

set image taken by camera in android?

android,matrix,bitmap,android-image

There are several methods available over stackoverflow but i am using a mixture of them, if you want the image to be in the orientation it was captured you can use the following instruction and classes to do this Your onActivityResult @Override public void onActivityResult(int requestCode, int resultCode, Intent data)...

Android: Does a bitmap created by my app have to be stored and scanned before I can pass it as an implicit intent to other apps?

android,android-intent,android-image,android-bitmap,android-implicit-intent

No, you dont need to save that image anywhere. Just get the filepath from the Bitmap: String path = Images.Media.insertImage(context.getContentResolver(), bitmap,"abcd", null); then get a valid Uri from it: Uri image = Uri.parse(path); and add this Uri to your Intent like this: intent.putExtra(Intent.EXTRA_STREAM, image); Done!...

Android set wallpaper of home screen with centering the image

android,android-image,universal-image-loader,android-bitmap,android-wallpaper

After several attempts, I managed to achieve the desired effect. public class SystemWallpaperHelper { private Context context; private ImageLoader imageLoader; private DisplayImageOptions imageLoaderOptions; private WallpaperManager wallpaperManager; public SystemWallpaperHelper(Context context) { this.context = context; setImageLoaderOptions(); wallpaperManager = WallpaperManager.getInstance(context); } private void setImageLoaderOptions() { imageLoaderOptions = new DisplayImageOptions.Builder() .imageScaleType(ImageScaleType.NONE)...

Eclipse-ADT issues about No resource found that matches the given name

android,eclipse,adt,android-image,eclipse-adt

I myself found the solution for this, just upgraded the version to Eclipse Luna and reinstalled SDK manager.Inside that installed API20 ie Android 4.4w.2.Now all are working fine. Thankyou for all who replied.....

Image size inside TextView

android,android-textview,android-image

I think you already knew the solution. In your code drawable.setBounds(0, 0, 0 + drawable.getIntrinsicWidth(), 0 + drawable.getIntrinsicHeight()); Just set the bound of your drawable like this drawable.setBounds(0, 0, 0 + MAX_WIDTH, 0 + MAX_HEIGHT); If you want to scale the image , I think you could do some math...

Android null pointer exception with camera images

android,android-image,android-externalstorage

Call for camera activity using below code: Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); File f = new File(android.os.Environment .getExternalStorageDirectory(), "temp.jpg"); intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(f)); startActivityForResult(intent, REQUEST_CAMERA); In onActivityResult if (resultCode == RESULT_OK) { if (requestCode == REQUEST_CAMERA) { File f = new File(Environment.getExternalStorageDirectory() .toString()); for (File temp : f.listFiles()) { if (temp.getName().equals("temp.jpg")) {...

open and save same image again on android

android,android-image

BitmapFactory.decodeFile always returns an immutable bitmap. Use Bitmap.copy to make a copy of bitmap which is mutable. Now perform modifications on the copied bitmap. Bitmap bm = BitmapFactory.decodeFile(pathiki).copy(Bitmap.Config.ARGB_8888, true); Update the exception handler code. Either log e.getMessage() to logcat or use e.printStackTrace()....

unable to display high resolution pictures inside ImageView

android,android-imageview,android-image

Add this method public Bitmap decodeImage(int resourceId) { try { // Decode image size BitmapFactory.Options o = new BitmapFactory.Options(); o.inJustDecodeBounds = true; BitmapFactory.decodeResource(getResources(), resourceId, o); // The new size we want to scale to final int REQUIRED_SIZE = 100; // you are free to modify size as your requirement //...

How to upload image to Parse in android?

android,parse.com,android-imageview,image-uploading,android-image

reading your answer : I already followed the code that you have before. I was able to upload the image to parse. but I dont know how to switch the drawable source to be my image from camera/gallery or imageview. – stanley santoso to : Abhishek Bansal I understand that...

Compressing Image Selected From Device Android

android,android-image,android-camera-intent

I hope the function I writes will help you. public Bitmap getResizedBitmap(Bitmap bm, int newHeight, int newWidth) { int width = bm.getWidth(); int height = bm.getHeight(); float scaleWidth = ((float) newWidth) / width; float scaleHeight = ((float) newHeight) / height; // CREATE A MATRIX FOR THE MANIPULATION Matrix matrix =...

Android detect if there is colour white on image and display toast

android,android-image,android-toast

First of all, you need to get the file path of your image from sdcard. String baseDir = Environment.getExternalStorageDirectory().getAbsolutePath(); String filePath = baseDir + "/your_file_name.jpg"; Bitmap bitmap = BitmapFactory.decodeFile(filePath); Now you have a bitmap. You can check every pixels in it. int w = bitmap.getWidth(); int h = bitmap.getHeight(); for(int...

piccasso square not rendering images

android,android-fragments,android-arrayadapter,android-image

Move: mGridView =(GridView) rootView.findViewById(R.id.imagesGrid);//reference to gridview ImagesGridAdapter adapter = new ImagesGridAdapter(getActivity(),mSmalImagesUrls); mGridView.setAdapter(adapter); To: @Override public void onResponse(Response response) throws IOException { try { String jsonData = response.body().string(); Log.v(TAG, jsonData); if (!response.isSuccessful()) { alertUserAboutError(); } else { mSmalImagesUrls = getCurrentDetails(jsonData); //Move it here getActivity().runOnUiThread(new Runnable(){ @Override public void...

Error: android.view.InflateException: Binary XML file line #26: Error inflating class com.android.camera.CropImageView

android,android-imageview,android-image

You have com.android.camera.CropImageView in your crop_selector XML layout but such a view class doesn't exist in the platform. (There's one in the Gallery app but you shouldn't be using it like this. There's no guarantees that manufacturers include particular platform apps. Usually they want to replace them with their own....

Sending Image From Android to C# webservice

c#,android,web-services,encoding,android-image

I figure it out I didn't Canvas it before sending it to server. use this too Canvas canvas = new Canvas(mBitmap); v.draw(canvas); public void save(View v) { mBitmap = Bitmap.createBitmap(v.getWidth(), v.getHeight(), Bitmap.Config.RGB_565); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); mBitmap.compress(Bitmap.CompressFormat.JPEG,40, outputStream); byte[] imgByte = outputStream.toByteArray(); String base64Str = Base64.encodeToString(imgByte, Base64.DEFAULT); Canvas canvas...

Would storing many images in an Android apk file be viable for a social app

android,android-image

What most of the Social media apps do is that they SYNC the data. Thats what you need to do. Don't add images in the application .Rather get the External Storage location/ path in the phone .Refer this Question and this Question and this link. And then when the user...

Get Image from gallery cause no activity found error in activity resulte

android,android-image,android-gallery,activitynotfoundexception

try:- Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); startActivityForResult(Intent.createChooser(intent, "Select Picture"), RESULT_LOAD_IMAGE); ...

Check if the device supports webP image format

android,android-image,webp

As far as I know there is no API for this. So solution is to try to decode some webp image on device and check if it returns Bitmap. This can be implemented like this: import android.graphics.Bitmap; import android.graphics.BitmapFactory; public class WebPUtils { //states private static final int NOT_INITIALIZED =...

taken from android camera image original resolution

android,android-image

Bitmap photo = (Bitmap) data.getExtras().get("data"); this code gives you only thumnail image.To get the original image u need to use EXTERNAL_STORAGE which image saved there. (Code is something like this) File storageDir = Environment.getExternalStoragePublicDirectory( Environment.DIRECTORY_PICTURES); For more information take a look at here...

Create Same Size Image Across Various Android Densities

android,android-layout,image-manipulation,android-image

You have to add images of various dimensions in various drawable folder viz- drawable-ldpi,drawable-mdpi and so on. And the image dimension ratio will be: Taking mdpi as a base your ldpi will be 0.75 times of mdpi hdpi - 1.5 times of mdpi xhdpi - 2 times of mdpi xxhdpi...