aboutsummaryrefslogtreecommitdiff
path: root/Src/Plugins/Portable/pmp_wifi/images.cpp
blob: 6badb9298ed88c585995ba145d929d4b86080f10 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include "main.h"
#include "images.h"
#include "resource.h"
#include <strsafe.h>

static int small_images[] = { IDB_GENERIC_16, IDB_EVO_16, IDB_INCREDIBLE_16, IDB_NEXUSONE_16, IDB_DROID_16 };
static int large_images[] = { IDB_GENERIC_160, IDB_EVO_160, IDB_INCREDIBLE_160, IDB_NEXUSONE_160, IDB_DROID_160 };
int GetImageIndex(const wchar_t *manufacturer, const wchar_t *model)
{
	if (!wcscmp(manufacturer, L"HTC"))
	{
		if (!wcscmp(model, L"PC36100")) // evo
		{
			return 1;
		}
		else if (!wcscmp(model, L"ADR6300")) // incredible
		{
			return 2;
		}
		else if (!wcscmp(model, L"Nexus One"))
		{
			return 3;
		}
	}
	else if (!wcscmp(manufacturer, L"motorola"))
	{
		if (!wcscmp(model, L"DROID2"))
		{
			return 4;
		}
	}

	return 0;
}

void GetImagePath(int image_index, int width, int height, wchar_t *path, size_t path_cch)
{
	if (image_index < 0)
	{
		path[0]=0;
		return;
	}

	if (width <= 16 && height <= 16)
	{
		if (image_index >= sizeof(small_images)/sizeof(small_images[0]))
		{
			path[0]=0;
			return;
		}
		int resource = small_images[image_index];
		FormatResProtocol(MAKEINTRESOURCE(resource), L"PNG", path, path_cch);
	}
	else
	{
		if (image_index >= sizeof(large_images)/sizeof(large_images[0]))
		{
			path[0]=0;
			return;
		}
		int resource = large_images[image_index];
		FormatResProtocol(MAKEINTRESOURCE(resource), L"PNG", path, path_cch);
	}
}

int GetSmallImageID(int image_index)
{
	if (image_index < 0 || image_index >= sizeof(small_images)/sizeof(small_images[0]))
		return IDB_GENERIC_16;

	return small_images[image_index];
}