Image Editing

I’d like to make a texture generator, and I’m having trouble with modifying images, I’d really like to know how to capture image data from a specific screen region, like a screenshot, but only from a 256x256 region of the screen.
Like this:

And also is there a way to assign this image data to an objects sprite? Edit: ← Found out how to do this. Still confused on the first step though.
Thanks for any help, it is very much appreciated.

The thing you have in mind is to make a pattern 256x256 and then make this image is repeated in a screen like 800x600.
So that, you have 4 256x256 horizontally and 3 256x256 vertically ?

I want to capture a portion of the screen, save it to an image, mirror it vertically and horizontally and place only four instances of this image on the screen( upper left, unmodified, upper right, mirrored horizontally, lower left, mirrored vertically, lower right, mirrored both vertically and horizontally)

I’m pretty sure I can figure out how to do all but capture a screen portion, I don’t think GD has any specific way to do this ATM, I was hoping there was some sort or workaround or something.