第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

獲取UIImage的Pixel顏色

獲取UIImage的Pixel顏色

iOS
元芳怎么了 2019-09-20 16:12:15
如何獲取UIImage中特定像素的RGB值?
查看完整描述

3 回答

?
慕哥9229398

TA貢獻(xiàn)1877條經(jīng)驗(yàn) 獲得超6個(gè)贊

您無法直接訪問原始數(shù)據(jù),但通過獲取此圖像的CGImage,您可以訪問它。這里是另一個(gè)問題的鏈接,可以回答您的問題以及您可能擁有的有關(guān)詳細(xì)圖像處理的其他問題:CGImage


查看完整回答
反對(duì) 回復(fù) 2019-09-20
?
holdtom

TA貢獻(xiàn)1805條經(jīng)驗(yàn) 獲得超10個(gè)贊

試試這個(gè)非常簡(jiǎn)單的代碼:


我曾經(jīng)在我的迷宮游戲中檢測(cè)到墻壁(我需要的唯一信息是alpha通道,但我包含了代碼以獲取其他顏色):


- (BOOL)isWallPixel:(UIImage *)image xCoordinate:(int)x yCoordinate:(int)y {


    CFDataRef pixelData = CGDataProviderCopyData(CGImageGetDataProvider(image.CGImage));

    const UInt8* data = CFDataGetBytePtr(pixelData);


    int pixelInfo = ((image.size.width  * y) + x ) * 4; // The image is png


    //UInt8 red = data[pixelInfo];         // If you need this info, enable it

    //UInt8 green = data[(pixelInfo + 1)]; // If you need this info, enable it

    //UInt8 blue = data[pixelInfo + 2];    // If you need this info, enable it

    UInt8 alpha = data[pixelInfo + 3];     // I need only this info for my maze game

    CFRelease(pixelData);


    //UIColor* color = [UIColor colorWithRed:red/255.0f green:green/255.0f blue:blue/255.0f alpha:alpha/255.0f]; // The pixel color info


    if (alpha) return YES;

    else return NO;


}


查看完整回答
反對(duì) 回復(fù) 2019-09-20
  • 3 回答
  • 0 關(guān)注
  • 514 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)