Roll third_party/android_tools to the latest: updated the support library to 19.0.1
[chromium-blink-merge.git] / ui / gfx / color_profile_win.cc
blob2e08a36d4b65a06a079fcf73ebcc335ab2c70c91
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ui/gfx/color_profile.h"
7 #include <windows.h>
9 #include "base/file_util.h"
11 namespace gfx {
13 void ReadColorProfile(std::vector<char>* profile) {
14 // TODO: support multiple monitors.
15 HDC screen_dc = GetDC(NULL);
16 DWORD path_len = MAX_PATH;
17 WCHAR path[MAX_PATH + 1];
19 BOOL res = GetICMProfile(screen_dc, &path_len, path);
20 ReleaseDC(NULL, screen_dc);
21 if (!res)
22 return;
23 std::string profileData;
24 if (!base::ReadFileToString(base::FilePath(path), &profileData))
25 return;
26 size_t length = profileData.size();
27 if (length > gfx::kMaxProfileLength)
28 return;
29 if (length < gfx::kMinProfileLength)
30 return;
31 profile->assign(profileData.data(), profileData.data() + length);
34 } // namespace gfx