You could do it passing a shader to spritebatch but im not sure how expensive it would be. It’s definately not to easy to explain either and so im just going to sort of pesudo spit it out.
Basically you need to modulate against the u v positional area on the image conditionally.
You would need to pass in the source rectangle to modulate the uv against it.
It would be best to pass it in with virtual coordinate form.
sourceRectangle / image.Bounds
the image bounds is a rectangle the size of the image like 0,0,100,100
the source is maybe like 10,10,20,20
Now your uv is passed in as texture coords you would want to read them and basically modulate those coordinates by the min max of the virtual source rectangles coordinates.
To say if
your textcoords.x - virtualRect.x is less then 0 you need to modulate the difference from virtualRect.Width in this case that would be virtualRect.z the fractional amount you get back is subtracted from virtualRect.Width to give a new u coordinate. if
your textcoord.x - (virtualRect.Width + virtualRectangle.x) = su , is more then 0 then
take that and divide it by the virtual width and add the fractional amount to virtualRect.x
frac(textcoord.x / (virtualRect.Width)) + virtualRect.x = new u coordinate
Repeat those steps for V using the virtual y and height.
When you have the new U,V you grab the pixel out of the image with it.
When you pass in the virtual rectangle you pass a float4 so width height is going to be z w
You could do this vertex shader side modulating based on actual pixel position and gain tons of control over it but that is even more complicated to explain and requires a couple more values to be passed to the shader.