Set BMP image resolution before or with imwrite

Hi All,
I am using Opencv to save a numpy array as a BMP file.
This BMP file is used by a software that ckecks the image resolution and it reports an invalid resolution.
It seems that BMP header can handle resolution fields in pixels per meter (XpixelsPerMeter and YPixelsPerMeter) but I have not seen a way to provide this information before or as argument of cv2.imwrite.
Do you have an idea on how to set resolution on a BMP image ?

I think you are out of luck, but using PIL, for example, could help. See here for PNG

Thank you Matti!
This is the solution I used finally: pil_im.save(“dummy.bmp”, dpi=(resolH, resolV)) but I would have been happy with a simple Opencv solution.
Your link is very interesting with a OpenCv solution but a solution that implies to modify the binary buffer. I hope that Opencv will offer this as a parameter for imwrite.