bitmapfactory

BitmapFactory.decodeFile(String imagePath) returns null even image exists

会有一股神秘感。 提交于 2019-12-11 13:23:24
问题 I don't know , why I am getting null from BitmapFactory.decodeFile(String imagePath) method. imagePath is perfect.Code is below here . public static byte[] imageToByteArray(String imagePath){ Bitmap bitmap = BitmapFactory.decodeFile(imagePath); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.JPEG , 100 , byteArrayOutputStream); return byteArrayOutputStream.toByteArray(); } imaagePath is a internet specific path .Here I am using

How to use bitmap factory to compress image without reduce the quality taken from camera?

不想你离开。 提交于 2019-12-11 11:54:33
问题 I have 3 images taken from camera and I want to set to 3 ImageView. But it throws OutOfMemory because the image has large size. I've read that bitmap factory can compress the size without reducing the quality. The problem is I don't know how to do that. This is my onClick Button: openCameraButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); file = new File(Environment

Android: BitmapFactory.decodeFile / OpenCV does return invaild Bitmap

寵の児 提交于 2019-12-11 08:19:12
问题 I'm taking a picture with the camera activity and then try to read it from the saved location. Unfortunately the Bitmap returnd by: Bitmap bimage = BitmapFactory.decodeFile( path ); has height and width = -1. I'm using OpenCV and when I read the image with Mat img = Highgui.imread(path); I get a proper matrix. Altough I cannot convert it to a bitmap. When doing bmp = Bitmap.createBitmap(img.cols(), img.rows(), Config.ARGB_8888); Utils.matToBitmap(img, bmp); I get the same result again: A

Problem with big images ( java.lang.OutOfMemoryError: bitmap size exceeds VM budget )

℡╲_俬逩灬. 提交于 2019-12-11 05:48:41
问题 as a many people i have a problem with big images too. ok,here my code. I found on stackoverflow how to fix this using BitmapFactory.Options. But in my situations i get image not from file. Can anyone tell me how to do this with Bitmap which already created in memory ( i get this picture from camera on phone) public void getImageAndSend( ) { Bitmap newbmp ; newbmp= Bitmap.createBitmap(oBmp.getWidth(), oBmp.getHeight(),oBmp.getConfig());////<----------error here log("widt oBmp = "+oBmp

Scale selected image in Android image gallery

夙愿已清 提交于 2019-12-11 02:24:26
问题 I have a question regarding scaling down the selected image in image gallery so i can upload it to a server via php. So the order of action are: 1)Get selected image from gallery (DONE) 2)Scale it down and compress it to jpg (Got stucked here) 3)Upload to server async(DONE) I need to connect 1st and 3rd step.So far i have done this: GET SELECTED IMAGE: @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data

Efficient way of creating Bitmap out of Drawable from res (BitmapFactory vs Type Casting)

自作多情 提交于 2019-12-10 20:33:23
问题 Which method is more efficient for creating Bitmap out of Drawable from resources? Bitmap myBitmap = BitmapFactory.decodeResource(context.getResources(), R.drawable.icon_resource); Vs Drawable myDrawable = getResources().getDrawable(R.drawable.icon_resource); Bitmap myBitmap = ((BitmapDrawable) myDrawable).getBitmap(); since API 22 above method is deprecated so use following Drawable myDrawable = ContextCompat.getDrawable(context, R.drawable.icon_resource) 回答1: You can take a look at the

BitmapFactory.decodeFile returns null

旧巷老猫 提交于 2019-12-10 12:15:54
问题 I want to create a Bitmap from a photo that is on the web. First i tried to use BitmapFactory.decodeStream but it returned null because of a bug (http://code.google.com/p/android/issues/detail?id=6066). now i am saving the image an then using BitmapFactory.decodeFile but it still returns null. Any ideas whats wrong or for another workaround? Thank you! try { URL uri = new URL("http://www.witzigundkraus.de/wp-content/uploads/2008/04/scooter-dj-munchen.jpg"); URLConnection connection = uri

Android decode Bitmap from Camera Preview

无人久伴 提交于 2019-12-10 10:58:37
问题 I am trying to get a Bitmap Image from Camera Preview on which I am going to do some processing and draw some overlays after performing Face detection. After looking around, I found out that the byte array that onPreviewFrame takes cannot be decoded into a bitmap directly, it needs to be converted to the correct pixel format using YuvImage, and that's exactly what I did: @Override public void onPreviewFrame(byte[] data, Camera camera) { YuvImage temp = new YuvImage(data, camera.getParameters(

BitmapFactory.decodeStream() returns a Bitmap ~100 times more than original

五迷三道 提交于 2019-12-09 23:57:59
问题 I have a PNG image of 168.2KB and 1991x1756 and tried to import it into a Bitmap using BitmapFactory.decodeStream() . The problem is that I run into OutOfMemoryError where the Bitmap size ends up being 13,657KB. What I don't understand is why is the file so big after the import and how to mitigate this. Seems that this OutOfMemoryError issue is very common with decoded Bitmap images but can't find a way to fix it. Any ideas? Bitmap bitmap = BitmapFactory.decodeStream(inputStream, null,

BitmapFactory.decodeResource() does not get my image from drawable

混江龙づ霸主 提交于 2019-12-08 02:43:34
问题 I want to get image in my bitmap like this : bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.bug); but this show me error on R.drawable.bug that bug can not be resolve or is not a field please tell where I'm doing things wrong. 回答1: Do you have a bug graphic file present in the drawable folder? Have you tried to clean your project in order for R.drawable to be correctly generated? 回答2: Try this: InputStream is = getResources().openRawResource(R.drawable.bug); Bitmap pisc =