Ejemplo n.º 1
0
 private void button6_Click(object sender, System.EventArgs e)
 {
     if (!WangTilesValid)
     {
         return;
     }
     if (saveFileDialog1.ShowDialog() == DialogResult.OK)
     {
         Bitmap[] bitmaps = new Bitmap[WangTiles.Length];
         for (int i = 0; i < WangTiles.Length; i++)
         {
             bitmaps[i] = WangTiles[i].WangBitmap;
         }
         WangTiler.SaveMegaTile(bitmaps, saveFileDialog1.FileName + ".bmp");
     }
 }
Ejemplo n.º 2
0
 private void button4_Click(object sender, System.EventArgs e)
 {
     if (!QuiltedTextureMapValid)
     {
         MessageBox.Show("Please load a valid quilt file first.");
         return;
     }
     if (QuiltedTextureMap.Width <= (int)numericUpDownWangTileSize.Value)
     {
         MessageBox.Show("Your Wang Tiles must be smaller than your quilted image texture.");
         return;
     }
     WangTile[] wangTiles = WangTile.LoadDescriptionsFromFile(new StreamReader(new MemoryStream(System.Text.Encoding.ASCII.GetBytes(this.textBoxWangSpecs.Text))));
     WangTiles = WangTiler.WangTile(wangTiles, new Size((int)numericUpDownWangTileSize.Value, (int)numericUpDownWangTileSize.Value),
                                    new Bitmap[] { QuiltedTextureMap }, (int)numericUpDownQuiltingBlockOverlap.Value,
                                    (int)numericUpDownMaxWangMatchAttempts.Value, (int)numericUpDownMaxWangMatchError.Value,
                                    checkBoxOnePixelOverlapBetweenTiles.Checked);
     Console.WriteLine("yeah");
 }
Ejemplo n.º 3
0
            public void RecalcScanLines()
            {
                int buff = this.OnePixelOverlap ? 1 : 0;

                int halfWangTileWidth = WangTileSize.Width / 2;

                foreach (WangTileWithBitmapInfo wtbi in WangTilesInfo)
                {
                    /// TODO: IF you wanted to blend multiple bitmaps, for example to introduce inhomogeneity, you'd need to first
                    /// have computed blended north, west, south, east blend cuts for each possible combination of tiles,
                    /// for each possible combination of corners.
                    Rectangle northSample       = SamplePortions[0, wtbi.WangTile.ColorN];
                    Rectangle eastSample        = SamplePortions[0, wtbi.WangTile.ColorE];
                    Rectangle southSample       = SamplePortions[0, wtbi.WangTile.ColorS];
                    Rectangle westSample        = SamplePortions[0, wtbi.WangTile.ColorW];
                    Point     northSampleCenter = new Point(northSample.Left + (northSample.Width / 2), northSample.Top + (northSample.Height / 2));
                    Point     eastSampleCenter  = new Point(eastSample.Left + (eastSample.Width / 2), eastSample.Top + (eastSample.Height / 2));
                    Point     southSampleCenter = new Point(southSample.Left + (southSample.Width / 2), southSample.Top + (southSample.Height / 2));
                    Point     westSampleCenter  = new Point(westSample.Left + (westSample.Width / 2), westSample.Top + (westSample.Height / 2));
                    wtbi.ScanLineNW = WangTiler.GetMinErrorBoundaryCutNWToSEDiagonal(SourceBitmaps[0], SourceBitmaps[0],
                                                                                     new Rectangle(new Point(northSampleCenter.X - halfWangTileWidth, northSampleCenter.Y - buff), new Size(halfWangTileWidth, halfWangTileWidth)), // north tile, left side
                                                                                     new Point(westSampleCenter.X - buff, westSampleCenter.Y - halfWangTileWidth),                                                                  // west tile, top side
                                                                                     out wtbi.MatchingErrorNW);
                    wtbi.ScanLineNE = WangTiler.GetMinErrorBoundaryCutNEToSWDiagonal(SourceBitmaps[0], SourceBitmaps[0],
                                                                                     new Rectangle(new Point(northSampleCenter.X, northSampleCenter.Y - buff), new Size(halfWangTileWidth, halfWangTileWidth)), // north tile, right side
                                                                                     new Point(eastSampleCenter.X - halfWangTileWidth - buff, eastSampleCenter.Y - halfWangTileWidth),                          // east tile, top side
                                                                                     out wtbi.MatchingErrorNE);
                    wtbi.ScanLineSE = WangTiler.GetMinErrorBoundaryCutNWToSEDiagonal(SourceBitmaps[0], SourceBitmaps[0],
                                                                                     new Rectangle(new Point(southSampleCenter.X, southSampleCenter.Y - halfWangTileWidth + buff), new Size(halfWangTileWidth, halfWangTileWidth)), // south tile, right side
                                                                                     new Point(eastSampleCenter.X - halfWangTileWidth + buff, eastSampleCenter.Y),                                                                  // east tile, top side
                                                                                     out wtbi.MatchingErrorSE);
                    wtbi.ScanLineSW = WangTiler.GetMinErrorBoundaryCutNEToSWDiagonal(SourceBitmaps[0], SourceBitmaps[0],
                                                                                     new Rectangle(new Point(southSampleCenter.X - halfWangTileWidth, southSampleCenter.Y - halfWangTileWidth + buff), new Size(halfWangTileWidth, halfWangTileWidth)), // south tile, left side
                                                                                     new Point(westSampleCenter.X - buff, westSampleCenter.Y),                                                                                                          // west tile, top side
                                                                                     out wtbi.MatchingErrorSW);
                }
            }