~regan-koopmans/tifftastic

b8f1733033574b9784fb6c676fbf73fa3108bb31 — Regan-Koopmans 12 days ago 705e51d
Add readme
2 files changed, 23 insertions(+), 3 deletions(-)

A README.md
M main.c
A README.md => README.md +15 -0
@@ 0,0 1,15 @@
# tifftastic

This is an educational project to better understand the TIFF file format.

## Building

```
make
```

## Usage

```
./tifftastic <filename>
```
\ No newline at end of file

M main.c => main.c +8 -3
@@ 80,7 80,7 @@ int render(struct ImageData *data) {
  }
}

struct Result read_data() {
struct Result read_data(char * filename) {
  FILE *fptr;
  struct TifHeader header;
  struct TifDirectory directory;


@@ 145,6 145,7 @@ struct Result read_data() {

  unsigned char * pixels = malloc(total);
  int total_pointer = 0;
  // First read the packed bits into a buffer, then expand
  for (int i = 0; i < strip_count; i++) {
    fseek(fptr, strip_offsets[i], 0);
    unsigned char * other = malloc(strip_bytes[i]);


@@ 171,8 172,12 @@ struct Result read_data() {
  return SOME(data);
}

int main() {
  struct Result result = read_data();
int main(int argc, char ** argv) {
  if (argc < 2) {
    printf("Please provide a file path to open\n");
    return 0;
  }
  struct Result result = read_data(argv[1]);
  if (result.is_error) {
    printf("Could not read tiff file, nested error: %s\n", result.value);
  }