resized image and result offsets

hello.
I have an image of size (640px,128px)with two subimages, one (128px,300px) and one (512px,300px) pixel.
the two images are one on the top of the other, without space between them.
The problem is that i must resize this image (that have two subimages) in an unique image of (1024px,300px), and find the result offset from the top to the bottom:
for example in the start image the offsets are 0-128 and 128-640.

I use freeimage ,an opensource library and the option is to stretch the result image.
is possible to find these offsets?
The ratio of the two subimages is the same in the start and in the resized images?
thanks.

I have an image of size (640px,128px)with two subimages, one (128px,300px) and one (512px,300px) pixel.
the two images are one on the top of the other, without space between them.

How do you manage to put a 128x300 image in a 640x128 image? Or was that meant to be 640x300? And if so, how are they “one on the top of the other”, since there isn’t vertical room for two 300 pixel images to be in a 640x300 image? Or did you mean that they were arranged horizontally?

sorry,
640px,128px is a mistake.
is 640px,300px
are arranged vertical