void
Hilbert(HDC hdc, int x, int y, int vx, int vy, int wx, int wy, int n)
{
    if (n >= MAXDEPTH) {
        LineTo(hdc, x + (vx+wx)/2, y + (vy+wy)/2);
    } else {
        n++;
        Hilbert(hdc, x, y, wx/2, wy/2, vx/2, vy/2, n);
        Hilbert(hdc, x+vx/2, y+vy/2, vx/2, vy/2, wx/2, wy/2, n);
        Hilbert(hdc, x+vx/2+wx/2, y+vy/2+wy/2, vx/2, vy/2, wx/2, wy/2, n);
        Hilbert(hdc, x+vx/2+wx, y+vy/2+wy, -wx/2, -wy/2, -vx/2, -vy/2, n);
    }
}
示例#2
0
void RiemersmaDither(const Image16Bpp& inImage, Image8Bpp& outImage, unsigned short transparent, int dither, float ditherlevel)
{
    DitherImage dimage(inImage, outImage, transparent, dither, ditherlevel);
    int size = ceil(log2(std::max(inImage.width, inImage.height)));
    if (size > 0) Hilbert(dimage, size, UP);
    move(dimage, NONE);
}
void
Hilbert_OnPaint(HWND hwnd)
{
    PAINTSTRUCT ps;
    HDC hdc;

    hdc = BeginPaint(hwnd, &ps);
    if (hdc) {
        if (g_fDragging) {
            g_fPaintDeferred = TRUE;
        } else {

            HBRUSH hbrOld;
            HPEN hpenOld;
            HCURSOR hcurOld;

            hcurOld = SetCursor(LoadCursor(0, IDC_WAIT));

            hbrOld = SelectObject(hdc, GetStockObject(BLACK_BRUSH));
            hpenOld = SelectObject(hdc, GetStockObject(BLACK_PEN));

            MoveToEx(hdc, 0, 0, 0);
            Hilbert(hdc, 0, 0, GetSystemMetrics(SM_CXFULLSCREEN), 0,
                               0, GetSystemMetrics(SM_CYFULLSCREEN), 0);
            SelectObject(hdc, hpenOld);
            SelectObject(hdc, hbrOld);

            SetCursor(hcurOld);
        }
        EndPaint(hwnd, &ps);
    }
}
示例#4
0
int main(int argc, char* argv[])
{

  int * x = NULL;
  int row = 2;
  int col = 2;
  int i, j;
  int layer = 3;

  if(argc >= 2)
    layer = atoi(argv[1]);

  x = (int*)malloc(row * col * sizeof(int));
  memset(x, 0, sizeof(int) * row * col);

  Initial(x, 2, 2);

  Hilbert(&x, row, col, layer);

  printf("Hilbert list:\n");
  for(i = 0;i < row * pow(2, layer - 1);i ++)
  {
    for(j = 0;j < col * pow(2, layer - 1);j ++)
      printf("%d \t", x[i * col * (int)pow(2, layer - 1) + j]);
    printf("\n");
  }
  printf("\nEnd Hilbert layer = %d.\n", layer);

  free(x);
  x = NULL;
  
  getchar();

  return 0;
}
示例#5
0
void Lotkin( Matrix<F>& A, Int n )
{
    DEBUG_ONLY(CallStackEntry cse("Lotkin"))
    Hilbert( A, n );
    // Set first row to all ones
    for( Int j=0; j<n; ++j )
        A.Set( 0, j, F(1) );
}
示例#6
0
void Lotkin( AbstractBlockDistMatrix<F>& A, Int n )
{
    DEBUG_ONLY(CallStackEntry cse("Lotkin"))
    Hilbert( A, n );
    // Set first row to all ones
    if( A.ColShift() == 0 )
    {
        const Int localWidth = A.LocalWidth();
        for( Int jLoc=0; jLoc<localWidth; ++jLoc )
            A.SetLocal( 0, jLoc, F(1) );
    } 
}
示例#7
0
int main()
{
 cwin.coord(0, h, h, 0);
 Hilbert();
 return 0;
}
示例#8
0
void Hilbert(DitherImage& dither, int level, int direction)
{
    if (level == 1)
    {
        switch (direction)
        {
            case LEFT:
                move(dither, RIGHT);
                move(dither, DOWN);
                move(dither, LEFT);
                break;
            case RIGHT:
                move(dither, LEFT);
                move(dither, UP);
                move(dither, RIGHT);
                break;
            case UP:
                move(dither, DOWN);
                move(dither, RIGHT);
                move(dither, UP);
                break;
            case DOWN:
                move(dither, UP);
                move(dither, LEFT);
                move(dither, DOWN);
                break;
        }
    }
    else
    {
        switch (direction)
        {
            case LEFT:
                Hilbert(dither, level - 1, UP);
                move(dither, RIGHT);
                Hilbert(dither, level - 1, LEFT);
                move(dither, DOWN);
                Hilbert(dither, level - 1, LEFT);
                move(dither, LEFT);
                Hilbert(dither, level - 1, DOWN);
                break;
            case RIGHT:
                Hilbert(dither, level - 1, DOWN);
                move(dither, LEFT);
                Hilbert(dither, level - 1, RIGHT);
                move(dither, UP);
                Hilbert(dither, level - 1, RIGHT);
                move(dither, RIGHT);
                Hilbert(dither, level - 1, UP);
                break;
            case UP:
                Hilbert(dither, level - 1, LEFT);
                move(dither, DOWN);
                Hilbert(dither, level - 1, UP);
                move(dither, RIGHT);
                Hilbert(dither, level - 1, UP);
                move(dither, UP);
                Hilbert(dither, level - 1, RIGHT);
                break;
            case DOWN:
                Hilbert(dither, level - 1, RIGHT);
                move(dither, UP);
                Hilbert(dither, level - 1, DOWN);
                move(dither, LEFT);
                Hilbert(dither, level - 1, DOWN);
                move(dither, DOWN);
                Hilbert(dither, level - 1, LEFT);
                break;
        }
    }
}
示例#9
0
 Hilbert::pointer Hilbert::create ( const Glib::ustring& id, unsigned level, double size, Fill::pointer fill, Stroke::pointer stroke )
 {
   PAPYRUS_CREATE ( Hilbert ( id, level, size, fill, stroke ) );
 }
