imageview

Save image from ImageView to device gallery

两盒软妹~` 提交于 2019-12-01 18:51:38
I'm trying to save an image from ImageView to devices gallery. I tried this code Code Edit: URL url = new URL(getIntent().getStringExtra("imageURL")); File f = new File(url.getPath()); addImageToGallery(f.getPath(), this); public static void addImageToGallery(final String filePath, final Context context) { ContentValues values = new ContentValues(); values.put(MediaStore.Images.Media.DATE_TAKEN, System.currentTimeMillis()); values.put(MediaStore.Images.Media.MIME_TYPE, "image/jpeg"); values.put(MediaStore.MediaColumns.DATA, filePath); context.getContentResolver().insert(MediaStore.Images.Media

How to display a blob image in Android?

时间秒杀一切 提交于 2019-12-01 18:47:33
I want to display an image which is saved into database in blob form on my Android. I am using ImageView as image container. Please suggest me something soon. Regards, Rahul Basically there are two options: Buffer read from BLOB wrap in InputStream so you will have InputStream which will point to BLOB data Save BLOB data to temporary file open it as FileInputStream - so in the end you'll again have stream over image data in both cases you can easily convert InputStream to bitmat data in a way: InputStream is; //stream pointing to your blob or file //... imageView=new ImageView(this); imageView

app:srcCompat - Vector drawable shows up in design preview, but doesn't show up in app

我怕爱的太早我们不能终老 提交于 2019-12-01 18:09:27
drawable/information.xml <vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp" android:viewportWidth="24.0" android:viewportHeight="24.0"> <path android:fillColor="#FF000000" android:pathData="M13,9H11V7H13M13,17H11V11H13M12,2A10,10 0,0 0,2 12A10,10 0,0 0,12 22A10,10 0,0 0,22 12A10,10 0,0 0,12 2Z"/> </vector> LayoutofCardView.xml <ImageView android:layout_width="24dp" android:background="#f00" android:layout_height="24dp" android:id="@+id/informationImageView" app:srcCompat="@drawable/information" tools:src="@drawable/information" />

getDrawable() gives null object while trying to get bitmap from imageview

风格不统一 提交于 2019-12-01 18:03:49
问题 I am using glide for imageview and I want to get bitmap from that imageview-- ImageView imageView = (ImageView) findViewById(R.id.dp); Glide.with(this).load("http://graph.facebook.com/1615242245409408/picture?type=large").into(imageView); Bitmap fbbitmap2 = ((BitmapDrawable)imageView.getDrawable()).getBitmap(); But it gives java.lang.NullPointerException: Attempt to invoke virtual method 'android.graphics.Bitmap android.graphics.drawable.BitmapDrawable.getBitmap()' on a null object reference

Android bitmap imageview memory leak

南楼画角 提交于 2019-12-01 17:14:49
问题 I put 4x4 imageView to an activity(BoardActivity), and user can change the images by clicking them. With HTC Desire (Android 2.2.2), I got OOM(Out Of Memory) in about 30 minutes of intensive useage -EDIT: 16th start of this activity- , but no other devices produces this (android 2.1, and android 2.2.1). Is it possible, that I made some mistake with the bitmap/imageview useage and that causes this error? First, I load all resource ID into a map: private Map<String, Integer> imageResourceMap;

Android setX() and setY() behaving weird

北慕城南 提交于 2019-12-01 16:04:52
I am trying to dynamically create and then move an image in an Android activity. However, the setX() and setY() methods seem to not work correctly. It correctly sets the position of an image when it is first created and placed, but any attempt to update it results in the image being placed in the wrong spot. For instance, the image moves on the following code: ImageView image; RelativeLayout layout = (RelativeLayout)findViewById(R.id.activity_this); if(action == MotionEvent.ACTION_DOWN){ image = new ImageView(MyClass.this); layout.addView(image, width, height); image.setX(206); image.setY(206)

Android setX() and setY() behaving weird

老子叫甜甜 提交于 2019-12-01 15:11:12
问题 I am trying to dynamically create and then move an image in an Android activity. However, the setX() and setY() methods seem to not work correctly. It correctly sets the position of an image when it is first created and placed, but any attempt to update it results in the image being placed in the wrong spot. For instance, the image moves on the following code: ImageView image; RelativeLayout layout = (RelativeLayout)findViewById(R.id.activity_this); if(action == MotionEvent.ACTION_DOWN){

how to scale an image in an ImageView so that it “fits”

廉价感情. 提交于 2019-12-01 15:08:57
I want to scale an image in an ImageView in the following way. The ImageView has some dimensions Width (W) and Height (H). The image I'm putting into the image view could be smaller or bigger than WxH. I want it to scale while preserving aspect ratio to fill WxH space. It seems like the closest thing to what I want is android:scaleType="centerInside", but what I'm seeing is that if the image is smaller than WxH, it will put a small-unscaled version of that image in the center of the ImageView (like the documentation says), but I want it to scale it to "fit", while showing the entire image, and

JavaFX imageview real coordinates translateX and translateY

僤鯓⒐⒋嵵緔 提交于 2019-12-01 14:53:54
And why the translateX and translateY is bad position on my scene ? I start on coordinate x = 100 y = 200 in real my real coordinate y = -24.8 ... why ? I need real coordinates when is my ImageView is ? primaryStage.setTitle("Title"); Group root = new Group(); Scene scene = new Scene(root, 800, 600, Color.WHITE); // border.prefHeightProperty().bind(scene.heightProperty()); //border.prefWidthProperty().bind(scene.widthProperty()); Image im = new Image("Images/universe.jpg", 800, 600, true, true); ImageView iv = new ImageView(im); Image iv1 = new Image("Images/Asteroid.png", 60, 50, false, false

onClickListener on imageview to start new intent

醉酒当歌 提交于 2019-12-01 14:45:39
So Im trying to use an onClickListener to pass an image from one activity to a new activity but I cannot figure out how to do it. How it works is the app starts with a listview where you can select an item and it opens a new activity that displays some information and an image below. I want to be able to click the image to open it in a new activity. Heres my routeDetails.java this is where the image I want to click is located package com.example.zach.listview; import android.content.Intent; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View;