Commit b91288ec051ec229a9a546c23549b4cd157d8857

Authored by henyxia
1 parent a8ebb985

Opening files

New makefile
Showing 3 changed files with 51 additions and 0 deletions   Show diff stats
.gitignore 0 โ†’ 100644
... ... @@ -0,0 +1 @@
  1 +bmp2rgb565
... ...
Makefile 0 โ†’ 100644
... ... @@ -0,0 +1,19 @@
  1 +CC=gcc
  2 +CC_FLAGS=-c -Wall -Werror -std=gnu99 -g
  3 +CC_LIBS=
  4 +INCLUDES=
  5 +
  6 +SOURCES=main.c
  7 +OBJECTS=$(SOURCES:.c=.o)
  8 +OUTPUT=bmp2rgb565
  9 +
  10 +all: $(SOURCES) $(OUTPUT)
  11 +
  12 +$(OUTPUT): $(OBJECTS)
  13 + $(CC) $(OBJECTS) $(CC_LIBS) -o $@
  14 +
  15 +%.o: %.c
  16 + $(CC) $(INCLUDES) $(CC_FLAGS) $< -o $@
  17 +
  18 +clear:
  19 + rm -f $(OUTPUT) $(OBJECTS)
... ...
main.c 0 โ†’ 100644
... ... @@ -0,0 +1,31 @@
  1 +#include <stdio.h>
  2 +#include <stdlib.h>
  3 +
  4 +int main(int argc, char *argv[])
  5 +{
  6 + if(argc != 3)
  7 + {
  8 + printf("bmp2rgb565 [BMP_SRC] [RGB565_DEST]\n");
  9 + return 1;
  10 + }
  11 +
  12 + FILE* src = NULL;
  13 + FILE* dst = NULL;
  14 +
  15 + src = fopen(argv[1], "r");
  16 + dst = fopen(argv[2], "w");
  17 +
  18 + if(src == NULL)
  19 + {
  20 + printf("Unable to open the BMP file\n");
  21 + return 2;
  22 + }
  23 +
  24 + if(dst == NULL)
  25 + {
  26 + printf("Unable to open the RGB565 file\n");
  27 + return 3;
  28 + }
  29 +
  30 + return 0;
  31 +}
... ...