所以我在C#中創建了一個程序,它接受一張圖像並將其分割爲多個圖塊。我處於想要拍攝大圖像的位置,並將其切分成不同的圖塊並保存每個圖塊。我遇到的問題是它適用於第一塊瓷磚,但所有其他瓷磚都是空白的,我不知道爲什麼。這裏是我正在做Choping的代碼。在C#中用TextureBrush重複抽樣圖像
Graphics g;
Image tempTile;
TextureBrush textureBrush;
int currRow = 1;
int currCol = 1;
int currX = 0; //Used for splitting. Initialized to origin x.
int currY = 0; //Used for splitting. Initialized to origin y.
//Sample our new image
textureBrush = new TextureBrush(myChopImage);
while (currY < myChopImage.Height)
{
while (currX < myChopImage.Width)
{
//Create a single tile
tempTile = new Bitmap(myTileWidth, myTileHeight);
g = Graphics.FromImage(tempTile);
//Fill our single tile with a portion of the chop image
g.FillRectangle(textureBrush, new Rectangle(currX, currY, myTileWidth, myTileHeight));
tempTile.Save("tile_" + currCol + "_" + currRow + ".bmp");
currCol++;
currX += myTileWidth;
g.Dispose();
}
//Reset the current column to start over on the next row.
currCol = 1;
currX = 0;
currRow++;
currY += myTileHeight;
}
是的,完美的作品,非常感謝你給我一個解決問題的辦法。 – Katianie 2013-02-15 19:24:53