bitmapfactory

Android - Picasso misses pictures sometimes

社会主义新天地 提交于 2019-12-24 13:38:18
问题 I am using Picasso library for images downloading using the following code, I've to load many pictures in a loop by resizing them and transforming to circular. Sometimes images are successfully loaded and sometimes onError method is called instead of onSuccess in Callback. And i get this error SkImageDecoder::Factory returned null Error . When i uninstall the app then after reinstalling images are loaded successfully mostly. What is the problem exactly and kindly suggest any solution. Code:

Where do I put the image resource file? BitmapFactory.decodeFile()

孤街浪徒 提交于 2019-12-24 10:58:09
问题 I am trying to use this: BitmapFactory.decodeFile("logo.jpg") and I don't seem to have the file: logo.jpg in the right place in comparison to my apk. where should it go? P.S. the error I get is: Edit I now am using this: >BitmapFactory.decodeResource(getActivity().getResources(),"logo.jpg") and am now getting a compiler error that says: The method getActivity() is undefined for the type Brick (Brick is the name of the class) I don't care which solution works as long as one of them does 回答1: I

Image exists, not null, but I get an NullPointerException on it

允我心安 提交于 2019-12-24 08:30:46
问题 Short introduction The app I am working on at the moment, takes an image from a JSON, if correct it uses it and saves it as a loading image on next use. Problem All of the sudden, the app started crashing on loading and on further inspection, the file.isFile && file.canRead() check I had in place returns positive but it still crashes on BitmapFactory.decodeStream . The byte count of the file is 8k, compared to other devices I've used, where that same image actually has 43k bytes. The image

android equivalent code for graphics2D

寵の児 提交于 2019-12-24 02:23:51
问题 I have been trying to get an android equivalent code for the following :- private BufferedImage user_space(BufferedImage image) { BufferedImage new_img = new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_3BYTE_BGR); Graphics2D graphics = new_img.createGraphics(); graphics.drawRenderedImage(image, null); graphics.dispose(); return new_img; } I want an android equivalent of Graphics2D. I have been searching for a while and found out that Canvas in android can do some

android equivalent code for graphics2D

断了今生、忘了曾经 提交于 2019-12-24 02:23:08
问题 I have been trying to get an android equivalent code for the following :- private BufferedImage user_space(BufferedImage image) { BufferedImage new_img = new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_3BYTE_BGR); Graphics2D graphics = new_img.createGraphics(); graphics.drawRenderedImage(image, null); graphics.dispose(); return new_img; } I want an android equivalent of Graphics2D. I have been searching for a while and found out that Canvas in android can do some

How to keep image quality same in BitmapFactory

冷暖自知 提交于 2019-12-24 00:36:40
问题 I've converted an bitmap image into string to save it: ............ Bitmap photo = extras.getParcelable("data"); ByteArrayOutputStream baos = new ByteArrayOutputStream(); photo.compress(Bitmap.CompressFormat.JPEG, 100, baos); byte[] b = baos.toByteArray(); String encodedImage = Base64.encodeToString(b, Base64.DEFAULT); Then I retrieve the bitmap from string to set an activity's background just like that: byte[] temp = Base64.decode(encodedImage, Base64.DEFAULT); Options options = new

Fastest way to load and display a jpeg on a SurfaceView?

随声附和 提交于 2019-12-23 16:52:04
问题 This is a bit of a followup to my last question: Canvas is drawing too slowly Now that I can draw images more quickly, the problem I am faced with is that the actual loading of the images takes far too long. In the app I am working on, the user is able to play back video frames (jpegs) in succession, as though he is viewing the video in realtime. I have been using BitmapFactory.decodeFile() to load each jpeg in a Bitmap. I'm unable to load all images at once since there are about 240 of them,

Android: Images from XML layout to Bitmaps in Code to solve OOM error

痴心易碎 提交于 2019-12-23 04:28:29
问题 I am getting the infamous java.lang.OutOfMemoryError: bitmap size exceeds VM budget error . I have several XML layouts and a lot of the elements have images (button backgrounds, Linear layout backgrounds, etc.) After going through the questions posted, like Strange out of memory issue while loading an image to a Bitmap object and external allocation too large for this process and OutofMemoryError: bitmap size exceeds VM budget (Android) and Android: Error loading images: OutOfMemoryError:

Compress bitmap to a specific byte size in Android

南笙酒味 提交于 2019-12-19 10:14:41
问题 Is there a way to compress Bitmap to a specific byte size? For example, 1.5MB. The matter is all the examples I have seen so far were resizing width and height, but my requirement is to resize the bytes. Is that possible? Also, what is the most straightforward and right way to compress the Bitmap? I am quite novice to this topic and would like to go right direction from the beginning. 回答1: You can calculate the size of a bitmap quite easily by width * height * bytes per pixel = size Where

Converting Bitmap in memory to Bitmap with Bitmap.Config.RGB_565

白昼怎懂夜的黑 提交于 2019-12-18 11:25:51
问题 I have a loaded Bitmap which I would like to convert to set the config to Bitmap.Config.RGB_565 . Is there a simple way of converting a Bitmap to this configuration after the Bitmap is already loaded into memory? For example, below I have a bitmap being decoded from the application resources, however, how would I convert an already loaded Bitmap to RGB_565 ? I'm sure it's something simple, however, I'm fairly new to working with Bitmaps and after a few hours of looking online, unfortunately I