Inserting graphics by code?

  • I'd like to insert graphics into a WPRichText.
    (The graphics are generated by the App dynamically - bitmap-graphics or wmf vector graphics. The text holds tags that are replaced by these graphics)

    Now there seem to be various ways to do that, e.g.

    Code
    // Prepare graphicgra:=TBitmap.Create;gra.LoadFromFile(AppPath+'monitor_64.bmp');  // just a sample, in reality this is painted somewhere...wpimg:=TWPOImage.CreateImage(WPRichText1.Memo.RTFData, gra);// code specific for this solutionwpimg.WidthTW :=1000;wpimg.HeightTW:=1000;WPRichText1.TextObjects.Insert(wpimg);


    or

    Code
    // first 4 lines as in the 1st sample
    
    
    wptobj:=WPRichText1.TextObjects.InsertNewObject(wpobjImage);
    wptobj.ObjRef:=wpimg;
    // object size is ignored - needs to be set here
    wptobj.Width :=1000;
    wptobj.Height:=1000;

    What's the difference, which one is recommended and is there a better way to do that?

    Thanks!