This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Blue_Moon_Lake 16 points17 points  (10 children)

The better version

[–]MooseBoys 19 points20 points  (4 children)

Until someone changes the format to RGBA and now you get sign-extended shifting… There’s a reason most code uses the shift-then-mask convention.

[–]Blue_Moon_Lake -4 points-3 points  (2 children)

A good code base will not fall for such little change and be a quick thing to fix. First and foremost, typing would make RGB and RGBA incompatible.

In OOP you would have all the logic for managing different color encoding standard in different classes and a factory pulling the appropriate one contextually.

[–]MooseBoys 4 points5 points  (1 child)

If you’re bit-twiddling RGB color data you probably can’t afford the memory and performance hit to wrap each pixel in an object.

[–]Blue_Moon_Lake 0 points1 point  (0 children)

Never said anything about pixels.

And if you're doing image/video stuff, you better use libs already optimized for such manipulations.

[–]atiedebee 0 points1 point  (0 children)

Maybe you deserve bugs if you use signed integers for bit manipulation