Skip to main content
Inspiring
March 29, 2013
Question

Is it possible to save PNG with transparency to Camera Roll?

  • March 29, 2013
  • 2 replies
  • 11018 views

I've had a user contact me saying that the pictures he creates save as JPG and because they are JPG they lose transparency. I looked at the code I'm using and it's CameraRoll.addBitmapData(bitmapData). I could find no other options or parameters. He also said it is highly compressed JPG as well. If it's not supported (although I thought it was in an earlier version??) is there a work around!?

This topic has been closed for replies.

2 replies

Known Participant
November 15, 2013

Hi everyone, is there a way of saving a retina resolution (144px) image using camera Roll on iPad? I'm a novice coder, so I hope there is an easy way. I'm not able to use command line etc..

Please post any code here, or if not, does anyone know if Flash CC has fixed this?

Thanks,

Matt

Inspiring
March 11, 2014

Anyone know an ANE where I can do this but for Android?  Sucks that this capability is limited due to an iOS issue.

jadams602
Inspiring
March 11, 2014

It isn't really limited due to an iOS issue, just that Adobe chooses to not add PNG with transparency support. I completely disagree with the premise that this should be limited just because on iOS  Photo Album doesn't display PNGs with transparency accurately. There are dozens of existing iOS apps now passing around and creating PNGs with transparency (and viewing them properly).

As far as Android, I implemented this myself just using the builtin BitmapData.encode support for creating PNG format ByteArray, and just saving directly to the filesystem a .png file since Android (unlike iOS) allows it.

To make that process  clean with the rest of the Android eco-system, you will probably want to include two additional ANE based features (or choose to roll your own ANE that combines everything)...

The two extra steps as far as ANE support is:

1) an ANE that will trigger a refresh of the Android Gallery (or some base directory more exactly) when the filesystem underneath it has changed if you write to the filesystem directly, there are a few ANEs that do this out there like:

http://forums.adobe.com/message/6092838

2) In newer versions of Android, different users get different mapped 'home dirs' for Pictures so you really don't want to just write to some common /mnt/sdcard folder and hope for the best.

The proper base directory to save Pictures to on Android with the newer APIs is to call (on the native Java side):

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

Just wrapping that returned directory location above from Java with an ANE, will guarantee you are always working with the proper base directory for the current runtime user in Android.

I don't know if any ANE out there has added that 'Public Pictures Directory' function above but it is a trivial function call, and you could even just tack this on as an additional API function on whatever RefreshGallery ANE you grab (with source code of course)

thx1138Author
Inspiring
April 9, 2013

Bump. How come it's so horribly compressed? If we are stuck with JPG can we use JPEG 2000 with lossless and transparency? Otherwise please allow adding content of PNG origin. 

Adobe Employee
April 18, 2013

Thanks for your bug report. The bug is already been logged at https://bugbase.adobe.com/index.cfm?event=bug&id=3205096 , please add your vote and comment.

Regards,

Nimit

Jeff__Ward
Inspiring
May 1, 2013

I would not implement this, or do so with a big disclaimer.  Images with transparency in the cameraroll cause iOS bugs (https://discussions.apple.com/thread/3778274?start=0&tstart=0) and people will blame AIR.  It's an iOS problem, but it doesn't matter - it will look like AIR or our apps that are causing problems.