如何设置UIImage的像素的RGBA颜色 [英] How to set RGBA Color of a Pixel of an UIImage
问题描述
我正在寻找一个可能性来设置(更改)我的Iphone应用程序的UIImage像素的RGBA颜色。 (我实际上想实现一些floodfill的东西)
所以我需要这样:
- (void)setPixelColorOfImage:(UIImage *)img atXCord:(int)x atYCord:(int)y
withRedColor:(CGFloat)red blueColor:(CGFloat)blue greenColor:(CGFloat) green
alpha:(CGFloat)alpha {
//需要一些代码her
}
因为这个方法会被频繁调用,所以不应该太慢。
请帮助。
UIImage不是,所以你必须复制,然后编辑,然后转换为UIImage。
复制
- 创建CGBitmapContext
-
- 在其上绘制源图片
转换为UIImage fwiw创建一个新的UIImage,在osx上使用(使用NSImage)。 I am looking for a possibility to set (change) the RGBA color of a Pixel of an UIImage for my Iphone Application. (I actually want to implement some floodfill stuff) So I need something like this: Because this method will be called quite often, it shouldn't be too slow. Please help. UIImage is not (externally) mutable, so you must copy, then edit, then convert to UIImage. Copy Edit Convert to UIImage fwiw, the form can also be used on osx (using NSImage). 这篇关于如何设置UIImage的像素的RGBA颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
-(void) setPixelColorOfImage: (UIImage*) img atXCord: (int) x atYCord: (int) y
withRedColor: (CGFloat) red blueColor: (CGFloat) blue greenColor: (CGFloat) green
alpha: (CGFloat) alpha {
// need some code her
}