At 8:37 AM -0800 12/18/04, Andreas Wittenstein wrote:
Jim,
Try setting the 'cmpCount' of the GWorld to 4. Apple's BMP encoder
doesn't support alpha, but if the decoder does, that should do the
trick.
Thanks for the idea, but it didn't work. What's interesting is that
for the BMP files that actually contain an alpha channel, the info
returned from GraphicsImportGetImageDescription() tells me that the
image depth is 32, which indicates that it does recognize that it has
an alpha channel. For BMP's without alpha channels, the image depth
is 24.
Below is the code I'm using, with error checking removed and the code
for allocating the GWorld stripped out. Anyone have any ideas how to
make this work?
BTW the same problem happens on either OS 9 or OS X.
// Create a BMP graphics importer component
::OpenADefaultComponent(GraphicsImporterComponentType,
kQTFileTypeBMP, &theImporter);
// Specify where the graphics data lives (in this case I'm loading
// BMP data from memory, which is the contents of an actual BMP file
// stored in a resource.
::GraphicsImportSetDataHandle(theImporter, theBMPGraphicH);
// Get the native size of the image associated with the importer
theComponentResult = ::GraphicsImportGetNaturalBounds(theImporter,
&theGWorldRect);
// Code snipped - set up 32-bit GWorld with size theGWorldRect,
// and LockPixels on pixmap
[...]
// Get some info about the image
ImageDescriptionHandle theImageDescH;
::GraphicsImportGetImageDescription(theImporter, &theImageDescH)
// Depth of 32 means has alpha
if ((*theImageDescH)->depth == 32)
{
// Do we have to set cmpCount manually to 4 to get alpha channel?
PixMapHandle thePixMapH = ::GetGWorldPixMap(theMacGWorld);
(*thePixMapH)->cmpCount = 4;
}
::DisposeHandle((Handle)theImageDescH);
// Set the graphics port for drawing
::GraphicsImportSetGWorld(theImporter, theMacGWorld, nil);
// Draw the image
::GraphicsImportDraw(theImporter);
I have some BMP format data which contains an alpha channel. I am
trying to load this image into a 32-bit GWorld (created with
NewGWorld), and preserve the alpha channel in the upper byte of
each pixel. At some later point I would then draw this GWorld
using the alpha channel using DecompressImage() with one of the
alpha transfer graphics modes. I've got the BMP graphics importer
set up and drawing the image into the GWorld using
GraphicsImportDraw(), but it doesn't preserve the alpha channel.
Is there something special I need to do to get it to copy the alpha
channel as well as the RGB data into the GWorld?
Thanks,
Jim
_______________________________________________
Do not post admin requests to the list. They will be ignored.
QuickTime-API mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/quicktime-api/email@hidden