Stretching few pixels from images

I’m wondering how could I use images (BMP, JPG) that can be stretched in the paint method of a component. Think in these ultra-simple images (they won’t be as simple as that).

The first one would be used as a window’s frame. The corners would have few special details, so I would be interested into stretch it adding or substracting pixels from the middle of each square’s sides. The second one could be used in a ScrollBar, where it would have specials details on its left and right extremes. So I would be interested into stretch it using the middle pixels only.

Could you please give me a small and quick orientation about how add or substract pixels from their middle parts efficiently?

You need to break your image up into nine sub-images, and only scale the middle ones, keeping the edges the same width.

Thanks, I’ll try that :slight_smile: