Skip to main content
added 5 characters in body
Source Link
Cliff B
  • 69.3k
  • 4
  • 33
  • 56

In the demo code that merely copies a bitmap, they are demonstrating how to strip off the padding and then add it back when writing to the outfile because that ability will be needed later.

Yes, every scan line has padding at the end because each line needs to end on a 4-bitbyte boundary. Keep that in mind because when you are scaling the image up to a larger size, the amount of padding needed will change unless the scaling factor is 1 or a multiple of 4.

So, when you read in the date from the source file, you get the relevant data, the pixels, and then skip over or discard the padding. Then, when you scale up, you write out the pixels x scaling factor, and then add the appropriate amount of padding for the output file, which you must calculate for the output file scan line length. Finally, note that you can't just multiply the input padding by the scaling factor to get the output padding.

If this answers your question, please accept this answer to remove the question from the unanswered question pool. Let's keep up on forum housekeeping. ;-)

In demo code that merely copies a bitmap, they are demonstrating how to strip off the padding and then add it back when writing to the outfile because that ability will be needed later.

Yes, every scan line has padding at the end because each line needs to end on a 4-bit boundary. Keep that in mind because when you are scaling the image up to a larger size, the amount of padding needed will change unless the scaling factor is 1 or a multiple of 4.

So, when you read in the date from the source file, you get the relevant data, the pixels, and then skip over or discard the padding. Then, when you scale up, you write out the pixels x scaling factor, and then add the appropriate amount of padding for the output file, which you must calculate for the output file scan line length. Finally, note that you can't just multiply the input padding by the scaling factor to get the output padding.

If this answers your question, please accept this answer to remove the question from the unanswered question pool. Let's keep up on forum housekeeping. ;-)

In the demo code that merely copies a bitmap, they are demonstrating how to strip off the padding and then add it back when writing to the outfile because that ability will be needed later.

Yes, every scan line has padding at the end because each line needs to end on a 4-byte boundary. Keep that in mind because when you are scaling the image up to a larger size, the amount of padding needed will change unless the scaling factor is 1 or a multiple of 4.

So, when you read in the date from the source file, you get the relevant data, the pixels, and then skip over or discard the padding. Then, when you scale up, you write out the pixels x scaling factor, and then add the appropriate amount of padding for the output file, which you must calculate for the output file scan line length. Finally, note that you can't just multiply the input padding by the scaling factor to get the output padding.

If this answers your question, please accept this answer to remove the question from the unanswered question pool. Let's keep up on forum housekeeping. ;-)

Source Link
Cliff B
  • 69.3k
  • 4
  • 33
  • 56

In demo code that merely copies a bitmap, they are demonstrating how to strip off the padding and then add it back when writing to the outfile because that ability will be needed later.

Yes, every scan line has padding at the end because each line needs to end on a 4-bit boundary. Keep that in mind because when you are scaling the image up to a larger size, the amount of padding needed will change unless the scaling factor is 1 or a multiple of 4.

So, when you read in the date from the source file, you get the relevant data, the pixels, and then skip over or discard the padding. Then, when you scale up, you write out the pixels x scaling factor, and then add the appropriate amount of padding for the output file, which you must calculate for the output file scan line length. Finally, note that you can't just multiply the input padding by the scaling factor to get the output padding.

If this answers your question, please accept this answer to remove the question from the unanswered question pool. Let's keep up on forum housekeeping. ;-)