예제 #1
0
    static Color Sample(const BitmapPtr bitmap, float u, float v)
    {
        u32 width = bitmap->GetWidth();
        u32 height = bitmap->GetHeight();

        float fx = XAddresserType::CalcAddress(u, width);
        int x = XAddresserType::FixAddress(Mathf::RoundToInt(fx), width);
        float fy = YAddresserType::CalcAddress(v, height);
        int y = YAddresserType::FixAddress(Mathf::RoundToInt(fy), height);

        return bitmap->GetColor(x, y);
    }
예제 #2
0
    static Color Sample(const BitmapPtr bitmap, float u, float v)
    {
        u32 width = bitmap->GetWidth();
        u32 height = bitmap->GetHeight();

        float fx = XAddresserType::CalcAddress(u, width);
        int x0 = Mathf::FloorToInt(fx);
        float fy = YAddresserType::CalcAddress(v, height);
        int y0 = Mathf::FloorToInt(fy);
        float xFrac = fx - x0;
        float yFrac = fy - y0;
        x0 = XAddresserType::FixAddress(x0, width);
        y0 = YAddresserType::FixAddress(y0, height);
        int x1 = XAddresserType::FixAddress(x0 + 1, width);
        int y1 = YAddresserType::FixAddress(y0 + 1, height);

        Color c0 = bitmap->GetColor(x0, y0);
        Color c1 = bitmap->GetColor(x1, y0);
        Color c2 = bitmap->GetColor(x0, y1);
        Color c3 = bitmap->GetColor(x1, y1);

        return Color::Lerp(c0, c1, c2, c3, xFrac, yFrac);
    }