CGBitmapContextCreate with kCGImageAlphaNone

后端 未结 1 2002
面向向阳花
面向向阳花 2020-12-08 15:59

I desperately need to create a CGContextRef WITHOUT an alpha channel. Unfortunately, with Core Graphics you CANNOT specify kCGImageAlphaNone with CGBitmapCreateContext.

相关标签:
1条回答
  • 2020-12-08 16:26

    You can create a bitmap context with no alpha channel. You just can't create a bitmap context with three bytes per pixel. Here's the secret handshake:

    CGContextRef gc = CGBitmapContextCreate(NULL, myWidth, myHeight, 8, myWidth * 4,
        myColorSpace, kCGImageAlphaNoneSkipLast);
    
    0 讨论(0)
提交回复
热议问题