]> source.dussan.org Git - tigervnc.git/commitdiff
Added support all true color pixel format for scaling the
authorgeorge82 <george82@3789f03b-4d11-0410-bbf8-ca57d06f2519>
Sun, 26 Nov 2006 11:18:38 +0000 (11:18 +0000)
committergeorge82 <george82@3789f03b-4d11-0410-bbf8-ca57d06f2519>
Sun, 26 Nov 2006 11:18:38 +0000 (11:18 +0000)
remote desktop. Palette is not supported yet.

git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@2133 3789f03b-4d11-0410-bbf8-ca57d06f2519

common/rfb/ScaledPixelBuffer.cxx
win/rfb_win32/ScaledDIBSectionBuffer.cxx

index 2bfb4e870b5ff37ffb1909e39d3182ce5f79b19a..c38a2543bb698147d0b2847255b87f37041c27a9 100644 (file)
@@ -111,21 +111,22 @@ inline U32 ScaledPixelBuffer::getSourcePixel(int x, int y) {
 
 void ScaledPixelBuffer::scaleRect(const Rect& rect) {
   Rect changed_rect;
-  U8 *ptr;
-  U32 *px, *psrc_data = (U32*)(*src_data);
+  U8 *ptr, *pxs, *px;
   float rx, gx, bx, red, green, blue, *xweight, *yweight, xWeight, yWeight;
   int r, g, b, xwi, ywi;
 
   // Calculate the changed pixel rect in the scaled image
   changed_rect = calculateScaleBoundary(rect);
 
+  int bytesPerPixel = pf.bpp / 8;
+
   for (int y = changed_rect.tl.y; y < changed_rect.br.y; y++) {
     ptr = &(*scaled_data)[(changed_rect.tl.x + y*scaled_width) * 4];
     yweight = xWeightTabs[y].weight;
 
     for (int x = changed_rect.tl.x; x < changed_rect.br.x; x++) {
       ywi = 0; red = 0; green = 0; blue = 0;
-      px = &psrc_data[xWeightTabs[x].i0 + yWeightTabs[y].i0*src_width];
+      pxs = &(*src_data)[(xWeightTabs[x].i0 + yWeightTabs[y].i0*src_width) * bytesPerPixel];
       xweight = xWeightTabs[x].weight;
     
       // Calculate the scaled pixel value at (x, y) coordinates by
@@ -135,19 +136,19 @@ void ScaledPixelBuffer::scaleRect(const Rect& rect) {
       // [(xWeight.i0,yWeight.i1-1)..(xWeight.i1-1,yWeight.i1-1)],
       // where [i0, i1) is the scaled filter interval.
       for (int ys = yWeightTabs[y].i0; ys < yWeightTabs[y].i1; ys++) {
-        xwi = 0; rx = 0; gx = 0; bx = 0;
+        xwi = 0; rx = 0; gx = 0; bx = 0; px = pxs;
         for (int xs = xWeightTabs[x].i0; xs < xWeightTabs[x].i1; xs++) {
-          rgbFromPixel(px[xwi], r, g, b);
+          rgbFromPixel(*(U32*)(px), r, g, b);
           xWeight = xweight[xwi++];
           rx += r * xWeight;
           gx += g * xWeight;
           bx += b * xWeight;
+          px += bytesPerPixel;
         }
         yWeight = yweight[ywi++];
         red += rx * yWeight;
         green += gx * yWeight;
         blue += bx * yWeight;
-        px += src_width;
       }
       *ptr++ = U8(blue);
       *ptr++ = U8(green);
index 63e3082c865b682dda5333f34faecc88dcd8261c..aa52e07875891b95d59ca5f4be55685782c6a7b0 100644 (file)
@@ -59,7 +59,7 @@ void ScaledDIBSectionBuffer::setScaleRatio(double scale_ratio_) {
 void ScaledDIBSectionBuffer::setPF(const PixelFormat &pf_) {
   if (memcmp(&(ScaledPixelBuffer::pf), &pf_, sizeof(pf_)) == 0) return;
 
-  if (pf_.depth != 24) throw rfb::UnsupportedPixelFormatException();
+  if (!pf_.trueColour) throw rfb::UnsupportedPixelFormatException();
 
   pf = pf_;
   if (scaling) {