Soru & Cevap

C# ...

27.03.2021 - 11:07

Arkadaşlar c# picturebox a yüklenilen bir fotoğrafı nasıl parçalara ayırabiliriz ? 

19 Görüntülenme

2 Cevap

Sitedeki sorulara cevap verebilmek için giriş yapın ya da üye olun.

Profile picture for user sevgii
sevgii
31.12.2022 - 01:34

Çözümü ben de merak ediyorum, paylaşır mısınız

picture-307552-1601310528.png
jfirat.alabuga
29.03.2021 - 12:42
Image img = Image.FromFile("media\\a.png"); // a.png için verilen 312X312 genişlik ve yükseklikint widthThird = (int)((double)img.Width / 3.0 + 0.5);
int heightThird = (int)((double)img.Height / 3.0 + 0.5);
Bitmap[,] bmps = new Bitmap[3,3];
for (int i = 0; i < 3; i++)
    for (int j = 0; j < 3; j++)
    {
        bmps[i, j] = new Bitmap(widthThird, heightThird);
        Graphics g = Graphics.FromImage(bmps[i, j]);
        g.DrawImage(img, new Rectangle(0, 0, widthThird, heightThird), new Rectangle(j * widthThird, i * heightThird, widthThird, heightThird), GraphicsUnit.Pixel);
        g.Dispose();
    }
pictureBox1.Image = bmps[0, 0];
pictureBox2.Image = bmps[0, 1];
pictureBox3.Image = bmps[0, 2];
pictureBox4.Image = bmps[1, 0];
pictureBox5.Image = bmps[1, 1];
pictureBox6.Image = bmps[1, 2];
pictureBox7.Image = bmps[2, 0];
pictureBox8.Image = bmps[2, 1];
pictureBox9.Image = bmps[2, 2];