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:
Diffstat (limited to 'decodepng.c')
-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);