QgsMapRenderer

from PyQt4.QtGui import *
from PyQt4.QtCore import *
#begin
img = QImage(QSize(800,600), QImage.Format_ARGB32_Premultiplied)
img.fill(QColor(255,255,255).rgb())
p = QPainter()
p.begin(img)
p.setRenderHint(QPainter.Antialiasing)
render = QgsMapRenderer()
aLayer = qgis.utils.iface.activeLayer()
# aLayer.loadSldStyle('/tmp/test.sld')
render.setLayerSet([ aLayer.id() ])
rect = QgsRectangle(render.fullExtent())
render.setExtent(rect)
render.setOutputSize(img.size(), 96)
render.render(p)
p.end()
img.save("/tmp/render.png","png")
#end