Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/DanTheMan827/decodepng.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel <790119+DanTheMan827@users.noreply.github.com>2017-12-01 06:37:38 +0300
committerDaniel <790119+DanTheMan827@users.noreply.github.com>2017-12-01 06:37:38 +0300
commitac7f36a559396b2acae2bec3302078ac49b9eb1a (patch)
tree4fdbe1af9aa76e6e433856141ac4313863aa50b2
parent058ce88e55db765f715b41b902b980c78df42fc7 (diff)
Swap red / blue and output twicebgra2x
-rw-r--r--decodepng.c19
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);