[Libreoffice] [Patch] Code review fix

Muthu Subramanian K sumuthu at suse.com
Mon Dec 5 03:56:00 PST 2011


Hi,

During the code digging for one of the bugs, I came across GetXPixel()
function in vcl. Which seems to be implemented wrong - not sure why it
is multiplied by 257 - the idea, I believe, is to convert 8bit to 16bit
values for X11, but I may be wrong. I have attached the patch with this
mail for review.

Thank you!
Muthu Subramanian

diff --git a/vcl/unx/generic/app/saldisp.cxx
b/vcl/unx/generic/app/saldisp.cxx
index 9ef3601..a92ed1d 100644
--- a/vcl/unx/generic/app/saldisp.cxx
+++ b/vcl/unx/generic/app/saldisp.cxx
@@ -3159,9 +3159,9 @@ inline sal_Bool SalColormap::GetXPixel( XColor
&rColor,
                                           int     g,
                                           int     b ) const
 {
-    rColor.red      = r * 257;
-    rColor.green    = g * 257;
-    rColor.blue     = b * 257;
+    rColor.red      = r << 8;
+    rColor.green    = g << 8;
+    rColor.blue     = b << 8;
     return XAllocColor( GetXDisplay(), m_hColormap, &rColor );
 }



More information about the LibreOffice mailing list