CCSprite 上的噪声
我使用 CCSprite 使我的项目显示简单的纹理。
但我发现纹理包含一些微小的噪点、黑色像素错误。
我使用代码将png文件分成小块。并将其添加到主视图中。
并非所有的设备都有噪音,但有些设备有噪音。
我不知道原因。
请发送您的意见。
CCSprite *sprite = [[CCSprite spriteWithFile:[NSString stringWithUTF8String:name] rect:CGRectMake(startx, starty, w, h)] retain];
float drawX = x, drawY = y;
CGSize size = [sprite contentSize];
int nWidth = size.width;
int nHeight = size.height;
nWidth *= scale;
nHeight *= scale;
drawX = drawX + nWidth/2;
drawY = drawY - nHeight/2;
ConvertCoordf(&drawX, &drawY);
drawY -= nHeight;
[sprite setScale:scale];
[sprite setPosition:ccp(drawX, drawY)];
[_mainLayer addChild:sprite];
[sprite release];
I made my project to show simple texture by using CCSprite.
But I found that the texture contains some tiny noise , black pixel bug.
I divided the png file into small piece by using code. And add it to the mainview.
Not all of them have noise, But some of them have it.
I can't know the reason.
Please send your opinion.
CCSprite *sprite = [[CCSprite spriteWithFile:[NSString stringWithUTF8String:name] rect:CGRectMake(startx, starty, w, h)] retain];
float drawX = x, drawY = y;
CGSize size = [sprite contentSize];
int nWidth = size.width;
int nHeight = size.height;
nWidth *= scale;
nHeight *= scale;
drawX = drawX + nWidth/2;
drawY = drawY - nHeight/2;
ConvertCoordf(&drawX, &drawY);
drawY -= nHeight;
[sprite setScale:scale];
[sprite setPosition:ccp(drawX, drawY)];
[_mainLayer addChild:sprite];
[sprite release];
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于每张图像,其周围都有一些噪声像素(仅 1 个像素)。例如,如果你想包含一张30px*30px的图片,你最好把它做成31px*31px的图片,并将你的图片放在中间。也就是说,用1px包围你的图片。
For every image, it has some noise pixel around it (Only 1 pixel). For example, if you want to include an image with 30px*30px, you'd better make it into a 31px*31px image and put your image in the middle of it.In other words, surround your image with 1px.