내가 objective-c 및 mac 개발 (비록 내가 C와 잘 맞지만)으로 무엇을하고 있는지 전혀 알지 못한다는 것을 먼저 알려주기 바란다. 기본적으로 텍스트 파일을 입력하고 편안한 PNG 파일을 (이 명령 줄 유틸리티입니다) 글을Quartz 2d 파이썬 데모에서 순수 코어 그래픽 C
http://developer.apple.com/graphicsimaging/pythonandquartz.html
: 나는 파이썬 바인딩 석영 - 2D와 표범의 멋지고 간단한 그래픽 유틸리티를했다. 유틸리티를 Snow Leopard 서버로 옮기고 Snow Leopard에서 CoreGraphics 및 32 비트 Python과 관련된 모든 종류의 문제가 발견 될 때까지 나는 진흙탕에서 돼지처럼 행복했습니다. 이 쟁점 중 일부는 용해성이고 일부는 용해성이 아닙니다. 그래서, 나는이 간단한 유틸리티 스크립트를 objective-c (정말로 C라고 생각합니다)에 포팅하여 몇 가지 문제로 돌리고 있습니다. 다른 사람들은 python과 quartz로 제공되는 것과 거의 비슷한 멋진 예제가 있는지 알고 있지만, 모두 원시 코드로되어 있나?
내 주요 문제는 파일
myBitmapContext = MyCreateBitmapContext (400, 300);
CGContextSetRGBFillColor (myBitmapContext, 1, 0, 0, 1);
CGContextFillRect (myBitmapContext, CGRectMake (0, 0, 200, 100));
CGContextSetRGBFillColor (myBitmapContext, 0, 0, 1, .5);
CGContextFillRect (myBitmapContext, CGRectMake (0, 0, 100, 200));
CGImageRef myImage = CGBitmapContextCreateImage (myBitmapContext);// 5
CGContextDrawImage(myBitmapContext, myBoundingBox, myImage);// 6
char *bitmapData = CGBitmapContextGetData(myBitmapContext); // 7
// I'd like to write to a file here!
CGContextRelease (myBitmapContext);// 8
if (bitmapData) free(bitmapData); // 9
CGImageRelease(myImage);
MyCreateBitmapContext에 그래픽 컨텍스트를 쓰는 것은 apple's guide on quartz 2d에서 간단한 함수입니다.
TL; DR 위의 링크에서 제공된 Python 데모의 C 포트를 가진 사람이 있습니까?
코어 grahpics에서 어리석은 데모였습니다. 나는 내가 이미지 I/O에서 찾고있는 것을 발견했다고 생각한다. http://developer.apple.com/mac/library/documentation/GraphicsImaging/Conceptual/ImageIOGuide/ikpg_dest/ikpg_dest.html. 그래도 알아 줘서 고마워! – Ralphleon
예, CGImageDestination과 CGImageSource는 ImageIO 프레임 워크의 두 클래스입니다.하지만 CoreIC의 일부로 간주됩니다. –