小编New*_*ack的帖子

如何创建NSImage的8位,4位和1位表示

我用以下代码创建了32位NSImage.

 NSBitmapImageRep *sourceRep = [[NSBitmapImageRep alloc] initWithData: imageData];

        // create a new bitmap representation scaled down

            NSBitmapImageRep *newRep = 
                [[NSBitmapImageRep alloc] 
                    initWithBitmapDataPlanes: NULL
                    pixelsWide: imageSize
                    pixelsHigh: imageSize
                    bitsPerSample: 8
                    samplesPerPixel: 4
                    hasAlpha: YES
                    isPlanar: NO
                    colorSpaceName: NSCalibratedRGBColorSpace
                    bytesPerRow: 0
                    bitsPerPixel: 0];

            // save the graphics context, create a bitmap context and set it as current
            [NSGraphicsContext saveGraphicsState] ;
            NSGraphicsContext *context = [NSGraphicsContext graphicsContextWithBitmapImageRep: newRep];
            [NSGraphicsContext setCurrentContext: context] ;

            // draw the bitmap image representation in it and restore the context …
Run Code Online (Sandbox Code Playgroud)

macos cocoa nsimage nsbitmapimagerep

10
推荐指数
1
解决办法
1395
查看次数

如何将背景颜色设置为IKImageBrowserView

我是可可的新手......我正在创造一个色彩缤纷的窗户.所以我需要设置背景颜色IKImageBrowserView.我认为子类化IKImageBrowserView是设置背景颜色的方法,但对我来说太难了..还有其他方法来设置背景颜色而不进行子类化吗?

cocoa osx-snow-leopard ikimagebrowserview

0
推荐指数
1
解决办法
612
查看次数