Highlighted

How to save image in good quality to photos album on Android and iOS

Explorer ,
Jul 05, 2017

Copy link to clipboard

Copied

Hi,

what I want to do is actually the same as CameraRoll.addBitmapData(DATA) is doing - but in a good quality as the mentioned function saves the image in a really, really bad quality as JPEG.

Thanks

Christian

TOPICS
Development

Views

903

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

How to save image in good quality to photos album on Android and iOS

Explorer ,
Jul 05, 2017

Copy link to clipboard

Copied

Hi,

what I want to do is actually the same as CameraRoll.addBitmapData(DATA) is doing - but in a good quality as the mentioned function saves the image in a really, really bad quality as JPEG.

Thanks

Christian

TOPICS
Development

Views

904

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jul 05, 2017 0
Engaged ,
Jul 05, 2017

Copy link to clipboard

Copied

Since Adobe still only supports JPEG which is lacking when you might want to really use 32-bit PNG with optional transparency, I recommend using one of the various ANEs out there that support exporting Photos and also adds support for PNG.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 05, 2017 0
Explorer ,
Jul 05, 2017

Copy link to clipboard

Copied

So at least it would be fine for us to save the image in a GOOD quality as a jpeg to the devices standard directory for photos?

Isn't there any way to do this without native extensions? We often had problems that something is crashing in 3rd party native extensions which is sometimes hard to find out and even harder or impossible to fix...

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 05, 2017 0
Engaged ,
Jul 05, 2017

Copy link to clipboard

Copied

On Android you could possibly do this without a native extension, although technically you should really be saving files into the standard Android photo directory for the OS, which can only be gotten with a native call to (Java code below):

File path = Environment.getExternalStoragePublicDirectory( Environment.DIRECTORY_PICTURES);

(sure you could guess various default folders you might find on the web, but some versions of the OS have now abstracted this folder so it isn't the same guaranteed location. It is important to use the right folder otherwise other apps or default photo browsing app won't see the images your app is exporting (if that is important to make them public to all other apps on the device))

On iOS I don't see how you could do it without an ANE as Adobe's API is simply CameraRoll.addBitmapData

Adobe has a CameraRollBrowseOptions class but no CameraRollSaveOptions class to support customization.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 05, 2017 2
Explorer ,
Jul 13, 2017

Copy link to clipboard

Copied

first make sure you have encoded bitmapdata without quality lost either use png or jpeg encoder with quality 100%

var bytes:ByteArray = new ByteArray();

bit.encode(bit.rect, flagPng ?  new PNGEncoderOptions() : new JPEGEncoderOptions(100),bytes);

var file:File = File.documentsDirectory.resolvePath("DCIM/customGalleryFolder/");

if(!file.exists) file.createDirectory();

file = file.resolvePath("imgFileName.jpg");


var stream:FileStream = new FileStream();

stream.open(file, FileMode.WRITE);

stream.writeBytes(bytes);

stream.close();

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 13, 2017 0
Explorer ,
Oct 23, 2017

Copy link to clipboard

Copied

Hi Fullflash,

I tried it your way and I can save an image on a windows PC but on Android  - I cannot find a stored image and I don't get any errors.

file.nativepath ist something like "/data/data/air.com.myCompany.myApp/com.myCompany.myApp/Local Store/DCIM/customGalleryFolder"

Do you have any idea where the problem could be?

Kinde regards

Chris

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 23, 2017 0
Enthusiast ,
Oct 23, 2017

Copy link to clipboard

Copied

Hi Chris,

I don't have the answer to your previous question, but when you add your image to the camera roll the old way, are you using the bitmapdata.drawWithQuality method?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 23, 2017 0
Explorer ,
Oct 24, 2017

Copy link to clipboard

Copied

Hi Lars,

the stageQuality in our app is high so the bitmapdata.drawWithQuality will not change anything - the compression is through the CameraRoll (see other threads)...

BitmapData - Adobe ActionScript® 3 (AS3 ) API Reference

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 24, 2017 0