lyft / scissors

✂ Android image cropping library
https://eng.lyft.com/scissors-an-image-cropping-library-for-android-a56369154a19
Apache License 2.0
1.84k stars 236 forks source link

Sending to intent goes wrong #21

Closed catalin-florescu closed 8 years ago

catalin-florescu commented 8 years ago

After crop, if i send picture via intent like in sample with Picasso, most of the times does nothing because file is corrupted or other causes. I made an AsyncTask with weak reference to load bitmap. I set image to crop, first time resulted bitmap is null. Second time bitmap is decoded successful. Is decoding when he wants. I do something wrong or is some bug? I followed the sample at first time and it isn't work at all.

eveliotc commented 8 years ago

@Cataalinn can you make sure you are loading file once flushing to disk has finished? it sounds like that operation has not completed when you start your other activity.

In our sample we use rxjava to observe when flushing is completed, and then we start the other Activity, please make sure you use as similar approach when using extensions or alternatively you can use just use Bitmap result = cropView.crop(); to obtain the Bitmap and save it to disk at your convenience.

catalin-florescu commented 8 years ago

@eveliotc what do you mean once Flushing to disk has finish?

eveliotc commented 8 years ago

@Cataalinn it means when writing all the bits that compose your image format into the file has completed. If you read the file before that it will likely be empty or partial (corrupted). For your information here is how extensions write to file.