示例#10
0
void Hilbert(int** px, int row, int col, int layer)
{
  int * y = NULL;
  int * z = NULL;
  int * t;
  int i, j;
  int c, r;
  layer --;
  if(layer <= 0)
    return;

  y = (int *)malloc(row * col * 4 * sizeof(int));
  z = (int *)malloc(row * col * sizeof(int));

  memset(y, 0, row * col * 4 * sizeof(int));

  memcpy(z, *px, row * col * sizeof(int));
  Rot(z, row, col, 1);
  for(i = 0;i < row;i ++)
    for(j = 0;j < col;j ++)
    {
      r = (int)(*(z + i * col + j) / col);
      c = *(z + i * col + j) % col;
      *(y + i * col * 2 + j) = r * col * 2 + c;
    }

  memcpy(z, *px, row * col * sizeof(int));
  Rot(z, row, col, 0);
  for(i = 0;i < row;i ++)
    for(j = 0;j < col;j ++)
    {
      r = (int)(*(z + i * col + j) / col);
      c = *(z + i * col + j) % col;
      *(y + (i + row) * col * 2 + j) = r * col * 2 + row * col * 2 + c;
    }

  memcpy(z, *px, row * col * sizeof(int));
  Rot(z, row, col, 3);
  for(i = 0;i < row;i ++)
    for(j = 0;j < col;j ++)
    {
      r = (int)(*(z + i * col + j) / col);
      c = *(z + i * col + j) % col;
      *(y + i * col * 2 + j + col) = r * col * 2 + col + c;
    }

  memcpy(z, *px, row * col * sizeof(int));
  Rot(z, row, col, 0);
  for(i = 0;i < row;i ++)
    for(j = 0;j < col;j ++)
    {
      r = (int)(*(z + i * col + j) / col);
      c = *(z + i * col + j) % col;
      *(y + (i + row) * col * 2 + j + col) = r * col * 2 + row * col * 2 + c + col;
    }

  *(y + row * col * 2 - col * 2) = row * col * 2;
  *(y + row * col * 2 + col * 2 - 1) = row * col * 2 - 1;
  *(y + row * col * 2 + col - 1) = row * col * 2 + col;
  *(y + col * 2 - 1) = -1;

  t = *px;
  *px = y;
  y = t;
 
  Hilbert(px, row * 2, col * 2, layer);

  free(y);
  free(z);

}