This post assumes that you're referring to DirectDraw and not Direct3d.

You have to blend surfaces by hand in DirectDraw, which means locking and going over the pixels. You'd read the pixels, break them up into r,g, and b components, do some calculations on them, then recombine the results. This ain't the fastest thing out there. You will get more speed with MMX, so try having a look at this article at Gamedev (note: it's in C++ - if that's a problem, let me know): MMX Enhanced Blending. There may be other blending articles at gamdev; I forget.

As for calculating the offsets... have a look at the pixel manipulation part of my yet-to-be-finished DDraw tutorial: http://www.alistairkeys.co.uk/ddraw2.shtml (Btw: the layout may screw up in IE 5 due to its broken box model implementation -- if so, upgrade to a less broken browser such as IE 6 or Mozilla).