alpha/transparent

44 views
Skip to first unread message

karin

unread,
Mar 21, 2012, 10:28:37 AM3/21/12
to HYPE Framework
Hi,

Is there someone who could tell me how I can get the background of a
PNG or TGA recorded with the save ContentImage transparent in
Photoshop. When I open it the background remains black instead of
transparent. Is the an alpha channel I have to use or something?

regards,
Karin

Jaime De Gouveia

unread,
Jul 4, 2012, 6:36:51 PM7/4/12
to hypefr...@googlegroups.com
Hello Karin please see the following I've highlighted in red, this works for me - hope this helps/works :


import hype.extended.color.ColorPool;
import hype.extended.layout.ShapeLayout;
import hype.framework.core.ObjectPool;

//must have the following 3 frameworks imported for PNG's to be exported

import hype.extended.util.ContextSaveImage;
import hype.framework.canvas.encoder.PNGCanvasEncoder;
import hype.framework.display.BitmapCanvas;


MyShape.visible = false;

//must have the following 5 lines included for PNG's to be exported

var myWidth = stage.stageWidth;
var myHeight = stage.stageHeight;

var bmc:BitmapCanvas = new BitmapCanvas(myWidth, myHeight);
addChild(bmc);

var clipContainer:Sprite = new Sprite();



var pool:ObjectPool = new ObjectPool(MyCircle, 50);
var layout:ShapeLayout = new ShapeLayout(MyShape);

var color:ColorPool = new ColorPool(
    0x587b7C, 0x719b9E, 0x9FC1BE, 0xE0D9BB, 0xDACB94, 0xCABA88, 0xDABD55, 0xC49F32, 0xA97409
);

pool.onRequestObject = function(clip) {
    clip.scaleX = clip.scaleY = (Math.random() * 0.75) + 0.25;
   
    layout.applyLayout(clip);
    color.colorChildren(clip);
   
    clipContainer.addChild(clip);
}


pool.requestAll();


// setupLargeCanvas(10) = scaleFactor x 10 (640 x 360 Stage / 6400 x 3600 PNG)
bmc.setupLargeCanvas(10);
var saveImage:ContextSaveImage = new ContextSaveImage(bmc, PNGCanvasEncoder);

bmc.startCapture(clipContainer, true);

Karin Merx

unread,
Jul 5, 2012, 2:01:06 AM7/5/12
to hypefr...@googlegroups.com
Thanks for your answer. I know about the lines in the actionscript. Png gives me a transparant background in photoshop, tga not.

Regards,
Karin


Reply all
Reply to author
Forward
0 new messages