Hi,
I want to draw the JPEG image (which is in Memory) onto Gworld
using correspoding image importer component. Handle to the memory is
available and image importer handle has been set using
GraphicsImportSetDataHandle. The code snippet is shown below.
Everything is fine till GraphicsImportDraw. But GraphicsImportDraw
is returning codecBadDataErr (-8969). When GetGraphicsImporterForFile
is used to open the same file then GraphicsImportDraw is successful and
showing the image on window.
Pls suggest why this error is occurred and how can it be fixed?
Handle imageDataHandle = 0;
//err = GetGraphicsImporterForFile( &theFSSpec, &importer );
theFile = fopen("Part 1:data6.jpg", "r"); fseek(theFile, 0, SEEK_END);
dataSize = ftell(theFile);
fseek(theFile, 0, SEEK_SET);
imageDataHandle = NewHandleClear(dataSize);
i = fread(*imageDataHandle, 1, dataSize, theFile);
err = OpenADefaultComponent(GraphicsImporterComponentType, kQTFileTypeJPEG, &importer);
if(err == noErr)
{ result = GraphicsImportSetDataHandle(importer, imageDataHandle);
}
err = GraphicsImportGetNaturalBounds( importer, &bounds );
OffsetRect( &bounds, 10, 45 );
window = NewCWindow( NULL, &bounds, "\pDraw Image", true, documentProc, (WindowPtr)-1, true, 0);
err = GraphicsImportSetGWorld( importer, GetWindowPort( window ), NULL );
err = GraphicsImportDraw( importer );
CloseComponent( importer );
DisposeHandle(imageDataHandle);
Thanks and Regards,
Sivaram Prasad Nakkala