4 Replies Latest reply on May 9, 2007 1:27 AM by smartino

    Combining Two Alpha's

    smartino
      Hi, I've managed through imaging Lingo to create an alpha channel and place it in/on to a Bitmap. What I want to do now is combine two Alpha's from two different Bitmaps and place it in a thrid bitmap.

      Is this possible? Thanks in advance for any help.

      Cheers Simon.
        • 1. Re: Combining Two Alpha's
          Level 7
          You can use imageObject.extractAlpha() to get the alpha channels of your
          2 images, copyPixels() to combine them and setAlpha() to add the
          resulting grayScale image object as an alpha channel - just be aware
          that setAlpha() will fail if the alpha channel's dimensions don't match
          the image's dimensions
          • 2. Re: Combining Two Alpha's
            smartino Level 1
            I'm not quite there yet with this problem. I've extracted two Alpha's from to different bitmaps and the only way I've managed to combine both alpha's together is by repeating through each alpha pixel by pixel to see if the pixel is black and if it is drawing it into another bitmap. Once it's finished I then use setAlpha.

            Even though it works it just takes a bit of time to loop through all the pixels and I might be using his technique on more than two bitmaps with alpha's. Is there a neat way i can do this using copypixel?
            • 3. Combining Two Alpha's
              Chunick Level 3
              let's say you now have alphaImg1 and alphaImg2... try copyImages with the #ink parameter... the values for the different inks can be found in the help... in my example below I'm going to try using 39 - Darkest ink.

              alphaImg1.copyPixels(alphaImg2, alphaImg1.rect, alphaImg2.rect, [#ink: 39])
              • 4. Re: Combining Two Alpha's
                smartino Level 1
                Spot on Chunick. I used ink 37 which seemed to give me the best result and it's A LOT faster than my repeat method. It was taking 14 seconds plus to draw and this is instant.

                Cheers,

                Simon.