UIImageのピクセルデータへの変換等をラップするライブラリ SoloComponents-iOS
たまたま見つけて、試してみました。
andreyvit / SoloComponents-iOS
iPhone/iPad components that are dead-easy to drop into your projects
- ATArrayView
- ATByteImage
- ATPagingView
という3つのクラスが入っています。
ATArrayView
デモプロジェクトを実行してみると、ATPagingViewは普通のUIScrollView使ったページング処理・・・
ATArrayView
デモプロジェクトを実行してみると、
お、NSArrayの要素をUITableViewじゃなくてこういう感じに見せてくれるのはよさそう。
(でもThree20にこういうのあったような)
ATByteImage
デモプロジェクトがなかったので、ヘッダファイルみてみると
-(id)initWithSize:(CGSize)size; -(id)initWithCGImage:(CGImageRef)image; -(id)initWithImage:(UIImage *)image; - (ATByteImage *)copy; - (UIImage *)image; // image with a copy of bytes - (UIImage *)imageNoCopyData; // image with the current bytes ― be sure not to modify the bytes! - (UIImage *)extractImage; // passes ownership of the bytes to the returned image, sets bytes to NULL - (ATByteImageContext *)newContext; - (ATByteImageContext *)context; @property(nonatomic, readonly, assign) NSUInteger width; @property(nonatomic, readonly, assign) NSUInteger height; @property(nonatomic, readonly, assign) CGSize size; @property(nonatomic, readonly, assign) NSUInteger byteCount; @property(nonatomic, readonly, assign) NSUInteger bytesPerPixel; @property(nonatomic, readonly, assign) NSUInteger bytesPerRow; @property(nonatomic, readonly, assign) NSUInteger bitsPerComponent; @property(nonatomic, readonly, assign) unsigned char *bytes; @property(nonatomic, readonly, assign) CGColorSpaceRef colorSpace; -(void)clear; -(void)invert; -(void)replaceColorWithRed:(unsigned char)red green:(unsigned char)green blue:(unsigned char)blue;
UIImageからピクセルデータにアクセスできるようにするあたりのCoreGraphicsの煩雑な手順(CGDataProviderRefを生成したりとか)をラップしてくれてるもよう。よさげ。