android-bitmap

Image from gallery rotates automatically - Android

耗尽温柔 提交于 2019-11-29 15:10:51
问题 In my android application i am loading image from device gallery.In that, i am facing issue regarding image orientation. When i load large resolution images from gallery, they are automatically rotated then display in my view. I tried various solution regarding this problem but couldn't get proper solution. I referred getOrientation() , and this links. I have tried both solutions but couldn't got desired result.The ExifInterface return proper data but then also they are not helpful as images

Get Video Thumbnail from Uri

一个人想着一个人 提交于 2019-11-29 14:51:23
I want to select a video from my Gallery. It's working fine. But now I want to display a Bitmap, as a thumbnail.I tired this code it's not working, it always says: NullPointerException Bitmap bitmap2 = ThumbnailUtils.createVideoThumbnail(uri.getPath, MediaStore.Video.Thumbnails.MICRO_KIND); This is all in an onActivityResult. How can I get the Bitmap from the video Uri?? Thanks for your help in onActivityResult String[] filePathColumn = {MediaStore.Images.Media.DATA}; Cursor cursor = context.getContentResolver().query(uri, filePathColumn, null, null, null); cursor.moveToFirst(); int

How to save bitmap to Firebase

自作多情 提交于 2019-11-29 12:07:51
I created a simple application which crop the image . Now I want to save this image to the Fire base . photo.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //Intent imageDownload = new Intent(Intent.ACTION_PICK,MediaStore.Images.Media.EXTERNAL_CONTENT_URI); Intent imageDownload=new Intent(); imageDownload.setAction(Intent.ACTION_GET_CONTENT); imageDownload.setType("image/*"); imageDownload.putExtra("crop", "true"); imageDownload.putExtra("aspectX", 1); imageDownload.putExtra("aspectY", 1); imageDownload.putExtra("outputX", 200); imageDownload.putExtra(

FAILED BINDER TRANSACTION while passing Bitmap from one activity to another

匆匆过客 提交于 2019-11-29 08:45:14
I want to pass a image as a bitmap from one activity to another. And i want to know whether it is possible to do like that. Sending Activity Intent intent = new Intent(getApplicationContext(), BitmapActivity.class); Bundle b = new Bundle(); b.putParcelable("BITMAP", bitmap); intent.putExtras(b); startActivity(intent); Receiving Activity Bundle bb = this.getIntent().getExtras(); b = bb.getParcelable("BITMAP"); But i am getting !!! FAILED BINDER TRANSACTION !!! Error You can use a global class with a static bitmap object in it, something like this: public class Global { static Bitmap img; }

Black edges around the taken screenshot

邮差的信 提交于 2019-11-29 07:58:17
I'm following this example : package com.mtsahakis.mediaprojectiondemo; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.graphics.Bitmap; import android.graphics.Bitmap.CompressFormat; import android.graphics.PixelFormat; import android.graphics.Point; import android.hardware.display.DisplayManager; import android.hardware.display.VirtualDisplay; import android.media.Image; import android.media.ImageReader; import android.media.projection.MediaProjection; import android.media.projection.MediaProjectionManager; import android.os.Bundle;

How to send an image from Android client to Node.js server via HttpUrlConnection?

元气小坏坏 提交于 2019-11-29 02:44:54
I am trying to send an image to the server using HttpUrlConnection, because it's recommended by Google. I decided to convert the image into Base64 string and send it to the server where I decoded it into .jpg file. But this method is only feasible with small-sized thumbnails and I cannot send a full-sized images. Here is the android client code: public static void postData(Bitmap imageToSend) { try { URL url = new URL("http://"); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestMethod("POST"); conn.setDoInput(true); conn.setDoOutput(true); conn

Release Memory of Particular Activity when it is Destroyed

跟風遠走 提交于 2019-11-28 23:11:07
I have a launcher Activity that load and resize big bitmap as it's background when it opens. Whenever hit the back button, the Activity is destroyed . But I think the memory is not released yet. When I open back the app, hit the back button and open it again (repeatedly), I will get a OutOfMemoryError . I am sorry for this newbie question but I am wondering how do I release the memory whenever an Activity is destroyed ? @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_welcome); //MARK - movingBackgroundImageView

Is there a way to get URI of bitmap without saving it to sdcard?

倾然丶 夕夏残阳落幕 提交于 2019-11-28 20:12:54
问题 I am making an app that allows the user to share an image using android intent but how to get that URI of a bitmap without need to saving it to sd card I have used this code that works fine, but I don't need to save this bitmap to sd card private Uri getImageUri(Context inContext, Bitmap inImage) { ByteArrayOutputStream bytes = new ByteArrayOutputStream(); inImage.compress(Bitmap.CompressFormat.JPEG, 100, bytes); String path = Images.Media.insertImage(inContext.getContentResolver(), inImage,

onPictureTaken byte[] small size in some device

ⅰ亾dé卋堺 提交于 2019-11-28 11:41:57
问题 I Creating custom camera app i am using Surfaceview. In my app i capture the picture but it work perfectly in Note 4 and it problematic in xiaomi mobile and i don't the reason why this happen. Note 4 onPictureTaken Byte[] size is original. BUT xiaomi onPictureTaken Byte[] size is always 160x120 Here is my code PictureCallback mPicture = new PictureCallback() { @Override public void onPictureTaken(byte[] data, Camera camera) { final BitmapFactory.Options sizeOptions = new BitmapFactory.Options

How to check if a Bitmap is empty (blank) on Android

橙三吉。 提交于 2019-11-28 10:50:10
How can I check if a Bitmap object is completely blank, i.e. all its pixels are transparent, without a x-y loop on every pixel? You can check your Bitmap instance (in the example myBitmap ) against an empty one with: Bitmap emptyBitmap = Bitmap.createBitmap(myBitmap.getWidth(), myBitmap.getHeight(), myBitmap.getConfig()); if (myBitmap.sameAs(emptyBitmap)) { // myBitmap is empty/blank } 来源: https://stackoverflow.com/questions/28767466/how-to-check-if-a-bitmap-is-empty-blank-on-android