File tree Expand file tree Collapse file tree 1 file changed +9
-7
lines changed Expand file tree Collapse file tree 1 file changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -1286,23 +1286,25 @@ private Uri whichContentStore() {
1286
1286
* @param bitmap
1287
1287
*/
1288
1288
public void processPicture (Bitmap bitmap , int encodingType ) {
1289
- ByteArrayOutputStream jpeg_data = new ByteArrayOutputStream ();
1289
+ ByteArrayOutputStream dataStream = new ByteArrayOutputStream ();
1290
1290
CompressFormat compressFormat = getCompressFormatForEncodingType (encodingType );
1291
1291
1292
1292
try {
1293
- if (bitmap .compress (compressFormat , mQuality , jpeg_data )) {
1294
- byte [] code = jpeg_data .toByteArray ();
1293
+ if (bitmap .compress (compressFormat , mQuality , dataStream )) {
1294
+ StringBuilder sb = new StringBuilder ()
1295
+ .append ("data:" )
1296
+ .append (encodingType == PNG ? PNG_MIME_TYPE : JPEG_MIME_TYPE )
1297
+ .append (";base64," );
1298
+ byte [] code = dataStream .toByteArray ();
1295
1299
byte [] output = Base64 .encode (code , Base64 .NO_WRAP );
1296
- String js_out = new String (output );
1297
- this .callbackContext .success (js_out );
1298
- js_out = null ;
1300
+ sb .append (new String (output ));
1301
+ this .callbackContext .success (sb .toString ());
1299
1302
output = null ;
1300
1303
code = null ;
1301
1304
}
1302
1305
} catch (Exception e ) {
1303
1306
this .failPicture ("Error compressing image: " +e .getLocalizedMessage ());
1304
1307
}
1305
- jpeg_data = null ;
1306
1308
}
1307
1309
1308
1310
/**
You can’t perform that action at this time.
0 commit comments