diff.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include "../tp2.h"
  5. void diff_asm (unsigned char *src, unsigned char *src_2, unsigned char *dst,
  6. int cols, int filas, int src_row_size,
  7. int src_row_size_2 ,int dst_row_size);
  8. void diff_c (unsigned char *src, unsigned char *src_2, unsigned char *dst,
  9. int cols, int filas, int src_row_size,
  10. int src_row_size_2 ,int dst_row_size);
  11. typedef void (diff_fn_t) (unsigned char*, unsigned char*, unsigned char*,
  12. int, int, int, int, int);
  13. void ayuda_diff()
  14. {
  15. printf ( " * diff\n" );
  16. printf ( " Parámetros : \n"
  17. " no tiene\n");
  18. printf ( " Ejemplo de uso : \n"
  19. " diff -i c facil.bmp facil2.bmp\n" );
  20. }
  21. void leer_params_diff(configuracion_t *config, int argc, char *argv[]) {
  22. if (config->archivo_entrada_2 == NULL) {
  23. printf("El filtro diff requiere de dos archivos de entrada\n\n");
  24. ayuda_diff();
  25. exit(EXIT_FAILURE);
  26. } else {
  27. printf ( " Archivo de entrada : %s\n", config->archivo_entrada_2);
  28. }
  29. }
  30. void aplicar_diff(configuracion_t *config)
  31. {
  32. diff_fn_t *diff = SWITCH_C_ASM ( config, diff_c, diff_asm ) ;
  33. buffer_info_t info = config->src;
  34. buffer_info_t info2 = config->src_2;
  35. if (info.width != info2.width || info.height != info2.height) {
  36. perror("Las imagenes deben tener el mismo tamaño en pixeles");
  37. }
  38. diff(info.bytes, info2.bytes, config->dst.bytes, info.width, info.height,
  39. info.width_with_padding, info2.width_with_padding,
  40. config->dst.width_with_padding);
  41. }