1

I have the following:

A very long URL of where the image is located (on the internet)

String imageAddress = data.getExtras().get("imageHTTP").toString();

The returns fine and there is an image ending with .jpg

The next part is where I'm having problems. Basically I've got a crop intent that accepts Uri's but the following doesn't work:

Uri imageUri = Uri.parse(imageAddress);
Intent intent = new Intent(this, com.android.camera.CropImage.class);
intent.setData(uri);
intent.putExtra("return-data", true);
startActivityForResult(intent, CROP);

Any ideas?

Following error code:

got exception decoding bitmap 
java.lang.NullPointerException
at com.android.camera.Util.makeInputStream(Util.java:337)
Oliver Dixon
  • 7,012
  • 5
  • 61
  • 95
  • Have you tried what was suggested in the accepted answer for http://stackoverflow.com/questions/3904685/unable-to-find-com-android-camera-cropimage-activity-in-android ? – Michael Jul 14 '12 at 18:52

1 Answers1

0

I figured this out. Was easier to save it to sdcard temporary then crop, then delete the temporary one. After that I ran it though a downloaded crop library (don't know where downloaded it from but there are a few).

File file = null;

            try {
                URL myImageURL = new URL(imagePath);
                HttpURLConnection connection = (HttpURLConnection)myImageURL.openConnection();
                connection.setDoInput(true);
                connection.connect();
                InputStream input = connection.getInputStream();

                // Get the bitmap
                Bitmap myBitmap = BitmapFactory.decodeStream(input);

                // Save the bitmap to the file
                String path = Environment.getExternalStorageDirectory().toString() + "/polygonattraction/app/";
                OutputStream fOut = null;
                file = new File(path, "temp.png");
                fOut = new FileOutputStream(file);

                myBitmap.compress(Bitmap.CompressFormat.PNG, 85, fOut);
                fOut.flush();
                fOut.close();
            }
            catch (IOException e) {}

            Log.w("tttt", "got bitmap");

            Uri uri = Uri.fromFile(file);
Oliver Dixon
  • 7,012
  • 5
  • 61
  • 95