android-bitmap

How to get the height and width of an ImageView/Bitmap in Android

天涯浪子 提交于 2019-12-17 17:44:44
问题 I want to get the height and width of an image bitmap that is either in ImageView or a background image. Please help me, any help will be appreciated. 回答1: You can get height and width of ImageView by using getWidth() and getHeight() through while this will not give you the exact width and height of the image, for getting the Image width height first you need to get the drawable as background then convert drawable to BitmapDrawable to get the image as Bitmap from that you can get the width

Image loses it's original result when passing it to another activity

我怕爱的太早我们不能终老 提交于 2019-12-17 10:07:16
问题 I am working on a camera feature in my application. I am capturing an image and passing it to another activity. The problem that I'm facing is when I display the image in another activity it loses its original result (gets pixilated) for some reason. This is how I'm doing it: private void takePhotoFromCamera() { if(ActivityCompat.checkSelfPermission(EnterDataView.this, Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED){ Intent cameraIntent = new Intent(android.provider

Android- how can I convert android.net.Uri object to java.net.URI object?

爷,独闯天下 提交于 2019-12-17 07:17:06
问题 I am trying to get a FileInputStream object on an image that the user selects from the picture gallery. This is the android URI returned by android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI content://media/external/images/media/3 When I try to construct a java URI object from this object, I get an IllegalArgumentException with the exception description Expected file scheme in URI: content://media/external/images/media/3 whereas the android URI shows the scheme as content Update :

Android Bitmap to Base64 String

喜你入骨 提交于 2019-12-17 02:29:08
问题 How do I convert a large Bitmap (photo taken with the phone's camera) to a Base64 String? 回答1: use following method to convert bitmap to byte array: ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.PNG, 100, byteArrayOutputStream); byte[] byteArray = byteArrayOutputStream .toByteArray(); to encode base64 from byte array use following method String encoded = Base64.encodeToString(byteArray, Base64.DEFAULT); 回答2: I have fast

“Bitmap too large to be uploaded into a texture”

廉价感情. 提交于 2019-12-17 01:34:19
问题 I'm loading a bitmap into an ImageView, and seeing this error. I gather this limit relates to a size limit for OpenGL hardware textures (2048x2048). The image I need to load is a pinch-zoom image of about 4,000 pixels high. I've tried turning off hardware acceleration in the manifest, but no joy. <application android:hardwareAccelerated="false" .... > Is it possible to load an image larger than 2048 pixels into an ImageView? 回答1: All rendering is based on OpenGL, so no you can't go over this

Intent seems not sent between activity

笑着哭i 提交于 2019-12-14 04:09:30
问题 I have wrote an app with 2 activities. One activity took a picture and the second one use it with some filters. Activity 1: Intent FilterSelectionIntent = new Intent(getActivity(), PulsFiltersActivity.class); FilterSelectionIntent.putExtra("PicTaken", currentBitmap); startActivity(FilterSelectionIntent); Acitivity 2: Bundle bd = intent.getExtras(); mBitmap = bd.getParcelable("PicTaken"); I have put some breakpoints in the Activity 2 and it never stop at. As soon as I comment the "putExtra" in

Android never call method onCreateThumbnail

点点圈 提交于 2019-12-13 20:22:13
问题 Based on Android documentation, method onCreateThumbnail is called before pausing the activity, and should draw into outBitmap the imagery for the desired thumbnail in the dimensions of that bitmap. It can use the given canvas , which is configured to draw into the bitmap, for rendering if desired. The default implementation returns fails and does not draw a thumbnail; this will result in the platform creating its own thumbnail if needed. When the method returns true , system will not use a

Android, Java: Improve quality of Bitmap with getDrawingCache()

拈花ヽ惹草 提交于 2019-12-13 04:36:02
问题 I have a dialog and convert it to a bitmap . Then I want so send it with the Sharing Intent: Bitmap cs = null; v1.setDrawingCacheEnabled(true); v1.buildDrawingCache(true); cs = Bitmap.createBitmap(v1.getDrawingCache()); Canvas canvas = new Canvas(cs); v1.draw(canvas); canvas.save(); v1.setDrawingCacheEnabled(false); String path = Images.Media.insertImage(getContext().getContentResolver(), cs, "MyImage", null); Uri file = Uri.parse(path); Intent sharingIntent = new Intent(Intent.ACTION_SEND);

Android, out of memory converting to black and white

戏子无情 提交于 2019-12-13 02:26:21
问题 I'm converting some resources to black and white when user touch them. I have this function to do this in my Util java file: public static Bitmap convertColorIntoBlackAndWhiteImage(Bitmap orginalBitmap) { ColorMatrix colorMatrix = new ColorMatrix(); colorMatrix.setSaturation(0); ColorMatrixColorFilter colorMatrixFilter = new ColorMatrixColorFilter(colorMatrix); Bitmap blackAndWhiteBitmap = orginalBitmap.copy(Bitmap.Config.ARGB_8888, true); Paint paint = new Paint(); paint.setColorFilter

Converting bitmap to Base64 string causes OutOfMemory error

偶尔善良 提交于 2019-12-13 02:25:35
问题 I'm currently using the following method to convert a bitmap into a Base64 encoded string, however for very big images I'm getting an OutOfMemory error: public static String convertBitmapToBase64String(Bitmap bmp) throws OutOfMemoryError { ByteArrayOutputStream baos = new ByteArrayOutputStream(); bmp.compress(Bitmap.CompressFormat.JPEG, 100, baos); byte[] byteArrayImage = baos.toByteArray(); String base64EncodedImg = Base64.encodeToString(byteArrayImage, Base64.DEFAULT); return