0

I was hoping to get some opinions on the optimal solution for variable changes. In the resize project you have to change the BI and BF variables (height, width, biSizeImage, bfSize etc.). I changed those variable's values to calculate the outfile headers and padding then changed them back to the original values before writing the pixels to the outfile. Would this be the optimal solution for processing speed? Memory management? General style and ease of use? I've seen people create new variables and assign the new values to them, and this is what I'm trying to compare.

P.S. I have 2 other questions outstanding that I wouldn't mind an opinion on, if you have the time!

0

I'd say the difference is very minor in this case in particular. typically there are multiple solutions to a problem. there is also a trade-off between time and space.

it's probably easier to create a couple of variables to cache the original biWidth and biHeight and perform the calculations once on the headers and avoid the headache of resetting the values back, but that would consume more space.

modifying the headers twice would save space but probably would take more time (perhaps unless you're only resetting biWidth and biHeight back).

it's a good practice not to create new variables if you don't need to. the need for a variable doesn't necessarily have to be for space. it could be for clarity. using less variables saves space, but often increases time (because of the trade-off). it's mainly a matter of design decision.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .