Skip to content

Instantly share code, notes, and snippets.

@patilarpith
Created June 11, 2015 11:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save patilarpith/08580b03f61145af5591 to your computer and use it in GitHub Desktop.
Save patilarpith/08580b03f61145af5591 to your computer and use it in GitHub Desktop.
RGB32 to RGB888
#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