Ejemplo n.º 1
0
GiColor GiGraphics::calcPenColor(const GiColor& color) const
{
    GiColor ret = color;

    if (kColorMono == m_impl->colorMode)
    {
        const GiColor& bk = getBkColor();
        if (color != bk)
            ret.set(~bk.r, ~bk.g, ~bk.b);
    }
    if (m_impl->drawColors == 2           // 黑白
        || kColorGray == m_impl->colorMode)
    {
        unsigned char by = (unsigned char)(
            (77 * ret.r + 151 * ret.g + 28 * ret.b + 128) / 256);
        ret.set(by, by, by);
    }
    if (m_impl->drawColors > 0 && m_impl->drawColors < 8
        && m_impl->canvas)              // 少于256色
    {
        ret = m_impl->canvas->getNearestColor(ret);
    }

    return ret;
}
Ejemplo n.º 2
0
GiColor GiGraphics::calcPenColor(const GiColor& color) const
{
    GiColor ret = color;
    
    if (isGrayMode()) {
        unsigned char by = (unsigned char)(
            (77 * ret.r + 151 * ret.g + 28 * ret.b + 128) / 256);
        ret.set(by, by, by);
    }

    return ret;
}
Ejemplo n.º 3
0
GiColor GiCanvasGdip::getNearestColor(const GiColor& color) const
{
    GiColor ret = color;

    if (m_attribDC != NULL)
    {
        COLORREF cr = ::GetNearestColor(m_attribDC, RGB(ret.r, ret.g, ret.b));
        ret.set(GetRValue(cr), GetGValue(cr), GetBValue(cr));
    }
    else if (m_draw->getDrawGs() != NULL)
    {
        G::Color c(ret.r, ret.g, ret.b);
        m_draw->getDrawGs()->GetNearestColor(&c);
        ret.set(c.GetR(), c.GetG(), c.GetB());
    }

    return ret;
}