Click here to Skip to main content
15,881,839 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: Tool recommendation for analyzing GCC compiler output? for metaprogramming Pin
honey the codewitch13-Mar-21 8:45
mvahoney the codewitch13-Mar-21 8:45 
GeneralRe: Tool recommendation for analyzing GCC compiler output? for metaprogramming Pin
Mike Hankey13-Mar-21 9:05
mveMike Hankey13-Mar-21 9:05 
AnswerRe: Tool recommendation for analyzing GCC compiler output? for metaprogramming Pin
megaadam15-Mar-21 13:00
professionalmegaadam15-Mar-21 13:00 
JokeJOTD Pin
Mike Hankey13-Mar-21 0:44
mveMike Hankey13-Mar-21 0:44 
GeneralRe: JOTD Pin
Richard Andrew x6413-Mar-21 6:59
professionalRichard Andrew x6413-Mar-21 6:59 
GeneralRe: JOTD Pin
Mike Hankey13-Mar-21 7:00
mveMike Hankey13-Mar-21 7:00 
GeneralRe: JOTD Pin
Richard Deeming14-Mar-21 22:47
mveRichard Deeming14-Mar-21 22:47 
GeneralWho's afraid of a pixel? Pin
honey the codewitch12-Mar-21 23:02
mvahoney the codewitch12-Mar-21 23:02 
My graphics library for embedded devices has to deal with pixel formats I don't know ahead of time because the devices are diverse, and in order to be efficient pixels must be represented in their native bit format at all times. In other words, a pixel should store its values in whatever underlying format best suits the device or data stream

To complicate things, not all channels are color channels, (think alpha channel for transparency) and not all channels are the same bit width. (rgb565 16 bit color for example)

There are also totally weird ones that are common like rgb666/18 bit format (262,144 colors)

And not all devices use the same byte order in their streams.

To complicate things further, not all devices use an RGB color model. To my surprise I found out that some devices are BGR, regardless of byte order. Meanwhile, JPEGs are (IIRC) CMY or CMYk! Also critical because that's the input format from cameras, which are commonly used with these devices.

What is a pixel?

It's color space, which includes color model. It's binary layout. It uses potentially highly heterogenous channels for its data.

A pixel is as complicated as a unicode character! Dead | X|

And I can't be messing with most of this in RAM, nor at runtime. Nope, most of it needs to be not only resolvable at compile time, but the dead code generated from all the metaprogramming involved needs to be removable by the compiler to avoid code bloat on these tiny devices.

One example is retrieving values, which I have generic getters and setters for (using metaprogramming) that generate the necessary masks and shifts at compile time based on the variable series of pixel_channel_traits you gave it and channel index, each which have their own bit depth, so retrieving and setting the channels individually gets complex.

My code can resolve it all at compile time. I feel like a hero. Shucks | :-\

I wouldn't need to do this if there was some sort of unified driver model for these things.

But all the meta programming in C++ is cool. I really hadn't caught up with C++11 variadic templates and such until now. They're neat!

An rgb565BE pixel definition:

C++
typedef pixel_channel_traits<uint8_t,5,pixel_channel_kind::color> color5_channel_traits_t;
typedef pixel_channel_traits<uint8_t,6,pixel_channel_kind::color> color6_channel_traits_t;
typedef pixel_traits<
    uint16_t, // int_type
    pixel_color_model::rgb,
    false, // big endian
    // 3 channels, in this case:
    color_5_channel_traits_t, // 5 bits
    color_6_channel_traits_t, // 6 bits
    color_5_channel_traits_t> // 5 bits
    rgb565be_traits_t;


This actually generates proper getter and setter methods off the int_type, and gives you a union between the int type, and an array of bytes representing the data. It's complicated and weird code - and all of the pixel template classes (above are *trait* classes associated with the pixel template classes) which add indexed getter and setter methods for the channels that get/set a floating point value between 0 and 1, so you can operate on them generically regardless of format if you need to which is useful for things like color conversion. Thumbs Up | :thumbsup:
Real programmers use butterflies


modified 13-Mar-21 5:29am.

GeneralRe: Who's afraid of a pixel? Pin
Jörgen Andersson12-Mar-21 23:25
professionalJörgen Andersson12-Mar-21 23:25 
GeneralRe: Who's afraid of a pixel? Pin
honey the codewitch12-Mar-21 23:30
mvahoney the codewitch12-Mar-21 23:30 
GeneralRe: Who's afraid of a pixel? Pin
Jörgen Andersson13-Mar-21 1:33
professionalJörgen Andersson13-Mar-21 1:33 
GeneralRe: Who's afraid of a pixel? Pin
Sander Rossel13-Mar-21 1:07
professionalSander Rossel13-Mar-21 1:07 
GeneralRe: Who's afraid of a pixel? Pin
Eddy Vluggen13-Mar-21 12:38
professionalEddy Vluggen13-Mar-21 12:38 
GeneralIs Xamarin Forms Dead? Pin
Kevin Marois12-Mar-21 15:41
professionalKevin Marois12-Mar-21 15:41 
GeneralRe: Is Xamarin Forms Dead? Pin
markrlondon12-Mar-21 16:52
markrlondon12-Mar-21 16:52 
GeneralRe: Is Xamarin Forms Dead? Pin
markrlondon12-Mar-21 17:02
markrlondon12-Mar-21 17:02 
GeneralRe: Is Xamarin Forms Dead? Pin
Kevin Marois12-Mar-21 18:24
professionalKevin Marois12-Mar-21 18:24 
GeneralRe: Is Xamarin Forms Dead? Pin
RickZeeland12-Mar-21 21:07
mveRickZeeland12-Mar-21 21:07 
GeneralRe: Is Xamarin Forms Dead? Pin
Eddy Vluggen13-Mar-21 12:39
professionalEddy Vluggen13-Mar-21 12:39 
GeneralRe: Is Xamarin Forms Dead? Pin
KateAshman16-Mar-21 2:48
KateAshman16-Mar-21 2:48 
GeneralRe: Is Xamarin Forms Dead? Pin
Eusebiu Marcu14-Mar-21 22:04
Eusebiu Marcu14-Mar-21 22:04 
GeneralRe: Is Xamarin Forms Dead? Pin
dshillito14-Mar-21 23:32
dshillito14-Mar-21 23:32 
GeneralRe: Is Xamarin Forms Dead? Pin
Member 334960915-Mar-21 2:08
Member 334960915-Mar-21 2:08 
GeneralRe: Is Xamarin Forms Dead? Pin
MadGerbil15-Mar-21 2:12
MadGerbil15-Mar-21 2:12 
GeneralRe: Is Xamarin Forms Dead? Pin
Member 334960915-Mar-21 2:19
Member 334960915-Mar-21 2:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.