Jump to content

Dividing a jpeg into a checkerboard of smaller ones?

Recommended Posts

I need to take two identically sized and shaped images (they happen to be labels) and divide them both into 48 smaller square pieces -- a grid 8 across and 6 down. I tried manually cutting the image(s) into rectangles and cutting and pasting, but its real hard to get the pieces to be the same size and I haven't even tried it for the second image! Please to help!

Thanks a lot.


Link to comment
Share on other sites

1) Add a new layer.

2) Run this codelab script.

void Render(Surface dst, Surface src, Rectangle rect)

           PdnRegion selectionRegion = EnvironmentParameters.GetSelection(src.Bounds);
           Rectangle selection = this.EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt();
           int GridSizeX = selection.Width/8;
           int GridSizeY = selection.Height/6;
           ColorBgra CurrentPixel;
           ColorBgra PrimaryColor = (ColorBgra)EnvironmentParameters.PrimaryColor;
           ColorBgra SecondaryColor = (ColorBgra)EnvironmentParameters.SecondaryColor;
           bool Odd = false;
               for (int y = rect.Top; y < rect.Bottom; y++)
                   for (int x = rect.Left; x < rect.Right; x++)
                       if (selectionRegion.IsVisible(x, y))
                           CurrentPixel = src[x, y];
                                   Odd = true;
                                   if (((x / GridSizeX) % 2) == 0) Odd = false;
                                   if (((y / GridSizeY) % 2) == 0) Odd = !Odd;
                                   if (Odd)
                                       CurrentPixel.R = (byte)PrimaryColor.R;
                                       CurrentPixel.G = (byte)PrimaryColor.G;
                                       CurrentPixel.B = (byte)PrimaryColor.B;
                                       CurrentPixel.A = (byte)PrimaryColor.A;

                                           CurrentPixel.R = (byte)SecondaryColor.R;
                                           CurrentPixel.G = (byte)SecondaryColor.G;
                                           CurrentPixel.B = (byte)SecondaryColor.B;
                                           CurrentPixel.A = (byte)SecondaryColor.A;

                           dst[x, y] = CurrentPixel;

3) Use the magic wand to draw a selection for one of the squares.

4) Crop to selection.

5) Delete the top layer.

6) File > Save as... to the filename of your choice.

7) Undo until the end of step 2 and repeat the process for the next rectangle - repeat until finished


Link to comment
Share on other sites

Thanks a lot --but I do have to state my probable inability to carry this out. While I am 100% certain that this would work, and I greatly appreciate the quick reply, I wouldn't know where to begin entering these commands! My experience with Paint.net is limited to pretty basic cutting, cropping, resizing, a little bit of retouching and the like.....The common stuff on the menu bars....

So any further hints would be so helpful. I'm willing to learn -- just need a bit of help about where to start...

Thanks again,


Link to comment
Share on other sites

Not sure if i can figure it out eider. But here are two useful links if you don’t know CodeLab.

http://paintdotnet.12.forumer.com/viewt ... sc&start=0


And one for installing CodeLab:


My DA: http://leif-j.deviantart.com/


Some people seek justice so persistent, that they will do great injustice themselves.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...