2009-07-24 3 views
0

私はUIViewサブクラス(TraceView)の幅が200 x 100で、ピクセル単位で描画しようとしています。この場合、私は横方向の75%を占める水平の青線を描こうとしています。代わりに、私は2つの垂直な青い線(端に1つ、中間に1つ)を得て、その75%は上に行く。私が使用しているCGLayerが90度回転して50%縮小したようです。これを修正するために私は何ができますか? .mファイルの上部に CGLayerが間違った方法で表示される

#define WORLD_WIDTH 200 
#define WORLD_HEIGHT 100 
#define ABGR_BYTES 4 

@implementation TraceView 

int theImage[WORLD_WIDTH][WORLD_HEIGHT]; 

オーバーライドのdrawRect:

- (void)drawRect:(CGRect)rect { 

    CGContextRef theViewContext = UIGraphicsGetCurrentContext(); 
    CGLayerRef theCGLayer = CGLayerCreateWithContext(theViewContext, rect.size, nil); 
    CGContextRef theCGLayerContext = CGLayerGetContext(theCGLayer); 

    CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); 
    CGContextRef bitmapContext = CGBitmapContextCreate(theImage, WORLD_WIDTH, WORLD_HEIGHT, 8, WORLD_WIDTH * ABGR_BYTES, colorSpace, kCGImageAlphaPremultipliedLast); 

    // is ABGR 
    for(int i=0;i<150;i++) { 
     theImage[i][0]=0xFFFF0000; 
    } 

    CGImageRef image = CGBitmapContextCreateImage(bitmapContext); 
    CGContextDrawImage(theCGLayerContext, rect, image); 
    CGContextDrawLayerInRect(theViewContext, rect, theCGLayer); 

} 

答えて

1

OK、私はそれが働いてしまった、私の愚かな。

Image [x] [y]ではなく配列をtheImage [y] [x]として扱えば問題なく動作します。

関連する問題