SetPortraitTexture() is what the default UI uses for the unitframe portraits. Just drop it in place for
SetPortraitTextureFromCreatureDisplayID() in Elcius' example. This takes a
UnitID instead of a number to generate an image from. For example,
SetPortraitTexture(texture,"player") will render your own portrait. If the model updates, you have to call the function again to show the changes in your portrait.