Trying to translate formula for blending mode
You can find many ready solution in the Internet. For example here following macro is given:

#define ChannelBlend_Overlay(A,B)    ((uint8)((B &lt; 128) ? (2 * A * B / 255):(255 - 2 * (255 - A) * (255 - B) / 255)))


Additionally you might want to check this package: blImage for source code as you can very easilly translate it. I am sure you will find what you are looking for.