« first day (3730 days earlier)      last day (1273 days later) » 

2:00 AM
You know when you stare at some math stuff and you don't understand why it's working..
ah, I think I have it.
 
What'cha working on?
 
The correct width for a pixel buffer to send to windows via GDI.
It requires that the line be a multiple of LONG, but the code I came up with "works" but does not make sense.
  int width = updateRect.right - updateRect.left;
  int widthForBufferPadding = width % sizeof( LONG ); // Lines must be "multiple of LONG"
  int pixelBufferSize = ( 3 * width + widthForBufferPadding ) * height;
  std::_tout << "widthForBufferPadding " << widthForBufferPadding << std::endl;
  std::_tout << "sizeof( LONG ) " << sizeof( LONG ) << std::endl;
  std::_tout << "( 3 * width + widthForBufferPadding ) % sizeof( LONG ) " << ( 3 * width + widthForBufferPadding ) % sizeof( LONG ) << std::endl;
This always outputs ( 3 * width + widthForBufferPadding ) % sizeof( LONG ) 0.
But the line int widthForBufferPadding = width % sizeof( LONG ); seems wrong.
 
...yeah, I'm at least 1.5 glasses of wine too far in to understand that in any kind of depth...
 
But I think I get why.
Ahaha :P
Gin-tonic here.
But still on the first, and it has not hit yet.
Okay, it's fixed
The right line is:
int widthForBufferPadding = ((3*width) % sizeof( LONG )) == 0 ? 0 : sizeof( LONG ) - ((3*width) % sizeof( LONG )); // Lines must be "multiple of LONG"
 
I'll take your word for it. :)
 
2:12 AM
I appreciate the vote of confidence :P
 
3:00 AM
Here's the math that's breaking my brain atm. 😜
 
Yes, given the "too much wine", I would have expected that those curves would have been more... curvy? :P
 
I need to be more sober to teach Excel how to dance.
 
A friend of mine who has a PhD in math said he could not do math while drunk.
 
I can't say I can do math. But I can throw numerical eggs at a wall and copy-and-paste the graphs I get.
 
3:11 AM
Yeah, when I try to credit a formula to "Horizon Zero Darn", it's time to step away from the keyboard and go to bed.
Goodnight!
 
'Night!
@Tyyppi_77 and 'morning ;)
 
user92578
:)
 
Funny to see people wake up that early on purpose :P
 
user92578
3:27 AM
I like getting off work in the afternoon instead of the evening, all though the morning wake up can be a bit difficult sometimes
 
I totally understand that.
I used to leave for work around 5h45 in the morning.
Leaving work around 15h30.
Can't do that anymore because of kids.
Well... I could wake up at 5h45 but they would wake up too and I'd have to take care of them until we leave for daycare, so nothing gained there :P
Would save me from being waken up by a jolt of adrenaline.
 
4:05 AM
@Vaillancourt perfect place NOT to use a ternary
 
 
4 hours later…
7:49 AM
ms teams is trash, fight me
@Tyyppi_77 what working hours do you have? At the last company I worked we weren't allowed to start before 0630, so leaving before 11530/1600 usually was difficult if you still wanted to get your hours
 
user92578
Can start anytime between 7 and 10, so if I start at 7 I can end my workday at 15
 
@Tyyppi_77 wow, no need to take lunchbreaks?
we're required by law to have at least 30min when working < 9hrs and at least 60min > 9 hrs
 
user92578
Lunch and coffee breaks are included in the 8 hour workday
 
holy shit, what country do you live? i need to relocate
 
user92578
Finland
 
7:54 AM
aaah, the dark north. with the language that shares roots with hungarian :D
 
 
4 hours later…
11:33 AM
@Almo yeah, this will be fixed during the code review phase. Meanwhile, it allows me to complain about how trash code this new feature I'm working on is :p
 
 
3 hours later…
2:54 PM
:D
If I had my way, ternaries wouldn't exist without a special compiler flag.
they strike me as an old (1970s) thing programmers wanted just to avoid typing.
 
user92578
Ternaries make it a lot easier to create a result that is immutable
 
user92578
Immediately invoked lambdas etc. make it possible without ternaries, but those do hurt a bit on the readability IMO
 
Yep
Although I agree that ternaries could make the code harder to read, such as in the code avobe.
 
 
7 hours later…
9:59 PM
@Vaillancourt that line has so many issues other than the ternary operator....
// Lines must be multiple of LONG
int rest = ((3 * width) % sizeof( LONG ));
int widthForBufferPadding = rest == 0 ? 0 : sizeof( LONG ) - rest;
 
Indeed ;)
 
what does the 3 stand for?
 
int widthForBufferPadding = 0;
if ( rest > 0 )
  widthForBufferPadding = sizeof( LONG ) - rest;
3 bytes per pixel (R, G, B)
 
ah
and then you try fitting the bytesequence into a sequence of LONGs :)
int widthForPadding = sizeof( LONG) - ((3 * sizeof( BYTE ) * width) % sizeof( LONG );
ah no, that doesn't handle the case of 0 properly
ugh
still would probably write 3 * sizeof( BYTE) * width, thus making the number less magical; the sizeof instruction will be resolved at compiletime anyway
 
11:10 PM
@dot_Sp0T it's only the padding at the end of the line as required by the Bitmap format!
I use 24 bit per pixel
 
well that is a lot of data
or not
it's 1am here^^
 
Why a lot of data? 255 values for r, g, and b. The classical values in windows?
 
see, it's not much at all, i just misread bit to byte
 
11:37 PM
either the font i'm using is completely broken, or I am using it wrong... considering that my code is working perfectly for all other fonts i've tried so far I like to think it's the first -.-
 

« first day (3730 days earlier)      last day (1273 days later) »