Example #1
0
void CCallCircle::draw(UCHAR *drawB, const int lX, const int lY, const int xx,
                       const int yy, const double r) {
  double aa = 2.0 * r / 3.0;  // Size of antialising

  for (int i = 0; i < m_nb && m_c[i].w <= r; i++) {
    double w = m_c[i].w;
    int x    = xx + m_c[i].x;
    int y    = yy + m_c[i].y;
    if (x >= 0 && y >= 0 && x < lX && y < lY) {
      UCHAR *pDB = drawB + y * lX + x;
      if (w <= aa) {
        *pDB = (UCHAR)255;
      } else {
        double q  = 255.0 * (r - w) / (r - aa);
        q         = D_CUT_0_255(q);
        UCHAR ucq = UC_ROUND(q);
        (*pDB)    = (*pDB) < ucq ? ucq : (*pDB);
      }
    }
  }
}
Example #2
0
UCHAR CSDirection::blurRadius(UCHAR *sel, const int xx, const int yy,
                              const int dBlur) {
  int sum, w;

  sum = w = 0;
  for (int y = yy - dBlur; y <= (yy + dBlur); y++)
    for (int x = xx - dBlur; x <= (xx + dBlur); x++)
      if (x >= 0 && y >= 0 && x < m_lX && y < m_lY) {
        UCHAR *pSel = sel + y * m_lX + x;
        if (*pSel > (UCHAR)0) {
          sum += (int)(*pSel);
          w++;
        }
      }
  if (w > 0) {
    double d = (double)sum / (double)w;
    d        = D_CUT_0_255(d);
    return UC_ROUND(d);
  }
  return *(sel + yy * m_lX + xx);
}