First, in your first fragment, RGBA is an object whose type is an unnamed structure. I do not think you intended. You probably meant:
typedef struct { ... } RGBA;
or
struct RGBA { ... };
In any case, to answer your question, give it a constructor!
struct RGBA {
RGBA(unsigned char r, unsigned char g, unsigned char b, unsigned char a) : red(r), green(g), blue(b), alpha(a) {
}
unsigned char red;
unsigned char green;
unsigned char blue;
unsigned char alpha;
};
Then you can write:
return RGBA(r,g,b,a);
source
share