我正在开发一个应用程序,它必须以下列方式使用像素操作:围绕一个点(x,y)我必须在半径为 R 的圆中压缩或扩展像素,但我想保持矩形框用户界面图像。我通过以下方式获取原始数据(我在网上找到了这个):
CGImageRef imageRef = image.CGImage;
NSUInteger width = CGImageGetWidth(imageRef);
NSUInteger height = CGImageGetHeight(imageRef);
CFDataRef dataref = CopyImagePixels(imageRef);
unsigned char *rawData = CFDataGetBytePtr(dataref);
所以,我在 rawData 中有像素数据。
int byteIndex = 0;
for (int ii = 0 ; ii < width * height ; ++ii)
{
//now rawData[baseIndex] stands for red
//rawData[baseIndex + 1] stands for green
//rawData[baseIndex + 2] stands for blue
byteIndex += 4;
}
现在,我如何知道当前像素是否在原点(x,y)和半径 R 的圆内?以及如何压缩/扩展这些像素?
谢谢