0
im Putten versuchen, ein Bild von einem Sprit Blatt ausschneiden und in einem picturebox setzen, aber seine Arbeit nicht, sind alle Ideen willkommenein Bild zuschneiden und es in einem Bildfeld
private void Form1_Load(object sender, EventArgs e)
{
Image Result = Crop(@"C:\Users\William\Documents\Sprites\Player\Male\Default\Light.png", 40, 60, 367, 701);
pictureBox1.Image = Result;
}
public Image Crop(string img, int width, int height, int x, int y)
{
try
{
Image image = Image.FromFile(img);
Bitmap bmp = new Bitmap(width, height, PixelFormat.Format24bppRgb);
bmp.SetResolution(80, 60);
Graphics gfx = Graphics.FromImage(bmp);
gfx.SmoothingMode = SmoothingMode.AntiAlias;
gfx.InterpolationMode = InterpolationMode.HighQualityBicubic;
gfx.PixelOffsetMode = PixelOffsetMode.HighQuality;
gfx.DrawImage(image, new Rectangle(0, 0, width, height), x, y, width, height, GraphicsUnit.Pixel);
// Dispose to free up resources
image.Dispose();
bmp.Dispose();
gfx.Dispose();
return bmp;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
return null;
}
}
Ich glaube nicht, es ist die Ernte-Funktion das ist falsch, aber ich bin nicht sicher,
oh yeh lol, es funktioniert jetzt, danke – Will