相关疑难解决方法(0)

将RGBA颜色转换为RGB

如何将RGBA颜色元组(例如96,96,96,202)转换为相应的RGB颜色元组?

编辑:

我想要的是在白色背景上获得与RGBA元组最相似的RGB值.

rgb image colors

74
推荐指数
4
解决办法
6万
查看次数

iOS在两种颜色之间的点处查找颜色

我有一个问题:我需要能够采用两种颜色并从中制作出"虚拟渐变".然后,我需要能够在此行的任何位置找到颜色.我目前的做法是:

if (fahrenheit < kBottomThreshold)
{
    return [UIColor colorWithRed:kBottomR/255.0f green:kBottomG/255.0f blue:kBottomB/255.0f alpha:1];
}
if (fahrenheit > kTopThreshold)
{
    return [UIColor colorWithRed:kTopR/255.0f green:kTopG/255.0f blue:kTopB/255.0f alpha:1];
}

double rDiff = kTopR - kBottomR;
double gDiff = kTopG - kBottomG;
double bDiff = kTopB - kBottomB;

double tempDiff = kTopThreshold - kBottomThreshold;

double rValue;
double gValue;
double bValue;

rValue = kBottomR + ((rDiff/tempDiff) * fahrenheit);
gValue = kBottomG + ((gDiff/tempDiff) * fahrenheit);
bValue = kBottomB + ((bDiff/tempDiff) * fahrenheit);

return [UIColor colorWithRed:rValue/255.0f green:gValue/255.0f …
Run Code Online (Sandbox Code Playgroud)

gradient blending linear-gradients uicolor ios

9
推荐指数
4
解决办法
3091
查看次数

标签 统计

blending ×1

colors ×1

gradient ×1

image ×1

ios ×1

linear-gradients ×1

rgb ×1

uicolor ×1