我需要將圖像繪製到CALayer中,因爲我需要對其執行各種效果,動畫和濾鏡。當我做簡單的CGContext繪圖時,無論我做什麼,它總是被繪製爲像素化... 什麼是正確的方式來繪製在視網膜上下文?Retina中的CGContextDrawImage繪製圖像像素化?
這是我現在在做什麼:
CGImageRef plateImage = [[UIImage imageNamed:@"someImage"] CGImage];
CGFloat width = CGImageGetWidth(plateImage), height = CGImageGetHeight(plateImage);
CGFloat scale = [[UIScreen mainScreen] scale];
NSLog(@"Scale: %f\nWidth: %f\nHeight: %f", scale, width, height);
CGContextTranslateCTM(_context, 0, height/scale);
CGContextScaleCTM(_context, 1.0, -1.0);
CGContextDrawImage(_context, CGRectMake(0, 0, width/scale, height/scale), plateImage);
Aaaaaa!我在CG文檔中無處不在 - 一分鐘沒有想到它是一個圖層問題!謝謝! – shein 2012-02-25 17:02:12
令人驚歎。謝謝。 – darkheartfelt 2014-01-29 19:18:38