As it says on the can; here is an example of why I need it:
正如它在罐头上所说;这是我需要它的一个例子:
Let's say I create a bitmap context:
假设我创建了一个位图上下文:
size_t pixelCount = dest_W * dest_H;
typedef struct {
uint8_t r,g,b,a;
} RGBA;
// backing bitmap store
RGBA* pixels = calloc( pixelCount, sizeof( RGBA ) );
// create context using above store
CGContextRef X_RGBA;
{
size_t bitsPerComponent = 8;
size_t bytesPerRow = dest_W * sizeof( RGBA );
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
// create a context with RGBA pixels
X_RGBA = CGBitmapContextCreate( (void *)pixels, dest_W, dest_H,
bitsPerComponent, bytesPerRow,
colorSpace, kCGImageAlphaNoneSkipLast
);
assert(X_RGBA);
CGColorSpaceRelease(colorSpace);
}
Now I want to throw this context to a drawing function that will eg draw a circle touching the edges:
现在我想把这个上下文抛给一个绘图函数,例如绘制一个接触边缘的圆圈:
Do I really need to throw in the width and height as well? I am 99% sure I have seen some way to extract the width and height from the context, but I can't find it anywhere.
我是否真的需要投入宽度和高度?我99%肯定我已经看到从上下文中提取宽度和高度的某种方法,但我无法在任何地方找到它。
1 个解决方案
#1
6
CGBitmapContextGetWidth // and Height
NB width and height probably don't make sense to a non-bitmap CGContextRef
NB宽度和高度可能对非位图CGContextRef没有意义
Thanks @ wiliz on #iphonedev
谢谢@ wiliz在#iphonedev上
#1
6
CGBitmapContextGetWidth // and Height
NB width and height probably don't make sense to a non-bitmap CGContextRef
NB宽度和高度可能对非位图CGContextRef没有意义
Thanks @ wiliz on #iphonedev
谢谢@ wiliz在#iphonedev上