I'm not sure if this can be done with the API, though it is possible in AutoCAD.
If you attach an image to a new drawing, and save the drawing, then you can insert that drawing in another drawing as block. The image is shown correctly.
Because it is a block, it is also possible to scale independently.
If it is not possible to add the RasterImage to a block, you might put the image in a new database and save that as an external block.