Open Source Tomb Raider Engine
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

mtk_tga.cpp 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*================================================================
  2. *
  3. * Project : Freyja
  4. * Author : Mongoose
  5. * Website : http://www.westga.edu/~stu7440/
  6. * Email : stu7440@westga.edu
  7. * Object :
  8. * License : GPL See file COPYING, also (C) 2000 Mongoose
  9. * Comments: TGA plug-in
  10. *
  11. * TODO: type should pass more info
  12. * 2 bits for RGBA | RGB | GREY
  13. * val for depth
  14. *
  15. * This file was generated using Mongoose's C++
  16. * template generator script. <stu7440@westga.edu>
  17. *
  18. *-- History ------------------------------------------------
  19. *
  20. * 2001-10-25:
  21. * Mongoose - support for screen origin bit
  22. *
  23. * 2000-10-15:
  24. * Mongoose - Created
  25. ================================================================*/
  26. #include <string.h>
  27. #include <stdarg.h>
  28. #include <mtk_tga.h>
  29. int main(int argc, char *argv[])
  30. {
  31. FILE *f;
  32. unsigned char *image;
  33. unsigned int width;
  34. unsigned int height;
  35. char type;
  36. if (argc > 1)
  37. {
  38. f = fopen(argv[1], "r");
  39. if (!f)
  40. {
  41. perror("Failed to open file> ");
  42. return -1;
  43. }
  44. if (!mtk_image__tga_check(f))
  45. {
  46. if (!mtk_image__tga_load(f, &image, &width, &height, &type))
  47. {
  48. printf("Loaded %s successfully!\n", argv[1]);
  49. delete [] image;
  50. }
  51. }
  52. fclose(f);
  53. } else {
  54. printf("Usage: %s testfile.tga\n", argv[0]);
  55. }
  56. return 0;
  57. }