I don't have enough points to comment so I am posting in answer section.
I came from MATLAB background and always like to have map2pix and pix2map function as giving in mapping toolbox. Using above comments and posted pdf link, I wrote both of them. It might help someone.
After this layer.dataProvider().identify(QgsPoint(x, y), QgsRaster.IdentifyFormatValue) can be used to get appropriate values
def map2Pix(longitude =0,
latitude =0,
transform =None):
"""
converts map coordinates to image pixel [col, row]
:param longitude:
:param latitude:
:param transform:
:return: xOffset, yOffset
"""
if transform:
# compute pixel offset
xOffset = int((longitude - transform[0]) / transform[1])
yOffset = int((latitude - transform[3]) / transform[5])
return xOffset, yOffset
def pix2Map(xOffset =0,
yOffset =0,
transform =None):
"""
converts image pixel [row, col] to map coordinates
:param xOffset:
:param yOffset:
:param transform:
:return: longitude, latitude
"""
if transform:
longitude = transform[0] + transform[1]*xOffset
latitude = transform[3] + transform[5]*yOffset
return longitude, latitude