From ec041ec6ee996368e3609f8e5401919c83c1caa3 Mon Sep 17 00:00:00 2001 From: Arthur Moore Date: Thu, 12 Mar 2015 21:10:17 -0400 Subject: [PATCH] Make the algorithm used to convert a 32bit image to a 24bit one easier to understnad. All it's doing is skipping the alpha channel when copying the data over --- debian-build.sh | 3 +++ src/filters/filters.cpp | 24 +++++++++++++----------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/debian-build.sh b/debian-build.sh index 86a87c05..e795fcf6 100755 --- a/debian-build.sh +++ b/debian-build.sh @@ -23,3 +23,6 @@ cd build cmake .. make #scan-build make + +#For profiling: +#valgrind --tool=callgrind ./wxvbam diff --git a/src/filters/filters.cpp b/src/filters/filters.cpp index ed6b4797..845d4783 100644 --- a/src/filters/filters.cpp +++ b/src/filters/filters.cpp @@ -44,18 +44,20 @@ const std::map filters::filterMap = makeFilterMap(); //Convert a 32 bit image to a 24 bit one void convert32To24(u32* src,u8* dst,unsigned int width, unsigned int height) { -// //Each pixel is 3 bytes, which is NOT a common unit, so have to use u8 and manually multiply -// for(unsigned int i=0;i>8)&0xFF) | ((src[i]>>16)&0xFF); -// } + //Need src as a single byte pointer for this to work + u8 * u8src = (u8*)src; - for(unsigned int y = 0; y < height ; y++) { - for(unsigned int x = 0; x < width; x++, src++) { - *dst++ = *src; - *dst++ = *src >> 8; - *dst++ = *src >> 16; + for(unsigned int y = 0; y < height ; y++) + { + for(unsigned int x = 0; x < width; x++) + { + //For each pixel copy r,g,b one byte at a time + for(unsigned int i = 0; i<3; i++) + { + *dst++ = *u8src++; + } + //Skip the alpha channel + u8src++; } -// ++src; // skip rhs border } }