'Revit failed to Load ImagePath

i try to Place a Temporary In-Canvas Graphic in Revit like this:

var activeUiDoc = document.Application.ActiveUIDocument;
        var activeDbDoc = activeUiDoc.Document;



        using (var graphicsManager = TemporaryGraphicsManager.GetTemporaryGraphicsManager(activeDbDoc))
        {

            try
            {
                var insertionPoint = activeUiDoc.Selection.PickPoint("Select insertion Point");
                var logoData = new InCanvasControlData(@"C:\Program Files\Autodesk\Revit 2023\uniE1D2.bmp", XYZ.Zero);

                var index = graphicsManager.AddControl(logoData, ElementId.InvalidElementId);
            } catch(Exception ex) 
            {
                return;
            }
        }

But i get a "Failed to load the image from specified path." Error message. I have tried various different Paths, the Error stays.

Is there an Issue with the Revit 2023 Api? What can i try to get my image displayed?

Thanks for the help.



Solution 1:[1]

We found out that .bmp images must have a Background color value of (0,128,128). Our images for Revit 2022 were somehow different. Once we changed the Color value, the images loaded successfully.

Solution 2:[2]

Have you tried to run Revit with admin rights? The process that Revit runs on might not have necessary permissions by default.

Maybe something like this before you call InCanvasControlData to make sure you can open the file?

         using (FileStream fs = new FileStream(filename, FileMode.Open))
        using (Bitmap b = new Bitmap(fs))
            Debug.Assert(new Bitmap(b) != null);

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Florian_Schaf
Solution 2 joelwsaury