BitmapData masking: how to merge 2 alpha channels?

How can I apply an alpha mask from one bitmapdata to another? In other words, I want to merge the alphas, not simply copy one alpha channel to another bitmap.
Here's an illustration:
Notice that both the triangle and the ellipse have alpha channels, and the result is an intersection of these alpha channels. The RGB channels from the second image are used, and discarded from the first.
I've looked into using BitmapData/merge(), draw(), copyChannel(), but they don't seem to do what I want. Anyone?
Cheers.
-Aaron

Aha, looks like the answer was right under my nose: copyPixels() can do exactly this:
If you include the alphaBitmap and alphaPoint parameters, you can use a secondary image as an alpha source for the source image. If the source image has alpha data, both sets of alpha data are used to composite pixels from the source image to the destination image. ThealphaPoint parameter is the point in the alpha image that corresponds to the upper-left corner of the source rectangle. Any pixels outside the intersection of the source image and alpha image are not copied to the destination image.
Cheers.
-Aaron

Similar Messages

  • How copy an alpha channel mask to an adjustment layer?

    I can copy an alpha channel mask to an image layer by Ctrl+Clicking the alpha channel then clicking the Add Layer Mask icon in Photoshop CC but this does not work for an adjustment layer. How can I copy the mask from an alpha channel to the layer mask for an adjustment layer? Thanks.

    I am using Photoshop CC as I stated in my question. All updates have been installed.
    I am running on Win 7 Pro 64 bit with all updates installed.
    I am editing a photograph.
    I have an alpha channel with a grey scale mask.
    If I Ctrl+Click the alpha channel then click the Add Layer Mask button to add a layer mask to an image layer the alpha channel mask is added to the image layer.
    If I delete the layer mask from an adjustment layer and follow the same steps a solid white mas is added to the adjustment layer.
    Several others in the camera club I belong to have tried this with the same result so the problem is not unique to my system.
    Hope this helps.

  • How to display alpha channel of layer mask in layers palette ??

    Help me out here folks....
    Using CS5--in the past, when I added a layer mask to a layer, it would display in the palette as the alpha channel, which was very handy. Now, when I add a layer mask, it only appears as the mask icon; i.e., gray square with white circle in the middle. I have no clue what I did to change from the one to the other, but I would certainly like to get the alpha representation back!
    TIA,
    Toby

    Could you please post a screenshot with the pertinent Panels visible?
    Could you be mixing up Layer Masks and Vector Masks?

  • How to set alpha channel names in a format plugin?

    I am writing a format plugin with 6 color planes for CMYK mode. I want to set the apha channel names for planes 5 and 6 to "White" and "Clear" instead of "Alpha 1" and "Alpha 2" when I read the color data from my file. How do I set the alpha channel names?
    Thanks!

    I am still trying to find a solution to this.  The propChannelName is read only and the documentInfo structure is NULL when reading.  Any suggestions?

  • How to create Alpha Channel automatically?

    I have a folder containing about 100 TIFF files, each containing an intricate shape against a transparent background.
    I need to create an Alpha Channel in each one which replicates the transparent background.
    Is there a way to do this "automatically" with Photoshop 7.0.1 (the only version I have access to) under MacOS X 10.4.11?

    Record into an action and batch: select layer transparency, save selection as alpha channel. Watch your matting though, as it sounds like these files will be flattened and any feathering in the alpha channel will leads to a fringe of [white? black?]. You could tuck in the alpha channel mask a bit before you save. It depends on the final usage...

  • How to retrieve alpha channel data in format plugin

    I want to ask how to get the alpha channel 's data that describle the document's transparent info, in a format plugin.
    for example , when open a PNG file in Photoshop, the photoshop set FormatRecord:: planes to 3 (not 4),
    in this case i can only request the RGB data.
    then how can i get if the pixel is transparent in document ?  (that is 0 - completely transparent, 255 - completely opaque)
    Thanks~

    i have resolved this problem, it's maybe i didnot set the fmtCanWriteTransparency flag in the pipl.
    thanks.

  • How can the alpha channel be removed in an image with the command sips?

    I solved it by converting the image to jpeg with best quality, but it's a less than optimal solution.
    Is there a better way?
    I want to know because I'm developing a bash script to manipulate images.
    Thank you.

    I'm developing a Bash script to automate PNG compression.
    Converting true color images is often a good idea to reduce file size dramatically but transparency doesn't look any good then. So removing the alpha channel is usually the thing to do.
    I think Apple's platform is very easy to use but as soon as I dig deeper into the system it often becomes frustrating. Why isn't there a simple way to do something so simple and basic as removing alpha channels from images from the command line? Sips should be the answer but doesn't seem to be, unless I've missed something, but the manual doesn't give any clue.

  • Merging alpha masks

    Hi,
    I have about 10 layers that I want to merge together.  Each layer has its own individual alpha mask that doesn't overlap each other.  I was wondering if it's possible to merge all the layers onto one while preserving an alpha that encompasses all 10 alpha masks as well.
    Thanks. 

    I am not sure how the merged alpha channel will help you and I am pretty sure if you applied that combined alpha channel as a layer mask on the merged images that you would not get the same result as a Merge operation (Michael already mentioned this above). In the layer stack, each Layer Mask operates wtih the existing layer and the next lower layer (with all other layer settings) to determine the Composite image to present to the next higher  Layer and Layer Mask.  The masks are not directly working in a cascade fashion with each other directly from a conceptual point of view (IMHO of course).  That is why preserve only keeps the bottom Layer Mask. All the other masks were merged into their respective Layers druing the merge process (except the last one).
    That given, if you want to create a composite mask for some purpose that I do not understand (very likely) then here is how you can do it:
    - Make sure that selections are cleared
    - On each Layer, add the Layer Mask to the selection
    - After all Layer Masks have been added to the selection, either a) save selection as a) Channel Mask or b) create a new Layer Mask on its own independent layer from the selection.
    At this point you have the combined mask as you requested either in the channels panel or as an independent layer mask.   You can do the merge without preserve set and still have a combined mask as you requested to be used whereever.
    Hope this is helpful and if I just don't  understand your request I apologize for taking up your time.   If I am off base, it may be helpful to describe what you want to achieve with your image as opposed to just what operations you want to execute.  I sense other forum members don't quite understand the end result you want to achieve.  I am sure you will get lots of suggestions once forum members understand the end image objectives.  Good luck.

  • Alpha channel modes

    Hi
    A compositor has done some green screen keying for me - great job but he's given me the key as a seperate alpha channel (TIF as an image sequence) I'm a bit unfamiliar with how to use alpha channels in this way.
    I have layer one as my background,
    layer 2 as my subject that he has worked on the green screen of
    layer 3 as a seperate alpha channel to key out the green. The Subject I want to see is white and the surroundings I want transparent are black.
    So please tell me what settings to use to see the subject and the background.
    I am assuming i only want to change settings on the alpha layer. By changing the compositing mode to overlay, i can see the subject fine, but the background is black. I have tried changing the alpha mode (ignore, straight, black or white) and various combinations of compositing mode and alpha but without getting any further....
    So any help would be greatly appreciated, its the end of a long project and I'm starting to tear out my hair!
    cheers

    Export using QuickTime conversion using animation codec, millions of colours+
    Try this:
    http://discussions.apple.com/thread.jspa?messageID=4791917&#4791917
    A search using Alpha channels produced this:
    http://discussions.apple.com/search.jspa?threadID=&q=alpha+channels&objID=c206&d ateRange=last90days&userID=&numResults=15&rankBy=10001
    Search is thy friend, si thi

  • Alpha Channel editing?

    Searching the forums and the internet at large, I don't see any way to view and directly edit the alpha channel of an image in Photoshop Elements 10?  I'm currently using the trial version for evaluation but imagine that no features are disabled?
    Specifically, I do game development for fun and frequently need to view and manipulate the alpha channel to achieve different things.  Looks like I might (?) be able to do something with masks but I'm so used to having direct access to the alpha channel in my very old version of Photoshop 5 that I really consider direct alpha channel access critical to my workflow.  Perhaps I'm wrong?
    As an aside, related to my "not a power user" level of needs overall for Photoshop, upgrading to the full CS version is way beyond what I want to spend.  Even Elements costs more and provides me with more features than I really need but would be willing to pay it if I could access the alpha channel.

    ChypeFlux2 wrote:
    Looks like I might (?) be able to do something with masks but I'm so used to having direct access to the alpha channel in my very old version of Photoshop 5 that I really consider direct alpha channel access critical to my workflow.  Perhaps I'm wrong?
    If you save your image as a PSD file, you can save various selections you make as named selections.  You can then recall specific selections at a later date.  The selection can be converted to a mask by:
    Loading the selection.
    Clicking the Mask button at the bottom of the Layers Panel.
    The selection is automatically used as a mask, which is an alpha channel:
    If you Alt-click on the Mask image, you can load it into the Editing window where you can manipulate it using PSE's tools:
    Is that what you're looking for?
    Ken

  • NSBitmapImageRep - how can I remove or reverse an alpha channel from tiff?

    Below is some code I cobbled together to save a square preview of an image. I am looking to figure out how to remove or inverse an alpha channel mask from a tiff image, and could really use some help....
    // I have been using 256.0 and 0.4 for the last 2 arguments, though feel free test with whatever.
    - (NSString *)savePreview: (NSString *)filePath: (NSString *)saveFilePath: (NSString *)previewSize: (NSString *)compressionRatio {
    NS_DURING
    NSAutoreleasePool *memoryPool = [[NSAutoreleasePool alloc] init];
    NSImage *myImage = [[NSImage alloc] initWithContentsOfFile: filePath];
    if (myImage == nil) {
    [myImage release];
    NSLog(@"! Error loading image");
    return @"! Error loading image";
    NSImageRep *myRep = [[myImage representations] objectAtIndex: 0];
    float hres = [myRep pixelsWide]/[myImage size].width;
    float vres = [myRep pixelsHigh]/[myImage size].height;
    float newWidth = [previewSize floatValue];
    float newHeight = newWidth;
    NSImage *thumbImage = [[NSImage alloc] initWithSize: NSMakeSize(newWidth, newHeight)];
    NSAffineTransform *at = [NSAffineTransform transform];
    [myImage setScalesWhenResized: YES];
    float heightFactor = newHeight/[myImage size].height;
    float widthFactor = newWidth/[myImage size].width;
    float scale;
    if(heightFactor > widthFactor) {
    scale = widthFactor;
    } else {
    scale = heightFactor;
    [at scaleBy: scale];
    [thumbImage lockFocus];
    [[NSGraphicsContext currentContext] setImageInterpolation: NSImageInterpolationHigh]; // NSImageInterpolationNone, NSImageInterpolationLow, NSImageInterpolationHigh
    [myImage setSize: [at transformSize: [myImage size]]];
    [myImage compositeToPoint: NSMakePoint((newWidth-[myImage size].width)/2 , (newHeight-[myImage size].height)/2) operation: NSCompositeCopy];
    NSBitmapImageRep *bitmapImageRep = [[NSBitmapImageRep alloc] initWithFocusedViewRect: NSMakeRect(0, 0, [thumbImage size].width, [thumbImage size].height)];
    [thumbImage unlockFocus];
    [myImage release];
    [thumbImage release];
    NSData *bitmapData = nil;
    NSNumber *factor = [NSNumber numberWithFloat: [compressionRatio floatValue]]; // The compression factor. Used only for JPEG files. The value is a float between 0.0 and 1.0, with 0.0 being the lowest and 1.0 being the highest. It’s set when reading in and used when writing out.
    NSDictionary *props = [NSDictionary dictionaryWithObject: factor forKey: NSImageCompressionFactor];
    bitmapData = [bitmapImageRep representationUsingType: NSJPEGFileType properties: props];
    [bitmapData writeToFile: saveFilePath atomically: YES];
    [bitmapImageRep release];
    [memoryPool release];
    return @"YES";
    NS_HANDLER
    NSLog(@"Exception occured : %@", localException);
    return @"NO";
    NS_ENDHANDLER
    }

    <bump>

  • Moving a layer's alpha channel into layer mask

    (CS3)
    I have a raster layer that has some semi-transparent pixels. I'd like to make the layer itself fully opaque, and move the contents of its alpha channel into a layer mask. How would I go about doing this? (If possible, merging the alpha channel with what I have already placed into the layer mask.)
    Thanks!

    kopo88 wrote:
    (CS3)
    I have a raster layer that has some semi-transparent pixels. I'd like to make the layer itself fully opaque, and move the contents of its alpha channel into a layer mask. How would I go about doing this? (If possible, merging the alpha channel with what I have already placed into the layer mask.)
    Thanks!
    Copy the alpha channel into your clipboard, then paste it into the mask. To paste into a layer's mask, alt click the mask to make the mask the focus then ctrl v to paste. To remove focus, alt click on the mask again or click on another layer. As to how to mix the two, you could probably do it using calculations.

  • How to export a video with an alpha channel that can be switched off

    Hi!
    I'm stuck with something that I think might have a simple solution:
    I need my video to have an alpha channel while still keeping all the RGB information in place too. This is for Syntheyes, which can take the alpha channel for a video and use it as a garbage matte while tracking.
    The problem is that if I draw a mask around my video and then export as a PNG (with alpha), the RGB information seems to be gone even when I choose to ignore the alpha channel. I know how to edit the alpha channel in Photoshop while still keeping the RGB elements untouched, but how should I do that in AE?
    Any help will be appreciated!

    Okay I will answer my own question:
    This worked as soon as I did a proper export as a PNG image sequence. I did my tests with only single frames by using the "save frame as file" -function, which did not work properly (the rbg information was gone).
    So the simple solution to this question was:
    Draw a mask on the video layer and export with alpha. The RGB will be there, even though the mask hides it in AE.

  • How can I dispaly alpha Channels to proxy and show transparency correctly?

    Hi all! I have a problem. Please help me. Thank you very much.
    I want to display alpha Channels to proxy and show transparency correctly. I have get the datas of alpha Channels and RGB color. Following are the codes:
    void HiddenData::PaintPreview()
    if( !channelData ) return;
    PSPixelMap pixels;
    int spotChannelCount = gFilterRecord->documentInfo->alphaChannelCount;
    pixels.version       = ( spotChannelCount > 0 ) ? 2 : 1;
    pixels.bounds.left   = proxyRect.left;
    pixels.bounds.right  = proxyRect.right;
    pixels.bounds.top    = proxyRect.top;
    pixels.bounds.bottom = proxyRect.bottom;
    int32 proxyWidth  = proxyRect.right - proxyRect.left;
    int32 proxyHeight = proxyRect.bottom - proxyRect.top;
    pixels.imageMode     = gFilterRecord->documentInfo->imageMode;
    pixels.rowBytes      = proxyWidth * gFilterRecord->documentInfo->depth / 8;
    pixels.colBytes   = 1;
    pixels.planeBytes    = proxyWidth * proxyHeight;
    pixels.baseAddr   = channelData;
    // new for version 2 of PSPixelMap
    PSPixelOverlay* overlay = NULL;
    if( spotChannelCount > 0 ){
      overlay = new PSPixelOverlay[ spotChannelCount ];
      if( overlay ){
       int j = 0;
       for( int i = 0; i < spotChannelCount; i++ ){
        overlay[i].data = channelData + pixels.planeBytes * (4 + i);
        overlay[i].rowBytes = pixels.rowBytes;
        overlay[i].colBytes = 1;
        overlay[i].r = (unsigned8)spotColorList[j++];
        overlay[i].g = (unsigned8)spotColorList[j++];
        overlay[i].b = (unsigned8)spotColorList[j++];
        overlay[i].opacity = 50 * 2.55;
        overlay[i].overlayAlgorithm = kStandardAlphaOverlay;
        overlay[i].next = ( i == (spotChannelCount - 1)) ? NULL : overlay + i + 1;
       pixels.pixelOverlays = overlay;
       pixels.colorManagementOptions = kViewAsStandardRGB/*kViewAsMask*/;
    pixels.mat = NULL;
    pixels.masks = NULL;
    pixels.maskPhaseRow = 0;
    pixels.maskPhaseCol = 0;
    (gFilterRecord->displayPixels)(&pixels, &pixels.bounds, 0, 0, (void *)hdc);
    delete[] overlay;
    But there is a problem.The image of alpha Channels in proxy is not clear, because overlay[i].opacity = 50 * 2.55.
    It looks like  diffrent from displaying in photoshop.I do not know how to use pixels.mat and pixels.masks.
    Thanks!

    I run the plugin. But It can not show alpha channels. Can you show the code in your example clearly.Thanks! Following are the frames.
    The original document:                                 
    The result:
    Can not show the alpha channels.

  • How should I edit an alpha channel after saving?

    I have a series of files in which I improperly modified the selection set prior to saving the selection, and now around the intended viewable area there is a hazy artifact that seems to correspond to where I manually edited the selection using Quick Mask (prior to saving).
    In other words, within the area of the alpha channel that should be invisible, there is actually a visible, unwanted grey-ish artifact, and I think it's related to how I was using the brush to edit the selection in Quick Mask before saving.
    Now I am unable to edit the alpha channel, although Adobe's own website says that in order to edit an alpha channel, all I need to do is select the alpha channel (which I am doing) and then paint at 100% black or white with a brush to either include or exclude parts of selection set.
    When I choose the brush and start painting at 100% black or white, nothing happens and I can't figure out what is happening.
    Any help would be greatly appreciated.
    The exact steps that I'm taking are below:
    1) click on alpha channel (visible and ready for editing), all other channels only visible not active.
    2) selecting the brush at either 100% black or white
    3) attempting to paint to alter the alpha channel (I've tried painting on the actual alpha channel in Channels, and I've tried painting on the alpha channel as it appears in Layers, and neither works for me).
    CLARIFICATION:
    I actually am able to "edit" the alpha channel HOWEVER I cannot remove the hazy artifact. I can use 100% black or white to remove the pink/light red areas on either the actual alpha channel (in the Channels area) or as it appears in Layers, but I cannot remove the areas that are grey-ish (well I can paint them white but I can't paint them black, i.e. fully pink).
    A teacher showed me a quick fix process that basically involves activating the alpha channel, inverting the selection, and then deleting everything outside of the alpha channel, and then resaving the file. That worked at one point, but now that quick fix is not working either (I am just ending up with a completely visible, white space around the intended visible area, rather than an invsible area).
    EDIT (07:22 3.20.13) Also, if you look at what Photoshop is registering as the actual alpha channle, it doesn't match with what I'm seeing above, that is the black and white alpha channel appears to be as expected, and there is not the weird distortion that I'm seeing above in the pink/grey image.
    So I am super confused and would appreciate any help!

    I greatly appreciate your help with this.
    However, after adjustting the black from 99 to 100%, and double checking that the white is fully zero (right now I can't find any files with the white set to anything but "0," so I don't know why some of my screenshots showed that), I am still unable to use black to contract a selection, or white to erase unwanted areas of the alpha channel (this specific post's problem).
    So, I'm completely baffeled and am wondering if there is anything else that could be accounting for these results (i.e. the black and white paint not producing the expected results).
    Thanks again,
    dk
    EDIT:
    I attempted to make another alpha channel, this time without any manual adjustment of selection via the paint brush. Instead, I used the selection modification option of Contract and used it to contract the selection.
    SAME problem. The area that I contracted using Contract, (never painted), is once again displaying a slight grey artifact in the area that is supposed to be completely transparent.

Maybe you are looking for

  • In Calendar, deleting one event in a recurring event deletes everything...

    When I delete one event in a recurring event, calendar deletes the entire event, both past and future. I am clicking the option "delete only this event," and the rest of the recurring event doesn't disappear on my iphone 4 (linked through iCloud). Th

  • OO programing and other help......

    I got the following done. It is very nearly finished. Apart from a few error. ( Which i can't find out why so if you figure it out please be so kind to tell me. ) I think you could see my idea and what i intend to do in this program. But it is my fir

  • How do I change file type?

    I am trying to upload a video that I edited onto my hard drive in order to share and view it through different players.  My problem is that after I upload the video, the players do not recognize the file type.  How do I change the file type in order

  • UWL - FROM field

    Hello UWL experts, Where is the FROM column in the UWL mapped from the backend Workflow item? Thanks, zryxel

  • Travel expense - Miscellaneous Expense Type

    Hi All, There is miscellaneous expense type (MIAL) that i have configured for my client. Now they want to assign maximum default value for miscellaneous expense. The requirement is that on the basis of  R Grp M/A Enterprise, that i have maintained in