Click here to Skip to main content
15,867,308 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: Pulled The Trigger Last Night Pin
maze312-Jun-23 3:03
professionalmaze312-Jun-23 3:03 
GeneralRe: Pulled The Trigger Last Night Pin
Mark Starr12-Jun-23 4:22
professionalMark Starr12-Jun-23 4:22 
JokeThe earliest computer Pin
Cp-Coder9-Jun-23 8:37
Cp-Coder9-Jun-23 8:37 
GeneralRe: The earliest computer Pin
FreedMalloc9-Jun-23 9:02
FreedMalloc9-Jun-23 9:02 
GeneralRe: The earliest computer Pin
jmaida9-Jun-23 13:28
jmaida9-Jun-23 13:28 
GeneralRe: The earliest computer Pin
trønderen9-Jun-23 18:28
trønderen9-Jun-23 18:28 
GeneralRe: The earliest computer Pin
jmaida10-Jun-23 18:48
jmaida10-Jun-23 18:48 
GeneralThe magic of coffee Pin
honey the codewitch9-Jun-23 4:05
mvahoney the codewitch9-Jun-23 4:05 
So I needed a simple bit of code to take an icon and convert it to 1-bit monochrome. I had to write it in C++ such that my friend could easily understand it and then port it to JS and make my website do it. I'm an idiot when it comes to web development.

I could not get it right. Could not.

One cup of coffee later:

C++
using test_t = bitmap<alpha_pixel<1>>;
uint8_t test_data[test_t::sizeof_buffer(faAnchorCircleCheck_size)];
void gen_1bit() {
    size_t i = 0;
    size_t idx = 0;
    size_t offs = 0;
    uint8_t tmp = 0;
    for(int y = 0;y<faAnchorLock.dimensions().height;++y) {
        for(int x = 0;x<faAnchorLock.dimensions().width;++x) {
            decltype(faAnchorLock)::pixel_type px;
            faAnchorLock.point(point16(x,y),&px);
            float luma =px.template channelr<0>();
            if((luma>=.5)) {
                tmp|=(1<<(7-offs));
            }
            ++i;
            ++offs;
            if(8==offs) {
                test_data[idx]=tmp;
                tmp=0;
                offs=0;
                ++idx;
            }
        }
    }
    if(offs!=0) {
        test_data[idx]=tmp;
    }
}


Like magic.

Not difficult code, by any means, but it just eluded me. And yes, I could replace ifs with shifts and such but I didn't make this to perform - I made it to be able to be read by someone else and ported.
There's smoke in my iris
But I painted a sunny day on the insides of my eyelids
So I'm ready now (What you ready for?)
I'm ready for life in this city
And my wings have grown almost enough to lift me

GeneralRe: The magic of coffee Pin
Craig Robbins9-Jun-23 4:41
Craig Robbins9-Jun-23 4:41 
GeneralRe: The magic of coffee Pin
OriginalGriff9-Jun-23 4:56
mveOriginalGriff9-Jun-23 4:56 
GeneralRe: The magic of coffee Pin
Gary Wheeler9-Jun-23 5:53
Gary Wheeler9-Jun-23 5:53 
GeneralRe: The magic of coffee Pin
jschell9-Jun-23 10:03
jschell9-Jun-23 10:03 
GeneralRe: The magic of coffee Pin
Gary R. Wheeler9-Jun-23 15:03
Gary R. Wheeler9-Jun-23 15:03 
GeneralRe: The magic of coffee Pin
sasadler12-Jun-23 10:21
sasadler12-Jun-23 10:21 
GeneralRe: The magic of coffee Pin
Cpichols13-Jun-23 3:09
Cpichols13-Jun-23 3:09 
GeneralRe: The magic of coffee Pin
Slacker0079-Jun-23 4:42
professionalSlacker0079-Jun-23 4:42 
GeneralRe: The magic of coffee Pin
honey the codewitch9-Jun-23 5:17
mvahoney the codewitch9-Jun-23 5:17 
GeneralRe: The magic of coffee PinPopular
Gary Wheeler9-Jun-23 5:56
Gary Wheeler9-Jun-23 5:56 
GeneralRe: The magic of coffee Pin
Slacker0079-Jun-23 6:04
professionalSlacker0079-Jun-23 6:04 
GeneralRe: The magic of coffee Pin
Brisingr Aerowing11-Jun-23 3:59
professionalBrisingr Aerowing11-Jun-23 3:59 
GeneralRe: The magic of coffee Pin
Marc Clifton9-Jun-23 4:48
mvaMarc Clifton9-Jun-23 4:48 
GeneralRe: The magic of coffee Pin
honey the codewitch9-Jun-23 5:16
mvahoney the codewitch9-Jun-23 5:16 
GeneralRe: The magic of coffee Pin
Member 1180367312-Jun-23 2:22
Member 1180367312-Jun-23 2:22 
GeneralRe: The magic of coffee Pin
kmoorevs9-Jun-23 6:19
kmoorevs9-Jun-23 6:19 
GeneralRe: The magic of coffee Pin
jeron19-Jun-23 7:12
jeron19-Jun-23 7:12 

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.