在我的代码中,我选择了一个图像并被裁剪成 9 块。现在我想在我的画布中随机放置每一块。我该怎么做呢?
public void CutImage(string img)
{
int count = 0;
BitmapImage src = new BitmapImage();
src.BeginInit();
src.UriSource = new Uri(img, UriKind.Relative);
src.CacheOption = BitmapCacheOption.OnLoad;
src.EndInit();
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 3; j++)
{
objImg[count++] = new CroppedBitmap(src, new Int32Rect(j * 120, i * 120, 120, 120));
}
}
}
public void PositionImage(object[] objImage)
{
for (int i = 0; i < objImage.Length; i++)
{
TranslateTransform translateTransform1 = new TranslateTransform(rnd1.Next(1,360), rnd1.Next(1,360));
}
//movedRectangle.RenderTransform = translateTransform1;
//mainCanvas.Children.Add(movedRectangle);
}