diff options
author | Daniel <790119+DanTheMan827@users.noreply.github.com> | 2017-12-01 06:37:38 +0300 |
---|---|---|
committer | Daniel <790119+DanTheMan827@users.noreply.github.com> | 2017-12-01 06:37:38 +0300 |
commit | ac7f36a559396b2acae2bec3302078ac49b9eb1a (patch) | |
tree | 4fdbe1af9aa76e6e433856141ac4313863aa50b2 | |
parent | 058ce88e55db765f715b41b902b980c78df42fc7 (diff) |
Swap red / blue and output twicebgra2x
-rw-r--r-- | decodepng.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/decodepng.c b/decodepng.c index 907be9a..5d75bc3 100644 --- a/decodepng.c +++ b/decodepng.c @@ -2,6 +2,23 @@ #include <stdint.h> #include "lodepng/lodepng.h" +static inline void rgbSwap(unsigned char*buf) +{ + unsigned char t; + t=buf[0]; + buf[0]=buf[2]; + buf[2]=t; + buf[3]=0; +} + +static void rgbSwapImage(unsigned char*buf,unsigned len) +{ + for(unsigned i=0;i<len;i+=4) + { + rgbSwap(buf+i); + } +} + int main(int argc, char *argv[]) { if(argc < 2) @@ -28,6 +45,8 @@ int main(int argc, char *argv[]) return 1; } + rgbSwapImage(image,imageLength); + fwrite(image, 1, imageLength, stdout); fwrite(image, 1, imageLength, stdout); fflush(stdout); |