The first problem I had was, based on commonality the PNG flips were all wrong; this was a simple coding error; I put 'false' when I meant 'true'.
The biggest issue was two of the TGA decoders not working properly; this turned out to be me being pwn'd hard by operator presidence; (row+1 * width) wasn't what I meant, ((row+1) * width) was [grin]
One last and very puzzling bug remains with the TGA RLE loaders; setting the origin to the bottom left doesn't produce the correct output.
The test image I have is 4 circles arranged thusly;
(where R = Red, G = Green, B = Blue and Y = Yellow)
Everyone else outputs
The RLE TGA code however throw out;
This is slightly puzzling.
The TGA Image is stored as
in memory (this is the output from the 'no flip' path), so to get the correct output we need to flip it in the 'x' axis.
The decoder hits the correct code path, everything seems to setup correctly, yet for some reason the output is always;
Which is a full flip o.O
I've probably got something wrong with the maths somewhere, but I'm getting too tired to get staring at it, so I'll throw it out here, see if anyone else spots the problem before me;
const int imgsize = width * height;
while (count > 0)
int row = offset / width; // get the row we are on i.e. 12 / 10 = row 1 (check interger divsion...)
int rowRemains = width - (offset % width);
int copyAmount = (count > rowRemains) ? rowRemains : count;
forward_mem_iter end_itor(src + copyAmount);
int rowoffset = ((row+1) * width) - (width - rowRemains) - 1;
reverse_mem_iter dest_itor(dest + rowoffset );
count -= copyAmount;
offset += copyAmount;
src += copyAmount;
Where 'count' is the element repeat amount or number of elements to copy.
"width" is the row width.
"height" is the image height.
"offset" is the offset in elements we are into the decoded image.
The memory iter objects are just standard iterators, with the reverse iter stepping backwards thru memory.
Dest is the START of the destination memory, this is NOT changed as the algo. progresses thus we have to workout the offset each time.
Get to end of current row, then step backwards from that position by however much we have already written into that row. The '-1' is there to ensure we stay on the correct row.
The two Copy functions call std::fill_n and std::transform respectively under the hood.
Any ideas anyone?