FAQ Database Discussion Community


Set TransitionDrawable with ImageView ScaleType

android,android-animation,android-drawable,android-bitmap,transitiondrawable
I have got this code to crossfade the background of an ImageView: private void setWithCrossfade(Bitmap bitmap) { //create drawable vector Drawable backgrounds[] = new Drawable[2]; //getting first image backgrounds[0] = mImageView.getDrawable(); backgrounds[1] = new BitmapDrawable(mImageView.getResources(), bitmap); TransitionDrawable transitionDrawable = new TransitionDrawable(backgrounds); transitionDrawable.setCrossFadeEnabled(true); mImageView.setAdjustViewBounds(false); mImageView.setImageDrawable(transitionDrawable); //it is needed to...

bitmap size exceeds VM budget in some devices

android,android-drawable,android-image,android-bitmap
I am doing android app, works fine in a device with 3Gb Ram but bad in a device with 512 mbRam. I am getting error "bitmap size exceeds VM budget" I don´t know how solve it. This is my layout´s code that uses many drawables. <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"...

Can't apply a colorFilter to text selection handles

android,material-design,nine-patch,android-bitmap
I'm trying to bring material text selection handles to my app. I got drawables from the SDK for middle/right/left handle (bitmaps) and text cursor (9-patch), and set: <item name="android:textSelectHandleLeft">@drawable/text_select_handle_left_mtrl_alpha</item> <item name="android:textSelectHandleRight">@drawable/text_select_handle_right_mtrl_alpha</item> <item name="android:textSelectHandle">@drawable/text_select_handle_middle_mtrl_alpha</item> <item...

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

android,android-image,android-bitmap,android-service-binding
I have image's sd card path. Now what are the next steps to convert image into byte array because I want to upload the image to server? Thanks in advance....

Android BitmapDrawable results in out of memory

android,android-bitmap,bitmapdrawable
Basically I have 4 ImageView in the UI and I want to set image to them. Following is the related codes: private void showPhoto() { // (re)set the image button's image based on our photo Photo p = mCrime.getPhoto(); BitmapDrawable b = null; if (p != null) { String path...

How much memory is allocated to this Bitmap?

android,android-bitmap
I'm not quite sure how much memory will be allocated to the following variable "bitmap", Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.mipmap.example); bitmap = Bitmap.createScaledBitmap(bitmap, 100, 100, true); Say, the dimension of the original image is 1024*768 and some memory has been allocated to the bitmap. Then the bitmap was scaled to...

OOM when creating Bitmaps on an Android application

android,out-of-memory,android-bitmap
I have an application that gets a fixed amount of images from the camera preview and converts them into a list of Bitmaps. For that purpose I have the following code: private Camera.PreviewCallback SetPreviewCallBack() { return new Camera.PreviewCallback() { @Override public void onPreviewFrame(byte[] data, Camera camera) { List<Bitmap> imageList =...

How to set an image on imageView from the gallery and image taken by camera in Android?

android,android-intent,android-imageview,android-bitmap
In my app I want to set an image on a Image View from gallery and I want to set an image which is taken by the camera.I have tried this code ,but when I load image from gallery ,it is working.But when I try to take a picture to...

getWidth() function in bitmap library of android doesn't return true image height

android,width,renderscript,android-bitmap
I wanted to load an .PNG image through my android application by using android.graphics.Bitmap library. I have succeeded to load it but there is some problem i can't figure out. My image pixel count is 144*144 but when i try to get the width of my loaded image by using...

andriod out of memory exception

android,out-of-memory,assets,bitmapfactory,android-bitmap
please help in solving me this out of memory exception as i am unable to solve it, any help would be greatly appreciated, 06-04 12:11:44.119: E/AndroidRuntime(9090): FATAL EXCEPTION: main 06-04 12:11:44.119: E/AndroidRuntime(9090): Process: com.zar.bdr, PID: 9090 06-04 12:11:44.119: E/AndroidRuntime(9090): java.lang.OutOfMemoryError 06-04 12:11:44.119: E/AndroidRuntime(9090): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method) 06-04 12:11:44.119: E/AndroidRuntime(9090): at...

unable to decode stream while selecting an image

android,image,decode,android-bitmap
While selecting an image from a gallery in my application it doesn't crash but instead its unable to decode the stream of the path. Taking the picture directly from the camera is working fine but from the gallery its not here is my code in my activity result . //enter...

Android: Can we create bitmaps with Strings on it on the application runtime?

android,bitmap,android-bitmap,android-runtime
I want to create a Bitmap with some string data on it, and later send it to my mobile printer. How can we do that?...

Faster alternative for getPixel and getPixel in Android Bitmap?

android,performance,android-ndk,android-bitmap,renderscript
I'm using the methods getPixel and setPixel for my Bitmap and it's so slow (getPixels too). I want to process every pixel of the Bitmap and then create another Bitmap. How can I get access to pixels by RenderScript or using C++? I think they are faster but I don't...

How to display Photograph without distortion in Android Application

android,android-bitmap,bitmapfactory
My current Android Application allows the user to select any photograph they have on their device. I use this code to display all photographs to allow user selection final Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); startActivityForResult(Intent.createChooser(intent, "Select Picture"), SELECT_PICTURE); Once the photograph has been selected, i display it within...

Android edit images on the fly

android,opencv,bitmap,android-bitmap,opencv4android
It seems that in Android there are no "easy" libraries for editing and save pictures, neither free or with licenses). Aviary is no longer available. I have to implement an app for Taking picture, edite with some effects on the fly (Vignetting contrast, brightness...), add some text and save. A...

Bitmap not showing up on canvas

android,android-canvas,surfaceview,android-bitmap
I have canvas that I am drawing a bitmap on. I set the dimensions of the canvas and bitmap to variables and printed out their respective values. When I try to draw the bitmap it does not show up. Code for SurfaceView: protected void onDraw(Canvas canvas) { if (canvas !=...

Draw image inside a View without subclassing

android,canvas,bitmap,android-canvas,android-bitmap
Can I draw a image inside a view without subclassing ? I have tried: TextView texto = (TextView) viewGroup.findViewWithTag("text"); Paint p = new Paint(); p.setColor(Color.WHITE); Bitmap b = BitmapFactory.decodeResource(getResources(), R.mipmap.ic_lanc); Bitmap b2 = b.copy(Bitmap.Config.ARGB_8888, true); Canvas c = new Canvas(b2); c.drawBitmap(b, 1, 1, p); textView.draw(c); Someone can help me?...

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
Introduction and background Hi, I have a bitmap created by my application, I wish for this bitmap to be sent to any apps that can handle the mime type "image/png" and the action ("ACTION_SEND"). Basically, allow the bitmap image to be sent to someone by another component like email and...

How to set an image taken by the camera in to an imageview.?

android,android-camera,android-bitmap
I am using camera 2 API for creating my own camera ,I want to set the image taken by the camera in to an imageView ,which is on another activity.I have tried this code but it is not working.when clicking the camera button the photo is saved to an sdcard...

How does a bitmap cache work?

android,caching,bitmap,android-bitmap
Can someone explain the difference between a method like this and a bitmap cache? Don't they both just load it into memory? Which one is more efficient? public static Bitmap loadBitmap(String filename, boolean transparency) { InputStream inputStream = null; try { inputStream = GameMainActivity.assets.open(filename); } catch (IOException e) { e.printStackTrace();...

Undo in the drawing canvas in android [closed]

android,android-layout,canvas,android-bitmap
I was working on the undo operation in android. The problem is , currently the bitmap is not set and I can not draw on it. Here is my code , which is extract from extended imageview: private ArrayList<Path> paths = new ArrayList<Path>(); private Path mPath; public ScaleImageView(Context context) {...

How to position bitmap using drawBitmap in android canvas

android,android-canvas,android-bitmap
I want to position two bitmaps next to each other using drawBitmap() in Canvas, Android. My onDraw() function. protected void onDraw(Canvas canvas) { if (currentState == openedState) { fruit1Bitmap = ApplicationServices.textureManager.bitmap[fruitId[0]]; fruit2Bitmap = ApplicationServices.textureManager.bitmap[fruitId[1]]; fruit3Bitmap = ApplicationServices.textureManager.bitmap[fruitId[2]]; src.set(0, 0, fruit1Bitmap.getWidth(), fruit1Bitmap.getHeight()); dst.set(0,0, this.getWidth()/2, this.getHeight()/2); src1.set(0, 0,...

How to get Bit Depth of a Bitmap on Mono For Android

bitmap,monodroid,android-bitmap
In .NET one way to check the bitdepth of a Bitmap image is using the Bitmap class like so: switch (bitmap.PixelFormat) { case System.Drawing.Imaging.PixelFormat.Format1bppIndexed: return 1; case System.Drawing.Imaging.PixelFormat.Format4bppIndexed: return 4; case System.Drawing.Imaging.PixelFormat.Format8bppIndexed: return 8; case System.Drawing.Imaging.PixelFormat.Format16bppArgb1555: case System.Drawing.Imaging.PixelFormat.Format16bppGrayScale: case System.Drawing.Imaging.PixelFormat.Format16bppRgb555: case...