Skip to main content
Inspiring
Mar 29, 2013 9:15 PM UTC
Question

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

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 is closed to new replies. Start a new post to keep the conversation going.

13 replies

Known Participant
Nov 15, 2013 4:09 PM UTC

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

Translate
Inspiring
Mar 11, 2014 4:37 PM UTC

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

Translate
jadams602
Inspiring
Mar 11, 2014 5:02 PM UTC

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)

Translate
thx1138Author
Inspiring
Apr 9, 2013 7:52 PM UTC

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. 

Translate
Adobe Employee
Apr 18, 2013 7:43 AM UTC

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

Translate
Jeff__Ward
Inspiring
May 1, 2013 11:08 PM UTC

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.

Translate