diff options
author | pvalchev@google.com <pvalchev@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-13 22:06:01 +0000 |
---|---|---|
committer | pvalchev@google.com <pvalchev@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-13 22:06:01 +0000 |
commit | 7cd70c394eeaeb6a93a8e28142942b5584f01e2d (patch) | |
tree | 4a3bde2aefad49928afe234d0d48154370ecbfc5 /app/gtk_util.cc | |
parent | 42b206a6890ec008ed2729b36a5a58f0f334b3be (diff) | |
download | chromium_src-7cd70c394eeaeb6a93a8e28142942b5584f01e2d.zip chromium_src-7cd70c394eeaeb6a93a8e28142942b5584f01e2d.tar.gz chromium_src-7cd70c394eeaeb6a93a8e28142942b5584f01e2d.tar.bz2 |
Move non-linux specific code from base/linux_util to app/gtk_util
from sprewell
Review URL: http://codereview.chromium.org/2058004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@47201 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'app/gtk_util.cc')
-rw-r--r-- | app/gtk_util.cc | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/app/gtk_util.cc b/app/gtk_util.cc index 0411fbb..00b1b5b 100644 --- a/app/gtk_util.cc +++ b/app/gtk_util.cc @@ -31,6 +31,26 @@ void GetWidgetSizeFromResources( GetWidgetSizeFromCharacters(widget, chars, lines, width, height); } +uint8_t* BGRAToRGBA(const uint8_t* pixels, int width, int height, int stride) { + if (stride == 0) + stride = width * 4; + + uint8_t* new_pixels = static_cast<uint8_t*>(malloc(height * stride)); + + // We have to copy the pixels and swap from BGRA to RGBA. + for (int i = 0; i < height; ++i) { + for (int j = 0; j < width; ++j) { + int idx = i * stride + j * 4; + new_pixels[idx] = pixels[idx + 2]; + new_pixels[idx + 1] = pixels[idx + 1]; + new_pixels[idx + 2] = pixels[idx]; + new_pixels[idx + 3] = pixels[idx + 3]; + } + } + + return new_pixels; +} + void GetWidgetSizeFromCharacters( GtkWidget* widget, double width_chars, double height_lines, int* width, int* height) { |