2009-08-27 18 views
0

私はデータベースから小さな画像を持っており、画像の平均色を少し変更する必要があります。iPhone:画像の色を変更する方法

それはCGImageRefだと私は、CGContextを作成し、このコンテキストに画像を描画、その後何とかビットマップデータを変更し、最終的にそれをレンダリングすると考えます。 しかし、どのように色情報を変更できますか?

ありがとうございました!

答えて

0

は、このようなオブジェクトに色を描画します:カスタムUIViewの方法:

// first draw image 
    [self.image drawInRect:rect]; 

    // prepare the context to draw into 
    CGContextRef context = UIGraphicsGetCurrentContext(); 

    // set the blend mode and draw rectangle on top of image 
    CGContextSetBlendMode(context, kCGBlendModeColor); 
    CGContextClipToMask(context, self.bounds, image.CGImage); // this restricts drawing to within alpha channel 
    CGContextSetRGBFillColor(context, 0.75, 0.0, 0.0, 1.0); // this is your color, a light reddish tint 
    CGContextFillRect(context, rect);  

を私はのdrawRectにこれを置きます。 UIViewには色合いや色を付ける画像を保持するivar、UIImage *画像があります。

+0

ありがとうございましたが、私はそれ自身ですべてのピクセルを変更する必要がありました。 –

関連する問題