Прежде всего, необходимый код был добавлен к INAppStoreWindow
, поэтому у меня больше нет вариантов для этого.Однако для людей, которые хотели бы знать, как это сделать, вот как это делается с помощью INAppStoreWindow
.
Сначала создается функция для создания изображения с шумом.
static CGImageRef createNoiseImageRef(NSUInteger width, NSUInteger height, CGFloat factor)
{
NSUInteger size = width*height;
char *rgba = (char *)malloc(size); srand(124);
for(NSUInteger i=0; i < size; ++i){rgba[i] = rand()%256*factor;}
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceGray();
CGContextRef bitmapContext =
CGBitmapContextCreate(rgba, width, height, 8, width, colorSpace, kCGImageAlphaNone);
CFRelease(colorSpace);
free(rgba);
CGImageRef image = CGBitmapContextCreateImage(bitmapContext);
CFRelease(bitmapContext);
return image;
}
Затемизображение используется для наложения шума на текущую графику
static CGImageRef noisePattern = nil;
if (noisePattern == nil) noisePattern = createNoiseImageRef(128, 128, 0.015);
[NSGraphicsContext saveGraphicsState];
[[NSGraphicsContext currentContext] setCompositingOperation:NSCompositePlusLighter];
CGRect noisePatternRect = CGRectZero;
noisePatternRect.size = CGSizeMake(CGImageGetWidth(noisePattern), CGImageGetHeight(noisePattern));
CGContextRef context = [[NSGraphicsContext currentContext] graphicsPort];
CGContextDrawTiledImage(context, noisePatternRect, noisePattern);
[NSGraphicsContext restoreGraphicsState];