0 Replies Latest reply: Jun 28, 2014 8:27 PM by diamondcg RSS

    Alpha channel data with layered format plugin

    diamondcg

      I have a layered format plugin and I am trying to write the alpha channel information separately. I have set up channelPortProcs and I am attempting to read the pixel data with readPixelsProc. The issue is that even though the readPixelsProc function doesn't return any errors the rectangle that is supposed to store the rectangle that was actually read is a 0x0 rectangle. I can't seem to find why this would be or what I might be doing wrong. Here's what I have so far:

      // set up the pixel buffer
      int32 bufferSize = imSize.h*imSize.v;
      Ptr pixelData = sPSBuffer->New( &bufferSize, bufferSize );
      if (pixelData == NULL)
      {
           *gResult = memFullErr;
           return;
      }
      
      // Define the source and destination rectangles
      ReadChannelDesc *alphaChannel = gFormatRecord->documentInfo->alphaChannels;
      PIChannelPort port = alphaChannel->port;
      PSScaling scale;
      scale.sourceRect = scale.destinationRect = alphaChannel->bounds;
      VRect destRect = scale.sourceRect;
      
      // Set up the descriptor for reading pixel data
      VRect wroteRect = {0};
      PixelMemoryDesc dest = {0};
      dest.rowBits = imSize.h*alphaChannel->depth;
      dest.colBits = alphaChannel->depth;
      dest.depth = alphaChannel->depth;
      dest.data = pixelData;
      
      // Put the pixel data into the buffer
      *gResult = gFormatRecord->channelPortProcs->readPixelsProc(port,&scale, &destRect, &dest, &wroteRect);
      if(*gResult != noErr)
           return;
      

       

      The alpha channel gives me the proper name, but I just can't get the data associated with it. Thanks.