손가락 터치 사용 비트 맵을 그립니다.화면에 비트 맵 그리기가 흐리게 ???
먼저 비트 맵에 선을 그립니다.
그런 다음 비트 맵을 화면에 그립니다.
하지만이 방법을 사용하면 선이 흐려집니다.
아래는 비교입니다.
PICTURE1 직접 스크린 상에 드로잉된다. picture2가 비트 맵을 사용 중입니다. 내 코드는 다음과 같습니다.
- (BOOL)CreateBitmapContext:(int)pixelsWide High:(int)pixelsHight
{
CGColorSpaceRef colorSpace;
void * bitmapData;
int bitmapByteCount;
int bitMapBytesPerRow;
bitMapBytesPerRow = (pixelsWide * 4);
bitmapByteCount = (bitMapBytesPerRow * pixelsHight);
colorSpace = CGColorSpaceCreateDeviceRGB();
bitmapData = malloc(bitmapByteCount);
if (bitmapData == NULL)
{
CGColorSpaceRelease(colorSpace);
return NO;
}
tempContext = CGBitmapContextCreate(bitmapData, pixelsWide, pixelsHight, 8, bitMapBytesPerRow, colorSpace, kCGImageAlphaPremultipliedLast);
if (tempContext == NULL)
{
CGColorSpaceRelease(colorSpace);
free(bitmapData);
return NO;
}
CGColorSpaceRelease(colorSpace);
return YES;
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
CGPoint p = [touch locationInView:self];
[tool setFirstPoint:p];
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
CGPoint p = [touch locationInView:self];
CGPoint previous = [touch previousLocationInView:self];
[tool moveFromPoint:previous toPoint:p];
[tool draw:tempContext];
[self setNeedsDisplay];
}
- (void)drawRect:(CGRect)rect
{
// Drawing code
CGContextRef myContext = UIGraphicsGetCurrentContext();
myImage = CGBitmapContextCreateImage (tempContext);// 5
CGContextDrawImage(myContext, rect, myImage);// 6
}
그래서 무엇이 잘못 되었습니까 ??
누구나?
망막 장치의 컨텍스트에 두 배의 너비와 너비를 사용해야합니다. – yinkou