Home > other >  Separate a 200x200 bitmap into 5x5 array
Separate a 200x200 bitmap into 5x5 array

Time:05-14

I'm trying to create 25 bitmap of 40x40 in a 200x200 bitmap (so it's 5x5 bitmap) so I can determine where it's colored by the user draw (See example).

I tried to create 5 row and column of bitmap and insert a portion of the bitmap original (40x40) but i always get the bitmap original in 40x40, is there a way to get the 40x40 first pixel then the 40x40 of the 2nd row etc ?

Example

CodePudding user response:

I found a way :

private Bitmap split(Bitmap bmpOriginal)
        {
            Bitmap[] bmpArray = new Bitmap[] { };
            Rectangle cloneRect = new Rectangle(0, 0, 40, 40);
            Bitmap cloneBitmap = bmpOriginal.Clone(cloneRect, bmpOriginal.PixelFormat);
            return cloneBitmap;
        }
  • Related