예제 #1
0
UCHAR CSDirection::getDir(const int xx, const int yy, UCHAR *sel) {
  short sum[4] = {0, 0, 0, 0};
  short w      = 0;

  for (int i = 0; i < m_lDf; i++) {
    int x = xx + m_df[0][i].x;
    int y = yy + m_df[0][i].y;
    if (y >= 0 && y < m_lY && x >= 0 && x < m_lX) {
      UCHAR *pSel = sel + y * m_lX + x;
      for (int j = 0; j < NBDIR; j++) sum[j] += (short)(*pSel) * m_df[j][i].w;
      w += (short)(*pSel);
    }
  }
  if (w == 0) return 0;
  short ma     = std::max({sum[0], sum[1], sum[2], sum[3]});
  double angle = getAngle(sum, ma);
  // tmsg_info(" - dir - %d, %d, %d, %d angle=%f", sum[0],sum[1],sum[2],sum[3],
  //		                                          angle-50.0);
  return UC_ROUND(angle);
}
예제 #2
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);
      }
    }
  }
}
예제 #3
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);
}