From 5464b10f1a6abf6d29fced2007aa74a5e667863b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Fri, 18 Apr 2008 18:10:44 +0000 Subject: [PATCH] * get_uint32_color() now returns the color as host endian value. * Introduced a new get_rgb_color(), that returns an rgb_color from a host endian uint32. * Those two together fix bug #2094. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25031 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/interface/View.cpp | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/kits/interface/View.cpp b/src/kits/interface/View.cpp index c5d46fdf35..2b8409c994 100644 --- a/src/kits/interface/View.cpp +++ b/src/kits/interface/View.cpp @@ -104,7 +104,17 @@ static property_info sViewPropInfo[] = { static inline uint32 get_uint32_color(rgb_color color) { - return *(uint32 *)&color; + return B_BENDIAN_TO_HOST_INT32(*(uint32 *)&color); + // rgb_color is always in rgba format, no matter what endian; + // we always return the int32 value in host endian. +} + + +static inline rgb_color +get_rgb_color(uint32 value) +{ + value = B_HOST_TO_BENDIAN_INT32(value); + return *(rgb_color *)&value; } @@ -406,13 +416,13 @@ BView::BView(BMessage *archive) | B_FONT_SHEAR | B_FONT_ROTATION); } - rgb_color color; - if (archive->FindInt32("_color", 0, (int32 *)&color) == B_OK) - SetHighColor(color); - if (archive->FindInt32("_color", 1, (int32 *)&color) == B_OK) - SetLowColor(color); - if (archive->FindInt32("_color", 2, (int32 *)&color) == B_OK) - SetViewColor(color); + int32 color; + if (archive->FindInt32("_color", 0, &color) == B_OK) + SetHighColor(get_rgb_color(color)); + if (archive->FindInt32("_color", 1, &color) == B_OK) + SetLowColor(get_rgb_color(color)); + if (archive->FindInt32("_color", 2, &color) == B_OK) + SetViewColor(get_rgb_color(color)); uint32 evMask; uint32 options; @@ -512,10 +522,8 @@ BView::Archive(BMessage *data, bool deep) const // colors if (ret == B_OK) ret = data->AddInt32("_color", get_uint32_color(HighColor())); - if (ret == B_OK) ret = data->AddInt32("_color", get_uint32_color(LowColor())); - if (ret == B_OK) ret = data->AddInt32("_color", get_uint32_color(ViewColor()));