1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// MORE SUGGESTED HELPER FUNCTIONS FOR HW11
//
// In class, I said that ideally, a function should contain code at a given
// level of abstraction.  For example, a function that operates at the level
// of pixels should not contain any byte-level calculations.
//
// To the extent that you can follow this, it will make problems easier to think
// about because a given function will read at the same level of detail you
// would describe verbally.
//
// The helper functions below (just outlines, obviously) handle byte-level calculations
// so that code in your


int _get_offset_in_data(int x, int y, int img_w, int img_h) {
    int padding_per_row = ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒;
    int row_start_index = ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒;
    int index_in_row    = ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒;
    return ▒▒▒▒▒▒▒▒▒▒;
}


// _Color - a helper structure used only
typedef struct {
    uint8_t r;
    uint8_t g;
    uint8_t b;
} _Color;


_Color _get_pixel(const BMPImage* image, int x, int y) {
    ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒;

    return (_Color) { .r = ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒,
                      .g = ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒,
                      .b = ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ };
}

© Copyright 2019 Alexander J. Quinn         This content is protected and may not be shared, uploaded, or distributed.