Pregunta

Este proyecto es un C ++ genérico plugin con soporte de núcleo de gráficos. Soy incapaz de convertir un PicHandle a CGImageRef éxito. El ahorro de imagen a partir de CFDataRef se traduce en una mala imagen.

    if(pic)
{
    Handle thePictureFileHandle;
    thePictureFileHandle = NewHandleClear(512); 
    HandAndHand((Handle)pic,thePictureFileHandle);

    dataProvider= CGDataProviderCreateWithData(NULL,(void*)*thePictureFileHandle,GetHandleSize( (Handle)thePictureFileHandle ),NULL );
    CFDataRef data = CGDataProviderCopyData(dataProvider);
    CGImageSourceRef source = CGImageSourceCreateWithDataProvider(dataProvider, NULL);
    if ( source )
    {
        cgImageRef = CGImageSourceCreateImageAtIndex(source, 0, NULL);
    }
    CGDataProviderRelease(dataProvider);
    CFRelease( source );
    CFRelease( data );
}
¿Fue útil?

Solución

En CGImageSourceCreateImageAtIndex, tiene que pasar el diccionario diciendo que sus datos es una PICT. Consulte la documentación de Apple aquí . Es necesario hacer algo como

CFDictionaryRef   myOptions = NULL;
CFStringRef       myKeys[1];
CFTypeRef         myValues[1];

myKeys[0] = kCGImageSourceTypeIdentifierHint;
myValues[0] = (CFTypeRef)kUTTypePICT;
myOptions = CFDictionaryCreate(NULL, (const void **) myKeys,
               (const void **) myValues, 1,
               &kCFTypeDictionaryKeyCallBacks,
               & kCFTypeDictionaryValueCallBacks);

cgImageRef = CGImageSourceCreateImageAtIndex(source, 0, myOptions);

CFRelease(myOptions);
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top