Bitmap file saving problem.

Started by
10 comments, last by Undeadlnsanity 18 years ago
When you are loading the data into the array with the nested loop, you have an "iteration" over rows, and over columns. You want to go over the rows backwards, so that ... er, never mind, the order you do it in doesn't matter; rather, the idea is to copy row X to row (N-X) instead.

Er, wait. Then again, now that I look at it, you already have:

for( int y = temp->h - 1, y2 = 0; y >= 0 && y2 < sheight; --y, ++y2 )


The idea being that 'y' counts backwards over rows, and 'y2' counts forwards over them, and you thus reverse the rows as you copy them across. Apparently (given your results) you're supposed to *not* do that, as a consequence of whatever SDL is doing internally to be BMP-friendly.
Advertisement
The problem was fixed with this code:
uint8_t *imagepixels = reinterpret_cast<uint8_t*>(image->pixels);// Copy the "reversed_image" memory to the "image" memoryfor (int y = (sheight - 1); y >= 0; --y) {	uint8_t *row_begin = pixels + y * swidth * 3;	uint8_t *row_end = row_begin + swidth * 3;	std::copy(row_begin, row_end, imagepixels);	// Advance a row in the output surface.	imagepixels += image->pitch;}


Thanks for your help everyone!

rate++

This topic is closed to new replies.

Advertisement