What's new

On the topic of colours 'feature.setcolor()' is BGR instead of RGB

R-man

Senior Member
I noticed this some time ago. I expected that some update would fix it, so where a feature needed a to be highlighted a shade of grey was my choice.

Here is a simple test script to demonstrate:
 

Attachments

  • RGB_Test.py
    661 bytes · Views: 3
Last edited:

simonb65

Alibre Super User
BGR is an older format, used by many legacy photo editing applications and OpenCV (a popular image processing library) and was the main format direction back in the Pascal days! Not sure why Alibre uses it internally today though. Its not broken as such, it just uses a different format to what most programmers today would expect! The HOOP graphics core is RGB.

There are rgb2bgr and vise-versa coverters built into python 3 (you need to Google to find what you need to include and exact syntax). If your using the API direct in C/C#, just create your own conversion macro definition to swap the bytes around.

As an example, these are the colour conversion functions that I have in my C# based Alibre Add-ons ...

C#:
namespace AlibreAddOn
{
    static public class HoopsColor
    {
        static public int FromRGB(int r, int g, int b)
        {
            return FromARGB(255, r, g, b);
        }

        static public int FromARGB(int a, int r, int g, int b)
        {
            return (int)((a << 24) | (r << 16) | (g << 8) | b);
        }

        static public int FromColor(Color clr)
        {
            return (int)((clr.A << 24) | (clr.R << 16) | (clr.G << 8) | clr.B);
        }
    }

    static public class AlibreColor
    {
        static public int FromRGB(int r, int g, int b)
        {
            return FromARGB(255, r, g, b);
        }

        static public int FromARGB(int a, int r, int g, int b)
        {
            return (int)((a << 24) | (b << 16) | (g << 8) | r);
        }

        static public int FromColor(Color clr)
        {
            return (int)((clr.A << 24) | (clr.B << 16) | (clr.G << 8) | clr.R);
        }
    }
}
 
Last edited:

R-man

Senior Member
I didn't know that it was ever a standard. That probably explains how it snuck into Alibre's routines. JHowever, just so I don't get a shock someday when there is RBG thoughout, I'm going to stick to using colours where the R And B values are equal.
 
Top