Cut Image - CSharp System.Drawing

CSharp examples for System.Drawing:Image Effect

Description

Cut Image

Demo Code


using System.Drawing.Drawing2D;
using System.Drawing;
using System.Text;
using System.Collections.Generic;
using System;/*from www  . ja  v a2  s . c  om*/

public class Main{

        public static Image[] CutImage(Image srcImage, int count, bool IsHorizon)
        {
            srcImage = new Bitmap(srcImage, srcImage.Width, srcImage.Height);

            Image[] imageArray = new Image[count];
            if (IsHorizon)
            {
                Size picSize = new Size(srcImage.Width, srcImage.Height / count);
                for (int i = 0; i <= count - 1; i++)
                {
                    imageArray[i] = GetImage(srcImage, new Point(0, i * picSize.Height), picSize);
                }
            }
            else
            {
                Size picSize = new Size(srcImage.Width / count, srcImage.Height);
                for (int i = 0; i <= count - 1; i++)
                {
                    imageArray[i] = GetImage(srcImage, new Point(i * picSize.Width, 0), picSize);
                }
            }
            return imageArray;
        }
}

Related Tutorials