이미지를 가져 와서 타일로 분할하는 C#으로 프로그램을 만듭니다. 나는 큰 이미지를 가져 와서 다른 타일로 잘라서 각 타일을 저장하고 싶습니다. 내가 가지고있는 문제는 첫 번째 타일에 대해서는 작동하지만 다른 모든 타일은 비어 있으며 이유는 확실하지 않다는 것입니다. 여기 내가 자르기를하고있는 코드가있다.C#에서 TextureBrush를 반복적으로 사용하여 이미지 샘플링하기
g.FillRectangle(textureBrush, new Rectangle(currX, currY, myTileWidth, myTileHeight));
전화가 경계 외부의 좌표를 입력하려고 : 그것은 당신의 경우
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