0

I have a simple doubt that, can padding be put for all of the scan-lines at once? What I mean to say is, that suppose, I have bi.biHeight == 10 then if I Write for (int k = 0; k < padding; k++) { fputc(0x00, outptr); } where padding has been defined earlier(not here, but in the code). Will the above code add padding for all 10 scan-lines?

Also this line fseek(inptr, padding, SEEK_CUR);

does this line skip all paddings in the file i.e. skips reading padding for all 10 scan-lines?

1 Answer 1

1

While we think of an image as pixels and lines, i.e., a two dimensional array like a checkerboard, the data is stored in the file as a single linear string of data. Adding the padding all at once would either write it all in one place, probably at the end, would overwrite image data and leave a corrupted file, or would require a complicated process that would require writing each padding separately, defeating the goal of writing all at once.

If I understand your question, it seems like you want to add all the padding after processing the image data. To do so, you'd have to insert the padding between "rows of pixels" or more accurately, into the interior of the string of data at the correct locations. While theoretically possible, it would be very complicated by comparison and prone to errors. To do this, you'd be repeating most of the process that you've just done and that which you'd have to do to add the padding as you went along anyways.

It is far simpler and easier to just insert the padding as you go.

If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)

You must log in to answer this question.

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