1

I followed another StackOverflow tutorial where you can capture a bitmap from the camera and set it to your image view. The issue I am having is that the picture that is returned is very small and does not fill the rest of the screen. In my XML I do the following...

<ImageView 
     android:id="@+id/imgview" 
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />

If I change to "fill_parent" I get a larger image, but my question now is how would I go about getting the actual size image and putting it on a scrollable (in both the x and y directions) view container.

Thanks!

BTW, here is the code for capturing the Bitmap from the camera...

public class MainActivity extends Activity implements OnClickListener
{
private ImageView imageView;

@Override
public void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Log.d("matt","1");

    Button b = (Button)this.findViewById(R.id.btn);
    imageView = (ImageView)this.findViewById(R.id.imgview);

    b.setOnClickListener(this);
}

@Override
public boolean onCreateOptionsMenu(Menu menu)
{
    getMenuInflater().inflate(R.menu.activity_main, menu);
    return true;
}

@Override
public void onClick(View v)
{
    Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
    startActivityForResult(cameraIntent,1888);
}

protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
    if(requestCode == 1888)
    {
        Log.d("matt", "3.a");
        Bitmap photo = (Bitmap) data.getExtras().get("data");
        Log.d("matt", "3.b");
        imageView.setImageBitmap(photo);
        Log.d("matt", "3.c");
    }
}
JoxTraex
  • 13,423
  • 6
  • 32
  • 45
Matthew
  • 3,886
  • 7
  • 47
  • 84

2 Answers2

1

If you need the dimensions of the image being captured then you can use:

int height = photo.getHeight();
int width = photo.getWidth();

Otherwise, if you would like to find out the size of the image captured (in megabytes) then please refer to my answer to this question: https://stackoverflow.com/a/11846455/1512836

[EDIT] - Please check this for scrolling an image view: Images in ScrollView in android

Community
  • 1
  • 1
A Random Android Dev
  • 2,691
  • 1
  • 18
  • 17
1

The caller may pass an extra EXTRA_OUTPUT to control where this image will be written. If the EXTRA_OUTPUT is not present, then a small sized image is returned as a Bitmap object in the extra field. This is useful for applications that only need a small image. If the EXTRA_OUTPUT is present, then the full-sized image will be written to the Uri value of EXTRA_OUTPUT.

SAURABH_12
  • 2,262
  • 1
  • 19
  • 19