Created
June 11, 2015 11:37
-
-
Save patilarpith/08580b03f61145af5591 to your computer and use it in GitHub Desktop.
RGB32 to RGB888
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <string.h> | |
#include <math.h> | |
#include <stdlib.h> | |
#define getR(value) ((value & 0x0000FF00) >> 8) | |
#define getG(value) ((value & 0x00FF0000) >> 16) | |
#define getB(value) ((value & 0xFF000000) >> 24) | |
int main() { | |
int testcases = 0; | |
scanf("%d", &testcases); | |
int width = 0, height = 0; | |
scanf("%d %d", &width, &height); | |
for(int i = 0; i < testcases; i++) | |
{ | |
for(int j = 0; j < height; j++) | |
{ | |
for(int k = 0; k < width; k++) | |
{ | |
unsigned pixel = 0; | |
scanf("%u", &pixel); | |
printf("%u %u %u ", getR(pixel), getG(pixel), getB(pixel)); | |
} | |
printf("\n"); | |
} | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment