Skip to content

Instantly share code, notes, and snippets.

@sudhackar
Created March 21, 2018 13:56
Show Gist options
  • Save sudhackar/810e6888f0523489f22886908e264e4b to your computer and use it in GitHub Desktop.
Save sudhackar/810e6888f0523489f22886908e264e4b to your computer and use it in GitHub Desktop.
rgb
/*
* untitled.c
*
* Copyright 2018 Sudhakar Verma <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*
*
*/
#include <stdio.h>
#include <stdint.h>
uint32_t x(uint8_t in){
uint32_t i=0, f=0;
for(i=0;i<8;++i){
f=f|((4|((in&1)<<1))<<(3*i));
in=in>>1;
}
return f;
}
int main(int argc, char **argv){
uint8_t in;
uint32_t out;
while(1){
scanf("%hhu",&in);
out = x(in);
printf("%x\n", out);}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment