0

I am currently working on resize (more comfortable).

my code works with check50 for all scale factors greater than and equal to one (meaning to say it will get a perfect on resize less comfortable). However, factors between 0 and 1 somehow should affect the size of the file headers, specifically bf.bfSize.

For example if a BMP is scaled down by a factor of 0.5, bfSize is expected to be 0x5a (90) instead of our usual 0x36 (54).

Conceptually, how does the scale factor affect these BMP header sizes?

My code is here: https://pastebin.com/4BRrcBZS The most important part to focus on is the lines within the rows of '/'

Thanks in advance~

1 Answer 1

0

You must have found out the answer, but still I am contributing as it may help others.

The factor does not affect the sizes of BITMAPFILEHEADER and BITMAPINFOHEADER. Both of these are structures. Structers are like containers. See the following example.

#include <stdio.h>

typedef struct rectangle
{
    int width;
    int height;
} square;

int main(void)
{
    square sq1;
    sq1.width = 20;
    sq1.height = 20;
    printf("width = %d, height = %d\n", sq1.width, sq1.height); /*outputs width = 20, height = 20*/
    printf("sizeof square = %lu\n", sizeof(square)); /*outputs sizeof square = 8*/

    return 0;
}

In the above example, we've declared a structure sq1 of type square. It doesn't matter how much we reduce or increase the value of sq1.width or sq1.height, the sizeof(square) will always remain 8bytes. This is why the sizeof(BITMAPFILEHEADER) is always 14bytes and the sizeof(BITMAPINFOHEADER) is always 40bytes.

Hope that answers your question. Correct me if I have misunderstood.

You must log in to answer this question.

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