1
0

images.cpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #include "main.h"
  2. #include "images.h"
  3. #include "resource.h"
  4. #include <strsafe.h>
  5. static int small_images[] = { IDB_GENERIC_16, IDB_EVO_16, IDB_INCREDIBLE_16, IDB_NEXUSONE_16, IDB_DROID_16 };
  6. static int large_images[] = { IDB_GENERIC_160, IDB_EVO_160, IDB_INCREDIBLE_160, IDB_NEXUSONE_160, IDB_DROID_160 };
  7. int GetImageIndex(const wchar_t *manufacturer, const wchar_t *model)
  8. {
  9. if (!wcscmp(manufacturer, L"HTC"))
  10. {
  11. if (!wcscmp(model, L"PC36100")) // evo
  12. {
  13. return 1;
  14. }
  15. else if (!wcscmp(model, L"ADR6300")) // incredible
  16. {
  17. return 2;
  18. }
  19. else if (!wcscmp(model, L"Nexus One"))
  20. {
  21. return 3;
  22. }
  23. }
  24. else if (!wcscmp(manufacturer, L"motorola"))
  25. {
  26. if (!wcscmp(model, L"DROID2"))
  27. {
  28. return 4;
  29. }
  30. }
  31. return 0;
  32. }
  33. void GetImagePath(int image_index, int width, int height, wchar_t *path, size_t path_cch)
  34. {
  35. if (image_index < 0)
  36. {
  37. path[0]=0;
  38. return;
  39. }
  40. if (width <= 16 && height <= 16)
  41. {
  42. if (image_index >= sizeof(small_images)/sizeof(small_images[0]))
  43. {
  44. path[0]=0;
  45. return;
  46. }
  47. int resource = small_images[image_index];
  48. FormatResProtocol(MAKEINTRESOURCE(resource), L"PNG", path, path_cch);
  49. }
  50. else
  51. {
  52. if (image_index >= sizeof(large_images)/sizeof(large_images[0]))
  53. {
  54. path[0]=0;
  55. return;
  56. }
  57. int resource = large_images[image_index];
  58. FormatResProtocol(MAKEINTRESOURCE(resource), L"PNG", path, path_cch);
  59. }
  60. }
  61. int GetSmallImageID(int image_index)
  62. {
  63. if (image_index < 0 || image_index >= sizeof(small_images)/sizeof(small_images[0]))
  64. return IDB_GENERIC_16;
  65. return small_images[image_index];
  66. }