Click here to Skip to main content
15,888,098 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: I'm stunned at how stupid EntityFramework is Pin
Marc Clifton22-Mar-21 1:54
mvaMarc Clifton22-Mar-21 1:54 
GeneralRe: I'm stunned at how stupid EntityFramework is Pin
Dan Neely22-Mar-21 2:42
Dan Neely22-Mar-21 2:42 
GeneralRe: I'm stunned at how stupid EntityFramework is Pin
Jörgen Andersson21-Mar-21 23:30
professionalJörgen Andersson21-Mar-21 23:30 
GeneralRe: I'm stunned at how stupid EntityFramework is Pin
Marc Clifton22-Mar-21 1:58
mvaMarc Clifton22-Mar-21 1:58 
GeneralRe: I'm stunned at how stupid EntityFramework is Pin
pkfox22-Mar-21 0:05
professionalpkfox22-Mar-21 0:05 
GeneralRe: I'm stunned at how stupid EntityFramework is Pin
Espen Harlinn22-Mar-21 1:41
professionalEspen Harlinn22-Mar-21 1:41 
GeneralRe: I'm stunned at how stupid EntityFramework is Pin
Jacquers22-Mar-21 2:16
Jacquers22-Mar-21 2:16 
GeneralAnd here I thought I was clever. Pin
honey the codewitch21-Mar-21 10:36
mvahoney the codewitch21-Mar-21 10:36 
So I figured out awhile ago how to prepare a massive amount of information about a pixel format based on a few inputs about it, where the compiler computes the rest at compile time. It's all powered by C++ templates. It implements code, to for example, shift a 6 bit value out of the middle of a 16 bit big endian word, give it you you, and then allow you to change it.

You define the bit depth of every channel, and what type of channel it is, and it does the rest:
C++
using rgb565be = pixel<
        color_model::rgb,
        endian_mode::big_endian,
        channel_traits<channel_name::R,5>, // red 5-bits
        channel_traits<channel_name::G,6>, // green - 6-bits
        channel_traits<channel_name::B,5>  // blue - 5-bits
        >;

and then you can get the channel info from a pixel type like this:
C++
using ch = typename PixelType::channel_type_by_index<Index>;
printf("channel %s\r\n",ch::name_());
printf("\tindex: %d\r\n",(int)ch::index_);
printf("\tbit-depth: %d\r\n",(int)ch::bit_depth_);
printf("\tmin: %llu, max: %llu\r\n",(unsigned long long)ch::min,(unsigned long long)ch::max);
printf("\tscale: %llu\r\n",(unsigned long long)ch::scale);
printf("\r\n");


It computes all those values above (the trailing underscores are to avoid conflicts with virtual instance methods of the same name that allow you to get the information at runtime rather than compile time like above)

Pretty slick, if I do say so myself, but...

I want to be able to automatically generate code to convert pixel formats of the same color model to each other, so you can for example, from 24-bit RGB to 16-bit BGR format without missing a beat or writing code to do it yourself.

So I needed a template to fetch a channel by name at compile time.

I can get it, but I can't populate the index of the channel with a meaningful value if I don't retrieve it by index. Nor can I count the bits to the left of it which means that nifty shifting code I generate is incorrect if I fetch the channel type by name.

I'm stumped by the seemingly simple task of convincing the C++ compiler to give me the index of type (within a template argument parameter pack) that has a particular string associated with it.

I've been working on this all day.

I love C++.
I hate C++.
Real programmers use butterflies

GeneralRe: And here I thought I was clever. Pin
Greg Utas21-Mar-21 14:12
professionalGreg Utas21-Mar-21 14:12 
GeneralRe: And here I thought I was clever. Pin
honey the codewitch21-Mar-21 14:30
mvahoney the codewitch21-Mar-21 14:30 
GeneralRe: And here I thought I was clever. Pin
Greg Utas22-Mar-21 1:05
professionalGreg Utas22-Mar-21 1:05 
GeneralRe: And here I thought I was clever. Pin
honey the codewitch22-Mar-21 9:18
mvahoney the codewitch22-Mar-21 9:18 
PraiseRe: And here I thought I was clever. Pin
Eddy Vluggen22-Mar-21 13:56
professionalEddy Vluggen22-Mar-21 13:56 
GeneralRe: And here I thought I was clever. Pin
honey the codewitch22-Mar-21 15:49
mvahoney the codewitch22-Mar-21 15:49 
GeneralWe've finally named our hens Pin
honey the codewitch21-Mar-21 10:04
mvahoney the codewitch21-Mar-21 10:04 
GeneralRe: We've finally named our hens Pin
pkfox21-Mar-21 10:18
professionalpkfox21-Mar-21 10:18 
GeneralRe: We've finally named our hens Pin
honey the codewitch21-Mar-21 10:24
mvahoney the codewitch21-Mar-21 10:24 
GeneralRe: We've finally named our hens Pin
Nelek21-Mar-21 10:53
protectorNelek21-Mar-21 10:53 
GeneralRe: We've finally named our hens Pin
honey the codewitch21-Mar-21 12:19
mvahoney the codewitch21-Mar-21 12:19 
GeneralRe: We've finally named our hens Pin
dandy7221-Mar-21 12:48
dandy7221-Mar-21 12:48 
GeneralRe: We've finally named our hens Pin
Nelek21-Mar-21 21:01
protectorNelek21-Mar-21 21:01 
GeneralRe: We've finally named our hens Pin
OriginalGriff21-Mar-21 10:18
mveOriginalGriff21-Mar-21 10:18 
GeneralRe: We've finally named our hens Pin
honey the codewitch21-Mar-21 10:23
mvahoney the codewitch21-Mar-21 10:23 
GeneralRe: We've finally named our hens Pin
OriginalGriff21-Mar-21 10:28
mveOriginalGriff21-Mar-21 10:28 
GeneralOff topic: (ish) Pin
OriginalGriff21-Mar-21 10:30
mveOriginalGriff21-Mar-21 10:30 

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.