Zdravim.
Mam takovyto Form
public partial class TileSet : Form { public TileSet(int index) { InitializeComponent(); LoadPath(index); } public void LoadPath(int index) { string[] Cesty = new string[2]; Cesty[0] = @"D:\Users\Mutagen\Desktop\XNAGame\Texture\TileSet_One.png";
Cesty[1] = @"D:\Users\Mutagen\Desktop\XNAGame\Texture\TileSet_Two.png"
Cesty[2] = @"D:\Users\Mutagen\Desktop\XNAGame\Texture\TileSet_Three.png";
for (int i = 0; i < Cesty.Length; i++) { if ((index - 1) == i) { LoadTile(Cesty[i]); } } } private void LoadTile(string Cesta) { Image Img = Image.FromFile(Cesta, true); int x = 0; int y = 0; int Width = 32; int Height = 32; int ImageWidth = Img.Width / Width; int ImageHeight = Img.Height / Height; for (int a = 0; a < ImageHeight; a++) { for (int i = 0; i < ImageWidth; i++) { pictureBox1.Image = CutImage(Cesta, Width, Height, x, y); x += Width; } y += Height; } } private Image CutImage(string Img, int Width, int Height, int x, int y) { try { Image Obr = Image.FromFile(Img); Bitmap bmp = new Bitmap(Width, Height, PixelFormat.Format24bppRgb); bmp.SetResolution(Width, Height); Graphics gfx = Graphics.FromImage(bmp); gfx.SmoothingMode = SmoothingMode.AntiAlias; gfx.InterpolationMode = InterpolationMode.HighQualityBicubic; gfx.PixelOffsetMode = PixelOffsetMode.HighQuality; gfx.DrawImage(Obr, new Rectangle(0, 0, Width, Height), x, y, Width, Height, GraphicsUnit.Pixel); Obr.Dispose(); bmp.Dispose(); gfx.Dispose(); return bmp; } catch (Exception ex) { MessageBox.Show(ex.Message); return null; } } }
Z MainFormu to volam takhle
private void TileSet1_Click(object sender, EventArgs e)
{
TileSet TS = new TileSet(1);
TS.MdiParent = this;
TS.Show();
}
A na radku TS.Show(); mi to vypise error Parameter is not valid.
Nevite kde mam chybu ?