本文整理汇总了C++中app::Color::getGray方法的典型用法代码示例。如果您正苦于以下问题:C++ Color::getGray方法的具体用法?C++ Color::getGray怎么用?C++ Color::getGray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app::Color
的用法示例。
在下文中一共展示了Color::getGray方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: color_for_ui
ui::Color color_utils::color_for_ui(const app::Color& color)
{
ui::Color c = ui::ColorNone;
switch (color.getType()) {
case app::Color::MaskType:
c = ui::ColorNone;
break;
case app::Color::RgbType:
case app::Color::HsvType:
c = ui::rgba(color.getRed(),
color.getGreen(),
color.getBlue(), 255);
break;
case app::Color::GrayType:
c = ui::rgba(color.getGray(),
color.getGray(),
color.getGray(), 255);
break;
case app::Color::IndexType: {
int i = color.getIndex();
ASSERT(i >= 0 && i < (int)get_current_palette()->size());
uint32_t _c = get_current_palette()->getEntry(i);
c = ui::rgba(rgba_getr(_c),
rgba_getg(_c),
rgba_getb(_c), 255);
break;
}
}
return c;
}
示例2: onSetColor
void ColorSliders::onSetColor(const app::Color& color)
{
setAbsSliderValue(Channel::Red, color.getRed());
setAbsSliderValue(Channel::Green, color.getGreen());
setAbsSliderValue(Channel::Blue, color.getBlue());
setAbsSliderValue(Channel::HsvHue, int(color.getHsvHue()));
setAbsSliderValue(Channel::HsvSaturation, int(color.getHsvSaturation() * 100.0));
setAbsSliderValue(Channel::HsvValue, int(color.getHsvValue() * 100.0));
setAbsSliderValue(Channel::HslHue, int(color.getHslHue()));
setAbsSliderValue(Channel::HslSaturation, int(color.getHslSaturation() * 100.0));
setAbsSliderValue(Channel::HslLightness, int(color.getHslLightness() * 100.0));
setAbsSliderValue(Channel::Gray, color.getGray());
setAbsSliderValue(Channel::Alpha, color.getAlpha());
}
示例3: color_for_allegro
int color_utils::color_for_allegro(const app::Color& color, int depth)
{
int c = -1;
switch (color.getType()) {
case app::Color::MaskType:
c = get_mask_for_bitmap(depth);
break;
case app::Color::RgbType:
case app::Color::HsvType:
c = makeacol_depth(depth,
color.getRed(),
color.getGreen(),
color.getBlue(), 255);
break;
case app::Color::GrayType:
c = color.getGray();
if (depth != 8)
c = makeacol_depth(depth, c, c, c, 255);
break;
case app::Color::IndexType:
c = color.getIndex();
if (depth != 8) {
ASSERT(c >= 0 && c < (int)get_current_palette()->size());
uint32_t _c = get_current_palette()->getEntry(c);
c = makeacol_depth(depth,
rgba_getr(_c),
rgba_getg(_c),
rgba_getb(_c), 255);
}
break;
}
return c;
}
示例4: color_for_image
raster::color_t color_utils::color_for_image(const app::Color& color, PixelFormat format)
{
if (color.getType() == app::Color::MaskType)
return 0;
raster::color_t c = -1;
switch (format) {
case IMAGE_RGB:
c = rgba(color.getRed(), color.getGreen(), color.getBlue(), 255);
break;
case IMAGE_GRAYSCALE:
c = graya(color.getGray(), 255);
break;
case IMAGE_INDEXED:
if (color.getType() == app::Color::IndexType)
c = color.getIndex();
else
c = get_current_palette()->findBestfit(color.getRed(), color.getGreen(), color.getBlue());
break;
}
return c;
}
示例5: onSetColor
void GraySlider::onSetColor(const app::Color& color)
{
setAbsSliderValue(0, color.getGray());
setAbsSliderValue(1, color.getAlpha());
}
示例6: pickSample
void EyedropperCommand::pickSample(const doc::Site& site,
const gfx::Point& pixelPos,
app::Color& color)
{
// Check if we've to grab alpha channel or the merged color.
Preferences& pref = Preferences::instance();
bool allLayers =
(pref.eyedropper.sample() == app::gen::EyedropperSample::ALL_LAYERS);
ColorPicker picker;
picker.pickColor(site,
pixelPos,
(allLayers ?
ColorPicker::FromComposition:
ColorPicker::FromActiveLayer));
app::gen::EyedropperChannel channel =
pref.eyedropper.channel();
app::Color picked = picker.color();
switch (channel) {
case app::gen::EyedropperChannel::COLOR_ALPHA:
color = picked;
break;
case app::gen::EyedropperChannel::COLOR:
if (picked.getAlpha() > 0)
color = app::Color::fromRgb(picked.getRed(),
picked.getGreen(),
picked.getBlue(),
color.getAlpha());
break;
case app::gen::EyedropperChannel::ALPHA:
switch (color.getType()) {
case app::Color::RgbType:
case app::Color::IndexType:
color = app::Color::fromRgb(color.getRed(),
color.getGreen(),
color.getBlue(),
picked.getAlpha());
break;
case app::Color::HsvType:
color = app::Color::fromHsv(color.getHue(),
color.getSaturation(),
color.getValue(),
picked.getAlpha());
break;
case app::Color::GrayType:
color = app::Color::fromGray(color.getGray(),
picked.getAlpha());
break;
}
break;
case app::gen::EyedropperChannel::RGBA:
if (picked.getType() == app::Color::RgbType)
color = picked;
else
color = app::Color::fromRgb(picked.getRed(),
picked.getGreen(),
picked.getBlue(),
picked.getAlpha());
break;
case app::gen::EyedropperChannel::RGB:
if (picked.getAlpha() > 0)
color = app::Color::fromRgb(picked.getRed(),
picked.getGreen(),
picked.getBlue(),
color.getAlpha());
break;
case app::gen::EyedropperChannel::HSVA:
if (picked.getType() == app::Color::HsvType)
color = picked;
else
color = app::Color::fromHsv(picked.getHue(),
picked.getSaturation(),
picked.getValue(),
picked.getAlpha());
break;
case app::gen::EyedropperChannel::HSV:
if (picked.getAlpha() > 0)
color = app::Color::fromHsv(picked.getHue(),
picked.getSaturation(),
picked.getValue(),
color.getAlpha());
break;
case app::gen::EyedropperChannel::GRAYA:
if (picked.getType() == app::Color::GrayType)
color = picked;
else
color = app::Color::fromGray(picked.getGray(),
picked.getAlpha());
break;
case app::gen::EyedropperChannel::GRAY:
if (picked.getAlpha() > 0)
color = app::Color::fromGray(picked.getGray(),
color.getAlpha());
//.........这里部分代码省略.........
示例7: onSetColor
void GraySlider::onSetColor(const app::Color& color)
{
setSliderValue(0, color.getGray());
}