2011-05-30 13 views
6

Estoy tratando de exportar transparentes archivos PNG usando esta clase: com.adobe.images.PNGEncoder;as3 | Cómo exportar PNG usando Adobe AIR

var pngSource:BitmapData = new BitmapData (stage.stageWidth, stage.stageHeight); 
pngSource.draw(stage); 
var ba:ByteArray = PNGEncoder.encode(pngSource); 
var file:File = File.desktopDirectory.resolvePath("test.png"); 
var fileStream:FileStream = new FileStream(); 
fileStream.open(file, FileMode.WRITE); 
fileStream.writeBytes(ba); 
fileStream.close(); 

Todo funciona bien - excepto el tema transparente ...

si podía conseguir el color etapa de flash sea transparente, funcionará - pero por desgracia - no hay tal opción.

¿Hay alguna opción que me falta?

+0

recomiendan también le permite utilizar mejor la codificación de biblioteca: http://www.blooddy.by/en/crypto/ –

Respuesta

6

Debe realizar una instancia de BitmapData con un fondo transparente. Usted lo hace a través del argumento transparente en el constructor y un color de relleno con un componente alfa (ARGB en hexadecimal):

var pngSource:BitmapData = new BitmapData (stage.stageWidth, stage.stageHeight,true,0x00FFFFFF);//'transparent white' 
+1

Puede establecer el parámetro de color en '0'. El color será * negro transparente *, luego – NemoStein

+0

@ NemoStein Indeed :) –

+0

Guau, ¡funcionó como un amuleto! Gracias :) – Alon

Cuestiones relacionadas