2
저는 CMYK 색상 공간으로 비트 맵 컨텍스트를 만들고 이미지를 그릴 수있는 방법을 찾으려고합니다.CMYK 색상 공간을 사용하여 CGBitmapContext를 만들고 그 안에 그림을 그릴 수 있습니까?
나는 Apple의 Q & A here의 코드를 사용하여 CMYK 색상 공간을 만들고 그 안에 그려 넣습니다. 4 개 구성 요소, 8 비트 요소 당 32 비트 픽셀 당
를 내가 널 컨텍스트를 반환받을 - 내 로그에서 나는 오류를
지원되지 않는 픽셀 설명을 얻을.
무엇이 누락 되었습니까? 다음 코드는 실행하려고 시도하는 코드입니다.
CGContextRef context = NULL; CGColorSpaceRef colorSpace; void * bitmapData; int bitmapByteCount; int bitmapBytesPerRow; // Get image width, height. We'll use the entire image. size_t pixelsWide = CGImageGetWidth(inImage); size_t pixelsHigh = CGImageGetHeight(inImage); // Declare the number of bytes per row. Each pixel in the bitmap in this // example is represented by 4 bytes; bitmapBytesPerRow = (pixelsWide * 4); bitmapByteCount = (bitmapBytesPerRow * pixelsHigh); // Use the generic CMYK color space. colorSpace = CGColorSpaceCreateDeviceCMYK(); if (colorSpace == NULL) { fprintf(stderr, "Error allocating color space\n"); return NULL; } // Allocate memory for image data. This is the destination in memory // where any drawing to the bitmap context will be rendered. bitmapData = malloc(bitmapByteCount); if (bitmapData == NULL) { fprintf (stderr, "Memory not allocated!"); CGColorSpaceRelease(colorSpace); return NULL; } // Create the bitmap context. We don't need alpha. Regardless of what the source image format is // (CMYK, Grayscale, and so on) it will be converted over to the format // specified here by CGBitmapContextCreate. context = CGBitmapContextCreate (bitmapData, pixelsWide, pixelsHigh, 8, // bits per component bitmapBytesPerRow, colorSpace, kCGImageAlphaNone); if (context == NULL) { free (bitmapData); fprintf (stderr, "Context not created!"); } // Make sure and release colorspace before returning CGColorSpaceRelease(colorSpace); return context;
미리 감사드립니다. -SYU
그것은 내가 생각한 것입니다. 어쨌든 고마워요. –