BufferedImage from PNG : Alpha Channel disregaurded

I'm trying to load a PNG with an alpha channel into a BufferedImage, and
then sample the BufferedImage at various pixels for some operations.
However, the alpha channel seems to get lost upon creation of the BufferedImage.
For example, I'm using a PNG that is 100% transparent, and when I
load it into a BufferedImage and display it on a panel all I see is the panel's background color.
So far so good. Now, the problem. When I try to sample a pixel, the alpha is always 255 or 100% opaque
which is clearly not right. Also, when I print out the BufferedImage's type, I get 0 which means the image
type is "Custom". Care to shed any light as to how I can accurately sample an image with an alpha channel?
import javax.swing.*;
import java.awt.*;
import java.io.*;
import javax.imageio.*;
import java.awt.image.*;
public class PNGTest extends JFrame {
    public PNGTest() {
        setLocation(500,500);
        BufferedImage img = new BufferedImage(640,480,BufferedImage.TYPE_INT_RGB);
        try {
            img = ImageIO.read(new File("C:/folder/folder/myPNG.png"));
        } catch (Exception e) {
        setSize(img.getWidth(), img.getHeight());
        getContentPane().setBackground(Color.white);
        getContentPane().add(new JLabel(new ImageIcon(img)));
        setVisible(true);
        //Sample top left pixel of image and pass it to a new color
        Color color = new Color(img.getRGB(0,0));
        //print the alpha of the color
        System.out.println(color.getAlpha());
        //print the type of the bufferedimage
        System.out.println(img.getType());
    public static void main(String[] args) {
        new PNGTest();
}Edited by: robbie.26 on May 20, 2010 4:26 PM
Edited by: robbie.26 on May 20, 2010 4:26 PM
Edited by: robbie.26 on May 20, 2010 4:29 PM

Here ya go robbie, ti seems to work for the rest of the world, but not for you:
import java.awt.*;
import java.awt.image.*;
import java.net.URL;
import javax.swing.*;
import javax.imageio.*;
public class JTransPix{
  JTransPix(){
    JFrame f = new JFrame("Forum Junk");
    JPanel p = new MyJPanel();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.add(p);
    f.pack();
    f.setVisible(true);
  public static void main(String[] args) {
    new JTransPix();
  class MyJPanel extends JPanel{
    BufferedImage bi = null;
    MyJPanel(){
      try{
        bi = ImageIO.read(new URL("http://upload.wikimedia.org/wikipedia/commons/archive/4/47/20100130232511!PNG_transparency_demonstration_1.png"));  //here ya go--one liner
        this.setPreferredSize(new Dimension(bi.getWidth(), bi.getHeight()));
      }catch(java.io.IOException e){
        System.out.println(e.toString());
    public void paintComponent(Graphics g){
      super.paintComponent(g);
      g.setColor(Color.BLUE);
      g.fillRect(0, 0, bi.getWidth(), bi.getHeight());
      g.drawImage(bi,0, 0, this);
}Please notice how the BufferedImage is declared and set to NULL, then allow ImageIO to set the type--Just as I said before. If you have any question about the PNG producing an ARGB image with ImageIO, then change the color painted onto the backgroun din the paintComponent to what ever you want and you'll see it show through.
BTW: even in the short nobrainers--you still need to have VALID CATCH BLOCKS.
To get what you are looking for, you can mask off the Alpha component by dividing each getRGB by 16777216 (256^3) or do a binary shift right 24 places.

Similar Messages

  • Motion 5, Importing a PNG, Alpha Channel Wonky

    When I import a PNG into motion the alpha map gets brighter— brighter than it looks in photoshop, preview, pixelmator, etc.
    Then in motion if I just export the project as a movie, the alpha channel values seem to return to normal in the MOV file. It's comforting to know that the final product will turn out ok, but how am I supposed to know what it will look like wihtout having to export the project everytime I want to see what it looks like. Note: I don't ever remember encountering any problems like this with Motion 4.
    Any help appreciated. Thanks.

    Very top right of the Motion interface, 4th icon from the right, check those settings.

  • 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.

  • Export PNG images with alpha channel from flash

    Hi,
    I have this FLA with animation and when played, the animation has alpha channel. I can’t understand why when I look in the library I see the frames without the alpha channel and also when I try to export/extract the image again the image don’t have alpha channel.
    How is it that in flash this image has alpha channel and how to get it out like that into PNG?
    Here is the link to download the FLA:
    http://download759.mediafire.com/nb749r29220g/e0636ab0ru6ouoa/Untitled-1.fla

    "when played, the animation has alpha channel"
    how are you playing the animation? control/enter in Flash, Publishing to a Web page or what?
    How can you tell that the animation has the alpha channel? What exactly are you seeing?
    What is the aniimation? a series of images, one image moving? Are teweens imvolved?
    " when I try to export/extract the image again the image don’t have alpha channel"
    How are you exporting the image? is it a single image? or a series of frames that makes up an animation?
    What was the file format of the original image? you brought that image into Flash and animated it? Now you want to export as a .png with transparency?
    Have you ever tried to export a  simple .png before so that you see and understand the dialog box that pops up during export? are you chosing "24 bit with alpha channel" in the "Colors" choice?
    For those of us who may not want to download your file, please provide a more detailed describtion of everything related to this question.
    Best wishes,
    Adninjastrator

  • ImageIO PNG Writing Slow With Alpha Channel

    I'm writing a project that generates images with alpha channels, which I want to save in PNG format. Currently I'm using javax.ImageIO to do this, using statements such as:
    ImageIO.write(image, "png", file);
    I'm using JDK 1.5.0_06, on Windows XP.
    The problem is that writing PNG files is very slow. It can take 9 or 10 seconds to write a 640x512 pixel image, ending up at around 300kb! I have read endless documentation and forum threads today, some of which detail similar problems. This would be an example:
    [http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6215304|http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6215304]
    This surely must be resolvable, but after much searching I've yet to find a solution. If it makes any difference, I ONLY want to write png image, and ONLY with an alpha channel (not ever without), in case there are optimisations that that makes possible.
    If anyone can tell me how to address this problem, I'd be very grateful.
    Many thanks, Robert Redwood.

    This isn't a solution, but rather a refinement of the issue.
    Some of the sources I was reading were implying that the long save time might be due to a CPU heavy conversion process that had to take place before the BufferedImage could be saved. I decided to investigate:
    I loaded back in one of the (slowly) saved PNG images using ImageIO.read(file). Sure enough, the BufferedImage returned differed from the BufferedImage I had created. The biggest difference was the color model, which was DirectColorModel on the image I was generating, and was ComponentColorModel on the image I was loading back in.
    So I decided to manually convert the image to be the same as how it seemed to end up anyway. I wrote the following code:
          * Takes a BufferedImage object, and if the color model is DirectColorModel,
          * converts it to be a ComponentColorModel suitable for fast PNG writing. If
          * the color model is any other color model than DirectColorModel, a
          * reference to the original image is simply returned.
          * @param source The source image.
          * @return The converted image.
         public static BufferedImage convertColorModelPNG(BufferedImage source)
              if (!(source.getColorModel() instanceof DirectColorModel))
                   return source;
              ICC_Profile newProfile = ICC_Profile.getInstance(ColorSpace.CS_sRGB);
              ICC_ColorSpace newSpace = new ICC_ColorSpace(newProfile);
              ComponentColorModel newModel = new ComponentColorModel(newSpace, true, false, ComponentColorModel.TRANSLUCENT, DataBuffer.TYPE_BYTE);
              PixelInterleavedSampleModel newSampleModel = new PixelInterleavedSampleModel(DataBuffer.TYPE_BYTE, source.getWidth(), source.getHeight(), 4, source.getWidth() * 4, new int[] { 0, 1, 2, 3 });
              DataBufferByte newDataBuffer = new DataBufferByte(source.getWidth() * source.getHeight() * 4);
              ByteInterleavedRaster newRaster = new ByteInterleavedRaster(newSampleModel, newDataBuffer, new Point(0, 0));
              BufferedImage dest = new BufferedImage(newModel, newRaster, false, new Hashtable());
              int[] srcData = ((DataBufferInt)source.getRaster().getDataBuffer()).getData();
              byte[] destData = newDataBuffer.getData();
              int j = 0;
              byte argb = 0;
              for (int i = 0; i < srcData.length; i++)
                   j = i * 4;
                   argb = (byte)(srcData[i] >> 24);
                   destData[j] = argb;
                   destData[j + 1] = 0;
                   destData[j + 2] = 0;
                   destData[j + 3] = 0;
              //Graphics2D g2 = dest.createGraphics();
              //g2.drawImage(source, 0, 0, null);
              //g2.dispose();
              return dest;
         }My apologies if that doesn't display correctly in the post.
    Basically, I create a BufferedImage the hard way, matching all the parameters of the image I get when I load in a PNG with alpha channel.
    The last bit, (for simplicity), just makes sure I copy over the alpha channel of old image to the new image, and assumes the color was black. This doesn't make any real speed difference.
    Now that runs lightning quick, but interestingly, see the bit I've commented out? The alternative to setting the ARGB values was to just draw the old image onto the new image. For a 640x512 image, this command (drawImage) took a whopping 36 SECONDS to complete! This may hint that the problem is to do with conversion.
    Anyhow, I got rather excited. The conversion went quickly. Here's the rub though, the image took 9 seconds to save using ImageIO.write, just the same as if I had never converted it. :(
    SOOOOOOOOOOOO... Why have I told you all this?
    Well, I guess I think it narrows dow the problem, but eliminates some solutions (to save people suggesting them).
    Bottom line, I still need to know why saving PNGs using ImageIO is so slow. Is there any other way to fix this, short of writing my own PNG writer, and indeed would THAT fix the issue?
    For the record, I have a piece of C code that does this in well under a second, so it can't JUST be a case of 'too much number-crunching'.
    I really would appreciate any help you can give on this. It's very frustrating.
    Thanks again. Robert Redwood.

  • Graphics, ImageIO, and 32-bit PNG images with alpha-channels

    I have a series of 32-bit PNG images, all with alpha channels. I'm using ImageIO.read(File) : BufferedImage to read the PNG image into memory.
    When I call graphics.drawImage( image, 0, 0, null ); I see the image drawn, however all semi-transparent pixels have a black background, only 100% transparent pixels in the source image are transparent in the drawn image.
    The Graphics2D instance I'm drawing to is obtained from a BufferStrategy instance (I'm painting onto an AWT Canvas).
    Here's my code:
    Loading the image:
    public static BufferedImage getEntityImage(String nom, String state) {
              if( _entityImages.containsKey(nom) ) return _entityImages.get( nom );
              String path = "Entities\\" + nom + "_" + state + ".png";
              try {
                   BufferedImage image = read( path );
                   if( image != null ) _entityImages.put( nom, image );
                   return image;
              } catch(IOException iex) {
                   iex.printStackTrace();
                   return null;
         private static BufferedImage read(String fileName) throws IOException {
              fileName = Program.contentPath + fileName;
              File file = new File( fileName );
              if( !file.exists() ) return null;
              return ImageIO.read( new File( fileName ) );
         }Using the image:
    Graphics2D g = (Graphics2D)_bs.getDrawGraphics();
    g.setRenderingHint( RenderingHints.KEY_ANTIALIASING , RenderingHints.VALUE_ANTIALIAS_ON);
    public @Override void render(RenderContext r) {
              Point p = r.v.translateWorldPointToViewportPoint( getLoc() );
              int rad = getRadius();
              int x = (int) p.x - (rad / 2);
              int y = (int) p.y - (rad / 2);
              BufferedImage image = Images.getEntityImage( getCls(), "F" );
              r.g.drawImage( image, x, y, null );
         }

    You may want to check on you system and see what ImageReaders are available, it could be ImageIO is just not picking the best one, if not, then you can use getImageReaders to get an iterator of image readers, then choose the more appropriate one.

  • How do I save a PNG file with an alpha channel in Photoshop CS5?

    I have a PNG file created in Photoshop and I need to save it with an alpha channel for web purposes. I tried 'Save for Web & Devices' and selecting the Transparent box. Then, after saving, when I select 'get info' for the file it says there is no alpha channel. I'm stumped I can't seem to create an alpha channel from within Photoshop while I'm editing. Help!

    If you save as a 24bit png with transparent checked photoshop will save the png with transparent background (ie alpha transparency).  The png will appear transparent in a web browser.

  • Add alpha channel to a BufferedImage

    Hi, I am making a small jigsaw puzzle type game. I read an image from a file into a BufferedImage using ImageIO.read(). From this image I cut out rectangular pieces using getSubimage(). Then I would like to mask out the small figure cuts that should be along the edges of each piece. I'm thinking that I would like to do this by alpha transparency - making the background show through the irregular edges. So, my problem is that the images returned by ImageIO.read() does not necesarily have an alpha channel.
    Is there a simple way to add an alpha channel to an existing BufferedImage?
    Or does anyone have a better solution?
    P.S. Currently I intend to use a single circle at each edge, either inside the piece as a hole or filled outside the edge. These circles can easily be drawn, but I plan to eventually expand this to be able to make arbitrarily shaped pieces.

    Is there a simple way to add an alpha channel to an
    existing BufferedImage?Not for the general case. For example, I used ImageIO.read to load in a jpeg image. It's 50x60 pixels, and as an image it has 3 channels: red, green and blue -- no alpha. The pixel data is stored in a DataBufferByte, which has a single array of 9,000 bytes (3 channels x W x H). Given the packed structure of that data, there is no efficient way to slide in alpha values -- there's no room.
    One thing you can always do is copy the data from this BufferedImage into another BufferedImage that has an alpha channel. Here's some quick and dirty code to do it:
    static BufferedImage addAlpha(BufferedImage bi) {
         int w = bi.getWidth();
         int h = bi.getHeight();
         int type = BufferedImage.TYPE_INT_ARGB;
         BufferedImage bia = new BufferedImage(w,h,type);
         Graphics2D g = bia.createGraphics();
         ImageObserver imo = null;
         g.drawImage(bi, 0, 0, imo);
         g.dispose();
         return bia;
    Or does anyone have a better solution?
    P.S. Currently I intend to use a single circle at each
    edge, either inside the piece as a hole or filled
    outside the edge. These circles can easily be drawn,
    but I plan to eventually expand this to be able to
    make arbitrarily shaped pieces.1. The code given above is sufficient to take the original image and create the same image, but with an alpha channel. Don't worry about the fact that you're copying pixel data. Are you generating 100 jigsaw puzzles per second?
    2. Another possible solution is to start with the entire image, perhaps with no alpha channel, and draw individual jigsaw pieces by adjusting the Clip property before drawing each piece. Now, this may be a little slow, because calculating a fancy clipping shape with half-circles etc... may complicate the rendering
    3. My Conclusion. Because a jigsaw application would involve lots of repainting, rotating pieces and dragging them, I'd do the following:
    a. Create buffered images (with alpha) for each piece. I'm not using subimages because I'm trading more space for faster redrawing time. To be rigorous, one should do it both ways and compare the results.
    b. Just once, for each of these piece images, using a clipping shape, draw from the original image (with or without alpha) onto the piece image to generate the image of one piece. If your jigsaw game allows pieces to be rotated 90/180/270 degrees you may want to pre-generate those rotated piece images to speed up drawing the pieces in rotated orientations. Again, one should do it both ways and compare the results.
    --Nax

  • Automator or Applescript using png files with alpha channel

    I have hundred of png files with alpha channel.
    I want to suppress alpha channel.
    How can i do it using Automator or Applescript ?
    Thank you very much.

    You can use the free command line image processing tool ImageMagick in your Applescripts or Automator workflows, as well as from a Terminal shell.
    You can download ImageMagick from http://www.imagemagick.org, but Cactuslab has simplified installation by putting together an installer package. It’s available at  http://cactuslab.com/imagemagick/. Download the package and double-click on it. Follow the instructions to install. It will install ImageMagick into /opt/ImageMagick and add it to your $PATH by creating a file in /etc/paths.d/. Restart your computer for the changes to take effect.
    The two ImageMagick commands we’re concerned with are “convert” and “mogrify”. Convert is more efficient for multiple and piped operations on the same image file, and mogrify is more efficient for batch processing. Generally speaking, convert will output a file separate from the input file. Unless a path is specified, mogrify will overwrite the input file with the output file. An important distinction.
    You can perform various operations on the alpha channel using arguments after either the convert or mogrify command. Two of the available arguments are:
    -alpha off - Disables the image's transparency channel. Does not delete or change the existing data, just turns off the use of that data.
    -alpha remove - Composite the image over the background color.
    Also of use are the -flatten and -background options:
    -flatten - overlay all the image layers into a final image and may be used to underlay an opaque color to remove transparency from an image.
    -background - sets the background color.
    Start off using the convert command with a single image to see the effect and adjust to your liking. Once you’ve achieved the desired outcome, then use the mogrify command to batch process the chosen images.
    Before getting into how to use Automator or Applescript in your workflow, use Terminal and the command line to see the effect on a single image. Copy one image to your ~/Desktop. In Terminal change the directory to ~/Desktop by typing the following command and pressing the Enter key:
    cd ~/Desktop
    Then choose the option you are looking for, -alpha remove for instance, type the following command and press the Enter key:
    convert input-photo.png -alpha remove output-photo.png
    You can check the alpha channel (transparency) and background in the Preview app, go View > Show Image Background from the menu bar.
    Once you’re ready to batch proces, place all the photos you want to convert with the same command into one folder. Copy the folder to your ~/Desktop. Let’s assume you’ve labeled the folder “InPhotos”. It’s prudent to manipulate copies in case something goes amiss. In that event you can copy the folder with the originals again and start over. Create a new empty folder on your ~/Desktop and call it “OutPhotos”. Let’s also assume your home directory is called “Me”. The following command will process the photos from the InPhotos folder and put them in the OutPhotos folder:
    mogrify -alpha remove -path /Users/me/Desktop/OutPhotos/ /Users/me/Desktop/InPhotos/*png
    According to Apple Technical Note TN2065:
    "when you use just a command name instead of a complete path, the shell uses a list of directories (known as your PATH) to try and find the complete path to the command. For security and portability reasons, do shell script ignores the configuration files that an interactive shell would read"
    So, you need to use the full path to to ImageMagick commands, unlike in the shell where you can just use the command name.
    To batch process using Automator, use the “Run Shell Script” action (note: retain the single space at the beginning of the last line):
    /opt/ImageMagick/bin/mogrify \
    -alpha remove \
    -path /Users/Me/Desktop/OutPhotos/ \
    /Users/Me/Desktop/InPhotos/*png
    To batch process using Script Editor (Applescript), use the “do shell script” command:
    do shell script "/opt/ImageMagick/bin/mogrify -alpha remove -path /Users/pd/Desktop/OutPhotos/ /Users/pd/Desktop/InPhotos/*png"
    Further info on ImageMagick:
    http://www.imagemagick.org/script/command-line-options.php#alpha
    http://www.imagemagick.org/Usage/masking/#remove
    http://www.imagemagick.org/index.php
    http://www.imagemagick.org/script/command-line-tools.php
    http://www.imagemagick.org/script/command-line-options.php
    Examples:
    The original PNG image:
    -alpha off:
    -alpha remove:
    -background black -flatten:
    -background blue -flatten:
    -channel alpha -evaluate Divide 2:
    -channel alpha -evaluate Divide 2 -background black -flatten:

  • .png animation files... how to import keeping alpha channel please!

    My graphics man has buit me a animation on white swirly things on his system
    and given me them as sequential files.
    On gfx without alpha I open then in quicktime, open a sequential files then export to dv.
    Now of course dv will not keep alpha channels so any help on how to take this animation alpha .png and get it into my fcp time line would be much appreciated,
    regards
    daz

    Apple Animation is a high quality video codec that can support an alpha channel.
    While there are other formats that also support alpha channel, Apple Animation is the codec of choice on the Mac because it lets us transfer files between different software packages without any hassle.
    For instance, you could export a 3D scene from Maya, manipulate it further in After Effects then drop it into the FCP Timeline, all without converting it to something else at each stage.

  • Slightly distorted aspect-ratio (and missing alpha channel) when copy/paste from Photoshop

    Maybe this is an old topic (but I didn't find anything on google or this forum):
    When I copy images from Photoshop to Flash, the aspect ratio of the bitmap gets distorted. A 728x90 Bitmap becomes 727.6x90 (and so on...). The dpi is set on exactly 72 on both programs. Is there any way to JUST get a 1:1 pixel copy? (except using another program like Irfanview as a "man-in-the-middle")
    Although I selected "32 bit color w/alpha" in the clipboard settings of Flash, the alpha channel seems to get discarded when copying from Photoshop. Shouldn't it at least work with Photoshop? I mean, it's an Adobe product after all and maybe the most commonly used together with Flash.
    Would just be nice if a copy-paste between PS and FL was an easier thing.
    I know there can also be a pixel-aspect somewhere (like used for video productions and wide-screen), but I didn't find settings for that anywhere.
    I still use Flash Professional CS5.0

    I'm on windows7 with CS5.5 and transparency and size are copied over just fine. You answered what would be my first question, 72dpi. How about the image mode. Are you using RGB 8bit?
    I've had lots of issues with the OS not handling transparency very well also, such right-click on an image on a website that you know is a PNG and has transparency, then paste it into photoshop, the transparency isn't saved.
    The route that always works (but is a PITA) is of course to save it as a PNG with transparency and just import it.

  • AppleScript copy alpha channel from one document to a second document

    I have two documents. One with Alpha Channels, the other with none. I am trying to copy the alpha channels from one document into the second.
    When I use the following in PS 6, the action duplicates the channels in the same document, not in the second document. I am using PS 6 with both documents open in tabs. Any help appreciated.
    tell application "Adobe Photoshop CS6"
      set x to document 1
      set y to document 2
      set cc to number of channel of current document
      repeat with i from 5 to cc
      duplicate channel i of x to y
      end repeat
    end tell

    I can now copy-paste text frames and linked graphics from one document to another using snippets, but embedded images still don't work.
    If I embed an image from a pdf file it works but not for jpeg images. When I open the new document (for which I placed the snippet) in InDesign, there is a frame (with a dark grey background and a diagonal cross) shown, but no contents. The place() method did not throw an exception. What am I doing wrong?
    Chris.

  • Copying an alpha channel from one comp to another?

    I've created a green screen key using Primatte in one comp, and I want to use that same key in another comp, but where the background has since been replaced and rendered out with an effect I want to keep on the foreground subject. I bet it's something simple...
    Actually I bet that explanantion's confusing.
    Subject X is against green in a video in comp A.
    X was extracted using a key and rendered with an effect and a new background to creat video B.
    I want to extract subject X from B (and keep the new effect) using the alpha channel created in comp A.
    So how do I copy and paste the alpha channel from comp A to a new comp with video B in it?
    Cheers! 

    Pre-compose, use as a matte layer.
    Mylenium

  • Alpha channel from Quicktime into AE - broken?

    This has been driving me nuts for some time. I am generating an animation w/alpha channel from my 3D software (FormZ.) It creates a proprietary .fan file containing the animation frames, which is then converted to Quicktime. I am using the animation codec, max quality, millions+ colors. When I import the QT file into Aftereffects, I get the alpha channel pop-up - so it apparently recognizes that something is there - but whether I choose straight or premultiplied, I just get black for the alpha channel with jaggy edges.
    This is on OSX 10.5.5, QT 7.6, Adobe CS4. I have had the issue dating back a year or two, I had thought it was a bug that would be fixed by now - the same process used to work fine with older versions of AE and QT.
    Now - the kicker - when I boot into Windows XP and do the QT (7.5.5) conversion there - then take it back to OSX for import into AE - THE ALPHA CHANNEL WORKS PERFECTLY.
    I have talked with FormZ in the past, they recognize and have duplicated the problem. However, it is apparently a Quicktime issue so there is not much they can do about it.
    This seems like a pretty fundamental issue that I can't believe it would go uncorrected for so long. Why would the Mac version behave differently from the Windows version? Am I completely missing something in the Mac QT? I have played with the various transparency settings under Movie Properties (QT Pro) - but all I get is a dithered mess when I try to change those settings and bring it into AE. I can't even find much discussion of it - I found a reference to Quicktime 7.1.5 breaking alpha channels, but nothing very specific.

    Welcome to the discussions, austinpike.
    Normally, QuickTime should work the same on both systems. However, there are some deep differences in how the OS's work that mean the code isn't fully transportable, so there's a chance some things might get missed, or changed, etc.
    What you should do is go here.
    http://www.apple.com/quicktime/feedback
    And enter your details that you specified here. It could very well be that no one has reported this as an issue yet. I know I'd been perturbed by something in QuickTime I thought would just "get fixed" but a few versions after sending my bug, it was finally resolved. Hopefully, sending the feedback may put the wheels into motion to get it resolved for you.

  • 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>

Maybe you are looking for