1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_vcl.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include <unistd.h> 32*cdf0e10cSrcweir #include <cstdio> 33*cdf0e10cSrcweir #include <cstring> 34*cdf0e10cSrcweir 35*cdf0e10cSrcweir #include <bmp.hxx> 36*cdf0e10cSrcweir 37*cdf0e10cSrcweir #include <X11_selection.hxx> 38*cdf0e10cSrcweir 39*cdf0e10cSrcweir using namespace x11; 40*cdf0e10cSrcweir using namespace com::sun::star::uno; 41*cdf0e10cSrcweir using namespace com::sun::star::script; 42*cdf0e10cSrcweir using namespace com::sun::star::awt; 43*cdf0e10cSrcweir using namespace rtl; 44*cdf0e10cSrcweir 45*cdf0e10cSrcweir /* 46*cdf0e10cSrcweir * helper functions 47*cdf0e10cSrcweir */ 48*cdf0e10cSrcweir 49*cdf0e10cSrcweir inline void writeLE( sal_uInt16 nNumber, sal_uInt8* pBuffer ) 50*cdf0e10cSrcweir { 51*cdf0e10cSrcweir pBuffer[ 0 ] = (nNumber & 0xff); 52*cdf0e10cSrcweir pBuffer[ 1 ] = ((nNumber>>8)&0xff); 53*cdf0e10cSrcweir } 54*cdf0e10cSrcweir 55*cdf0e10cSrcweir inline void writeLE( sal_uInt32 nNumber, sal_uInt8* pBuffer ) 56*cdf0e10cSrcweir { 57*cdf0e10cSrcweir pBuffer[ 0 ] = (nNumber & 0xff); 58*cdf0e10cSrcweir pBuffer[ 1 ] = ((nNumber>>8)&0xff); 59*cdf0e10cSrcweir pBuffer[ 2 ] = ((nNumber>>16)&0xff); 60*cdf0e10cSrcweir pBuffer[ 3 ] = ((nNumber>>24)&0xff); 61*cdf0e10cSrcweir } 62*cdf0e10cSrcweir 63*cdf0e10cSrcweir inline sal_uInt16 readLE16( const sal_uInt8* pBuffer ) 64*cdf0e10cSrcweir { 65*cdf0e10cSrcweir return (((sal_uInt16)pBuffer[1]) << 8 ) | pBuffer[0]; 66*cdf0e10cSrcweir } 67*cdf0e10cSrcweir 68*cdf0e10cSrcweir inline sal_uInt16 readLE32( const sal_uInt8* pBuffer ) 69*cdf0e10cSrcweir { 70*cdf0e10cSrcweir return 71*cdf0e10cSrcweir (((sal_uInt32)pBuffer[3]) << 24 ) | 72*cdf0e10cSrcweir (((sal_uInt32)pBuffer[2]) << 16 ) | 73*cdf0e10cSrcweir (((sal_uInt32)pBuffer[1]) << 8 ) | 74*cdf0e10cSrcweir pBuffer[0]; 75*cdf0e10cSrcweir } 76*cdf0e10cSrcweir 77*cdf0e10cSrcweir 78*cdf0e10cSrcweir /* 79*cdf0e10cSrcweir * BmpTransporter 80*cdf0e10cSrcweir */ 81*cdf0e10cSrcweir 82*cdf0e10cSrcweir BmpTransporter::BmpTransporter( const Sequence<sal_Int8>& rBmp ) : 83*cdf0e10cSrcweir m_aBM( rBmp ) 84*cdf0e10cSrcweir { 85*cdf0e10cSrcweir const sal_uInt8* pData = (const sal_uInt8*)rBmp.getConstArray(); 86*cdf0e10cSrcweir 87*cdf0e10cSrcweir if( pData[0] == 'B' || pData[1] == 'M' ) 88*cdf0e10cSrcweir { 89*cdf0e10cSrcweir pData = pData+14; 90*cdf0e10cSrcweir m_aSize.Width = readLE32( pData+4 ); 91*cdf0e10cSrcweir m_aSize.Height = readLE32( pData+8 ); 92*cdf0e10cSrcweir } 93*cdf0e10cSrcweir else 94*cdf0e10cSrcweir m_aSize.Width = m_aSize.Height = 0; 95*cdf0e10cSrcweir } 96*cdf0e10cSrcweir 97*cdf0e10cSrcweir BmpTransporter::~BmpTransporter() 98*cdf0e10cSrcweir { 99*cdf0e10cSrcweir } 100*cdf0e10cSrcweir 101*cdf0e10cSrcweir com::sun::star::awt::Size SAL_CALL BmpTransporter::getSize() throw() 102*cdf0e10cSrcweir { 103*cdf0e10cSrcweir return m_aSize; 104*cdf0e10cSrcweir } 105*cdf0e10cSrcweir 106*cdf0e10cSrcweir Sequence< sal_Int8 > SAL_CALL BmpTransporter::getDIB() throw() 107*cdf0e10cSrcweir { 108*cdf0e10cSrcweir return m_aBM; 109*cdf0e10cSrcweir } 110*cdf0e10cSrcweir 111*cdf0e10cSrcweir Sequence< sal_Int8 > SAL_CALL BmpTransporter::getMaskDIB() throw() 112*cdf0e10cSrcweir { 113*cdf0e10cSrcweir return Sequence< sal_Int8 >(); 114*cdf0e10cSrcweir } 115*cdf0e10cSrcweir 116*cdf0e10cSrcweir /* 117*cdf0e10cSrcweir * scanline helpers 118*cdf0e10cSrcweir */ 119*cdf0e10cSrcweir 120*cdf0e10cSrcweir inline void X11_writeScanlinePixel( unsigned long nColor, sal_uInt8* pScanline, int depth, int x ) 121*cdf0e10cSrcweir { 122*cdf0e10cSrcweir switch( depth ) 123*cdf0e10cSrcweir { 124*cdf0e10cSrcweir case 1: 125*cdf0e10cSrcweir pScanline[ x/8 ] &= ~(1 << (x&7)); 126*cdf0e10cSrcweir pScanline[ x/8 ] |= ((nColor & 1) << (x&7)); 127*cdf0e10cSrcweir break; 128*cdf0e10cSrcweir case 4: 129*cdf0e10cSrcweir pScanline[ x/2 ] &= ((x&1) ? 0x0f : 0xf0); 130*cdf0e10cSrcweir pScanline[ x/2 ] |= ((x&1) ? (nColor & 0x0f) : ((nColor & 0x0f) << 4)); 131*cdf0e10cSrcweir break; 132*cdf0e10cSrcweir default: 133*cdf0e10cSrcweir case 8: 134*cdf0e10cSrcweir pScanline[ x ] = (nColor & 0xff); 135*cdf0e10cSrcweir break; 136*cdf0e10cSrcweir } 137*cdf0e10cSrcweir } 138*cdf0e10cSrcweir 139*cdf0e10cSrcweir static sal_uInt8* X11_getPaletteBmpFromImage( 140*cdf0e10cSrcweir Display* pDisplay, 141*cdf0e10cSrcweir XImage* pImage, 142*cdf0e10cSrcweir Colormap aColormap, 143*cdf0e10cSrcweir sal_Int32& rOutSize 144*cdf0e10cSrcweir ) 145*cdf0e10cSrcweir { 146*cdf0e10cSrcweir sal_uInt32 nColors = 0; 147*cdf0e10cSrcweir 148*cdf0e10cSrcweir rOutSize = 0; 149*cdf0e10cSrcweir 150*cdf0e10cSrcweir sal_uInt8* pBuffer = 0; 151*cdf0e10cSrcweir sal_uInt32 nHeaderSize, nScanlineSize; 152*cdf0e10cSrcweir sal_uInt16 nBitCount; 153*cdf0e10cSrcweir // determine header and scanline size 154*cdf0e10cSrcweir switch( pImage->depth ) 155*cdf0e10cSrcweir { 156*cdf0e10cSrcweir case 1: 157*cdf0e10cSrcweir nHeaderSize = 64; 158*cdf0e10cSrcweir nScanlineSize = (pImage->width+31)/32; 159*cdf0e10cSrcweir nBitCount = 1; 160*cdf0e10cSrcweir break; 161*cdf0e10cSrcweir case 4: 162*cdf0e10cSrcweir nHeaderSize = 72; 163*cdf0e10cSrcweir nScanlineSize = (pImage->width+1)/2; 164*cdf0e10cSrcweir nBitCount = 4; 165*cdf0e10cSrcweir break; 166*cdf0e10cSrcweir default: 167*cdf0e10cSrcweir case 8: 168*cdf0e10cSrcweir nHeaderSize = 1084; 169*cdf0e10cSrcweir nScanlineSize = pImage->width; 170*cdf0e10cSrcweir nBitCount = 8; 171*cdf0e10cSrcweir break; 172*cdf0e10cSrcweir } 173*cdf0e10cSrcweir // adjust scan lines to begin on %4 boundaries 174*cdf0e10cSrcweir if( nScanlineSize & 3 ) 175*cdf0e10cSrcweir { 176*cdf0e10cSrcweir nScanlineSize &= 0xfffffffc; 177*cdf0e10cSrcweir nScanlineSize += 4; 178*cdf0e10cSrcweir } 179*cdf0e10cSrcweir 180*cdf0e10cSrcweir // allocate buffer to hold header and scanlines, initialize to zero 181*cdf0e10cSrcweir rOutSize = nHeaderSize + nScanlineSize*pImage->height; 182*cdf0e10cSrcweir pBuffer = (sal_uInt8*)rtl_allocateZeroMemory( rOutSize ); 183*cdf0e10cSrcweir for( int y = 0; y < pImage->height; y++ ) 184*cdf0e10cSrcweir { 185*cdf0e10cSrcweir sal_uInt8* pScanline = pBuffer + nHeaderSize + (pImage->height-1-y)*nScanlineSize; 186*cdf0e10cSrcweir for( int x = 0; x < pImage->width; x++ ) 187*cdf0e10cSrcweir { 188*cdf0e10cSrcweir unsigned long nPixel = XGetPixel( pImage, x, y ); 189*cdf0e10cSrcweir if( nPixel >= nColors ) 190*cdf0e10cSrcweir nColors = nPixel+1; 191*cdf0e10cSrcweir X11_writeScanlinePixel( nPixel, pScanline, pImage->depth, x ); 192*cdf0e10cSrcweir } 193*cdf0e10cSrcweir } 194*cdf0e10cSrcweir 195*cdf0e10cSrcweir // fill in header fields 196*cdf0e10cSrcweir pBuffer[ 0 ] = 'B'; 197*cdf0e10cSrcweir pBuffer[ 1 ] = 'M'; 198*cdf0e10cSrcweir 199*cdf0e10cSrcweir writeLE( nHeaderSize, pBuffer+10 ); 200*cdf0e10cSrcweir writeLE( (sal_uInt32)40, pBuffer+14 ); 201*cdf0e10cSrcweir writeLE( (sal_uInt32)pImage->width, pBuffer+18 ); 202*cdf0e10cSrcweir writeLE( (sal_uInt32)pImage->height, pBuffer+22 ); 203*cdf0e10cSrcweir writeLE( (sal_uInt16)1, pBuffer+26 ); 204*cdf0e10cSrcweir writeLE( nBitCount, pBuffer+28 ); 205*cdf0e10cSrcweir writeLE( (sal_uInt32)(DisplayWidth(pDisplay,DefaultScreen(pDisplay))*1000/DisplayWidthMM(pDisplay,DefaultScreen(pDisplay))), pBuffer+38); 206*cdf0e10cSrcweir writeLE( (sal_uInt32)(DisplayHeight(pDisplay,DefaultScreen(pDisplay))*1000/DisplayHeightMM(pDisplay,DefaultScreen(pDisplay))), pBuffer+42); 207*cdf0e10cSrcweir writeLE( nColors, pBuffer+46 ); 208*cdf0e10cSrcweir writeLE( nColors, pBuffer+50 ); 209*cdf0e10cSrcweir 210*cdf0e10cSrcweir XColor aColors[256]; 211*cdf0e10cSrcweir if( nColors > (1U << nBitCount) ) // paranoia 212*cdf0e10cSrcweir nColors = (1U << nBitCount); 213*cdf0e10cSrcweir for( unsigned long nPixel = 0; nPixel < nColors; nPixel++ ) 214*cdf0e10cSrcweir { 215*cdf0e10cSrcweir aColors[nPixel].flags = DoRed | DoGreen | DoBlue; 216*cdf0e10cSrcweir aColors[nPixel].pixel = nPixel; 217*cdf0e10cSrcweir } 218*cdf0e10cSrcweir XQueryColors( pDisplay, aColormap, aColors, nColors ); 219*cdf0e10cSrcweir for( sal_uInt32 i = 0; i < nColors; i++ ) 220*cdf0e10cSrcweir { 221*cdf0e10cSrcweir pBuffer[ 54 + i*4 ] = (sal_uInt8)(aColors[i].blue >> 8); 222*cdf0e10cSrcweir pBuffer[ 55 + i*4 ] = (sal_uInt8)(aColors[i].green >> 8); 223*cdf0e10cSrcweir pBuffer[ 56 + i*4 ] = (sal_uInt8)(aColors[i].red >> 8); 224*cdf0e10cSrcweir } 225*cdf0e10cSrcweir 226*cdf0e10cSrcweir // done 227*cdf0e10cSrcweir 228*cdf0e10cSrcweir return pBuffer; 229*cdf0e10cSrcweir } 230*cdf0e10cSrcweir 231*cdf0e10cSrcweir inline unsigned long doRightShift( unsigned long nValue, int nShift ) 232*cdf0e10cSrcweir { 233*cdf0e10cSrcweir return (nShift > 0) ? (nValue >> nShift) : (nValue << (-nShift)); 234*cdf0e10cSrcweir } 235*cdf0e10cSrcweir 236*cdf0e10cSrcweir inline unsigned long doLeftShift( unsigned long nValue, int nShift ) 237*cdf0e10cSrcweir { 238*cdf0e10cSrcweir return (nShift > 0) ? (nValue << nShift) : (nValue >> (-nShift)); 239*cdf0e10cSrcweir } 240*cdf0e10cSrcweir 241*cdf0e10cSrcweir static void getShift( unsigned long nMask, int& rShift, int& rSigBits, int& rShift2 ) 242*cdf0e10cSrcweir { 243*cdf0e10cSrcweir unsigned long nUseMask = nMask; 244*cdf0e10cSrcweir rShift = 0; 245*cdf0e10cSrcweir while( nMask & 0xffffff00 ) 246*cdf0e10cSrcweir { 247*cdf0e10cSrcweir rShift++; 248*cdf0e10cSrcweir nMask >>= 1; 249*cdf0e10cSrcweir } 250*cdf0e10cSrcweir if( rShift == 0 ) 251*cdf0e10cSrcweir while( ! (nMask & 0x00000080) ) 252*cdf0e10cSrcweir { 253*cdf0e10cSrcweir rShift--; 254*cdf0e10cSrcweir nMask <<= 1; 255*cdf0e10cSrcweir } 256*cdf0e10cSrcweir 257*cdf0e10cSrcweir int nRotate = sizeof(unsigned long)*8 - rShift; 258*cdf0e10cSrcweir rSigBits = 0; 259*cdf0e10cSrcweir nMask = doRightShift( nUseMask, rShift) ; 260*cdf0e10cSrcweir while( nRotate-- ) 261*cdf0e10cSrcweir { 262*cdf0e10cSrcweir if( nMask & 1 ) 263*cdf0e10cSrcweir rSigBits++; 264*cdf0e10cSrcweir nMask >>= 1; 265*cdf0e10cSrcweir } 266*cdf0e10cSrcweir 267*cdf0e10cSrcweir rShift2 = 0; 268*cdf0e10cSrcweir if( rSigBits < 8 ) 269*cdf0e10cSrcweir rShift2 = 8-rSigBits; 270*cdf0e10cSrcweir } 271*cdf0e10cSrcweir 272*cdf0e10cSrcweir static sal_uInt8* X11_getTCBmpFromImage( 273*cdf0e10cSrcweir Display* pDisplay, 274*cdf0e10cSrcweir XImage* pImage, 275*cdf0e10cSrcweir sal_Int32& rOutSize, 276*cdf0e10cSrcweir int nScreenNo 277*cdf0e10cSrcweir ) 278*cdf0e10cSrcweir { 279*cdf0e10cSrcweir // get masks from visual info (guesswork) 280*cdf0e10cSrcweir XVisualInfo aVInfo; 281*cdf0e10cSrcweir if( ! XMatchVisualInfo( pDisplay, nScreenNo, pImage->depth, TrueColor, &aVInfo ) ) 282*cdf0e10cSrcweir return NULL; 283*cdf0e10cSrcweir 284*cdf0e10cSrcweir rOutSize = 0; 285*cdf0e10cSrcweir 286*cdf0e10cSrcweir sal_uInt8* pBuffer = 0; 287*cdf0e10cSrcweir sal_uInt32 nHeaderSize = 60; 288*cdf0e10cSrcweir sal_uInt32 nScanlineSize = pImage->width*3; 289*cdf0e10cSrcweir 290*cdf0e10cSrcweir // adjust scan lines to begin on %4 boundaries 291*cdf0e10cSrcweir if( nScanlineSize & 3 ) 292*cdf0e10cSrcweir { 293*cdf0e10cSrcweir nScanlineSize &= 0xfffffffc; 294*cdf0e10cSrcweir nScanlineSize += 4; 295*cdf0e10cSrcweir } 296*cdf0e10cSrcweir int nRedShift, nRedSig, nRedShift2 = 0; 297*cdf0e10cSrcweir getShift( aVInfo.red_mask, nRedShift, nRedSig, nRedShift2 ); 298*cdf0e10cSrcweir int nGreenShift, nGreenSig, nGreenShift2 = 0; 299*cdf0e10cSrcweir getShift( aVInfo.green_mask, nGreenShift, nGreenSig, nGreenShift2 ); 300*cdf0e10cSrcweir int nBlueShift, nBlueSig, nBlueShift2 = 0; 301*cdf0e10cSrcweir getShift( aVInfo.blue_mask, nBlueShift, nBlueSig, nBlueShift2 ); 302*cdf0e10cSrcweir 303*cdf0e10cSrcweir // allocate buffer to hold header and scanlines, initialize to zero 304*cdf0e10cSrcweir rOutSize = nHeaderSize + nScanlineSize*pImage->height; 305*cdf0e10cSrcweir pBuffer = (sal_uInt8*)rtl_allocateZeroMemory( rOutSize ); 306*cdf0e10cSrcweir for( int y = 0; y < pImage->height; y++ ) 307*cdf0e10cSrcweir { 308*cdf0e10cSrcweir sal_uInt8* pScanline = pBuffer + nHeaderSize + (pImage->height-1-y)*nScanlineSize; 309*cdf0e10cSrcweir for( int x = 0; x < pImage->width; x++ ) 310*cdf0e10cSrcweir { 311*cdf0e10cSrcweir unsigned long nPixel = XGetPixel( pImage, x, y ); 312*cdf0e10cSrcweir 313*cdf0e10cSrcweir sal_uInt8 nValue = (sal_uInt8)doRightShift( nPixel&aVInfo.blue_mask, nBlueShift); 314*cdf0e10cSrcweir if( nBlueShift2 ) 315*cdf0e10cSrcweir nValue |= (nValue >> nBlueShift2 ); 316*cdf0e10cSrcweir *pScanline++ = nValue; 317*cdf0e10cSrcweir 318*cdf0e10cSrcweir nValue = (sal_uInt8)doRightShift( nPixel&aVInfo.green_mask, nGreenShift); 319*cdf0e10cSrcweir if( nGreenShift2 ) 320*cdf0e10cSrcweir nValue |= (nValue >> nGreenShift2 ); 321*cdf0e10cSrcweir *pScanline++ = nValue; 322*cdf0e10cSrcweir 323*cdf0e10cSrcweir nValue = (sal_uInt8)doRightShift( nPixel&aVInfo.red_mask, nRedShift); 324*cdf0e10cSrcweir if( nRedShift2 ) 325*cdf0e10cSrcweir nValue |= (nValue >> nRedShift2 ); 326*cdf0e10cSrcweir *pScanline++ = nValue; 327*cdf0e10cSrcweir } 328*cdf0e10cSrcweir } 329*cdf0e10cSrcweir 330*cdf0e10cSrcweir // fill in header fields 331*cdf0e10cSrcweir pBuffer[ 0 ] = 'B'; 332*cdf0e10cSrcweir pBuffer[ 1 ] = 'M'; 333*cdf0e10cSrcweir 334*cdf0e10cSrcweir writeLE( nHeaderSize, pBuffer+10 ); 335*cdf0e10cSrcweir writeLE( (sal_uInt32)40, pBuffer+14 ); 336*cdf0e10cSrcweir writeLE( (sal_uInt32)pImage->width, pBuffer+18 ); 337*cdf0e10cSrcweir writeLE( (sal_uInt32)pImage->height, pBuffer+22 ); 338*cdf0e10cSrcweir writeLE( (sal_uInt16)1, pBuffer+26 ); 339*cdf0e10cSrcweir writeLE( (sal_uInt16)24, pBuffer+28 ); 340*cdf0e10cSrcweir writeLE( (sal_uInt32)(DisplayWidth(pDisplay,DefaultScreen(pDisplay))*1000/DisplayWidthMM(pDisplay,DefaultScreen(pDisplay))), pBuffer+38); 341*cdf0e10cSrcweir writeLE( (sal_uInt32)(DisplayHeight(pDisplay,DefaultScreen(pDisplay))*1000/DisplayHeightMM(pDisplay,DefaultScreen(pDisplay))), pBuffer+42); 342*cdf0e10cSrcweir 343*cdf0e10cSrcweir // done 344*cdf0e10cSrcweir 345*cdf0e10cSrcweir return pBuffer; 346*cdf0e10cSrcweir } 347*cdf0e10cSrcweir 348*cdf0e10cSrcweir sal_uInt8* x11::X11_getBmpFromPixmap( 349*cdf0e10cSrcweir Display* pDisplay, 350*cdf0e10cSrcweir Drawable aDrawable, 351*cdf0e10cSrcweir Colormap aColormap, 352*cdf0e10cSrcweir sal_Int32& rOutSize 353*cdf0e10cSrcweir ) 354*cdf0e10cSrcweir { 355*cdf0e10cSrcweir // get geometry of drawable 356*cdf0e10cSrcweir XLIB_Window aRoot; 357*cdf0e10cSrcweir int x,y; 358*cdf0e10cSrcweir unsigned int w, h, bw, d; 359*cdf0e10cSrcweir XGetGeometry( pDisplay, aDrawable, &aRoot, &x, &y, &w, &h, &bw, &d ); 360*cdf0e10cSrcweir 361*cdf0e10cSrcweir // find which screen we are on 362*cdf0e10cSrcweir int nScreenNo = ScreenCount( pDisplay ); 363*cdf0e10cSrcweir while( nScreenNo-- ) 364*cdf0e10cSrcweir { 365*cdf0e10cSrcweir if( RootWindow( pDisplay, nScreenNo ) == aRoot ) 366*cdf0e10cSrcweir break; 367*cdf0e10cSrcweir } 368*cdf0e10cSrcweir if( nScreenNo < 0 ) 369*cdf0e10cSrcweir return NULL; 370*cdf0e10cSrcweir 371*cdf0e10cSrcweir if( aColormap == None ) 372*cdf0e10cSrcweir aColormap = DefaultColormap( pDisplay, nScreenNo ); 373*cdf0e10cSrcweir 374*cdf0e10cSrcweir // get the image 375*cdf0e10cSrcweir XImage* pImage = XGetImage( pDisplay, aDrawable, 0, 0, w, h, AllPlanes, ZPixmap ); 376*cdf0e10cSrcweir if( ! pImage ) 377*cdf0e10cSrcweir return NULL; 378*cdf0e10cSrcweir 379*cdf0e10cSrcweir sal_uInt8* pBmp = d <= 8 ? 380*cdf0e10cSrcweir X11_getPaletteBmpFromImage( pDisplay, pImage, aColormap, rOutSize ) : 381*cdf0e10cSrcweir X11_getTCBmpFromImage( pDisplay, pImage, rOutSize, nScreenNo ); 382*cdf0e10cSrcweir XDestroyImage( pImage ); 383*cdf0e10cSrcweir 384*cdf0e10cSrcweir return pBmp; 385*cdf0e10cSrcweir } 386*cdf0e10cSrcweir 387*cdf0e10cSrcweir void x11::X11_freeBmp( sal_uInt8* pBmp ) 388*cdf0e10cSrcweir { 389*cdf0e10cSrcweir rtl_freeMemory( pBmp ); 390*cdf0e10cSrcweir } 391*cdf0e10cSrcweir 392*cdf0e10cSrcweir /* 393*cdf0e10cSrcweir * PixmapHolder 394*cdf0e10cSrcweir */ 395*cdf0e10cSrcweir 396*cdf0e10cSrcweir PixmapHolder::PixmapHolder( Display* pDisplay ) : 397*cdf0e10cSrcweir m_pDisplay( pDisplay ), 398*cdf0e10cSrcweir m_aColormap( None ), 399*cdf0e10cSrcweir m_aPixmap( None ), 400*cdf0e10cSrcweir m_aBitmap( None ) 401*cdf0e10cSrcweir { 402*cdf0e10cSrcweir /* try to get a 24 bit true color visual, if that fails, 403*cdf0e10cSrcweir * revert to default visual 404*cdf0e10cSrcweir */ 405*cdf0e10cSrcweir if( ! XMatchVisualInfo( m_pDisplay, DefaultScreen( m_pDisplay ), 24, TrueColor, &m_aInfo ) ) 406*cdf0e10cSrcweir { 407*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1 408*cdf0e10cSrcweir fprintf( stderr, "PixmapHolder reverting to default visual\n" ); 409*cdf0e10cSrcweir #endif 410*cdf0e10cSrcweir Visual* pVisual = DefaultVisual( m_pDisplay, DefaultScreen( m_pDisplay ) ); 411*cdf0e10cSrcweir m_aInfo.screen = DefaultScreen( m_pDisplay ); 412*cdf0e10cSrcweir m_aInfo.visual = pVisual; 413*cdf0e10cSrcweir m_aInfo.visualid = pVisual->visualid; 414*cdf0e10cSrcweir m_aInfo.c_class = pVisual->c_class; 415*cdf0e10cSrcweir m_aInfo.red_mask = pVisual->red_mask; 416*cdf0e10cSrcweir m_aInfo.green_mask = pVisual->green_mask; 417*cdf0e10cSrcweir m_aInfo.blue_mask = pVisual->blue_mask; 418*cdf0e10cSrcweir m_aInfo.depth = DefaultDepth( m_pDisplay, m_aInfo.screen ); 419*cdf0e10cSrcweir } 420*cdf0e10cSrcweir m_aColormap = DefaultColormap( m_pDisplay, m_aInfo.screen ); 421*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1 422*cdf0e10cSrcweir static const char* pClasses[] = 423*cdf0e10cSrcweir { "StaticGray", "GrayScale", "StaticColor", "PseudoColor", "TrueColor", "DirectColor" }; 424*cdf0e10cSrcweir fprintf( stderr, "PixmapHolder visual: id = 0x%lx, class = %s (%d), depth=%d; color map = 0x%lx\n", 425*cdf0e10cSrcweir m_aInfo.visualid, 426*cdf0e10cSrcweir (m_aInfo.c_class >= 0 && unsigned(m_aInfo.c_class) < sizeof(pClasses)/sizeof(pClasses[0])) ? pClasses[m_aInfo.c_class] : "<unknown>", 427*cdf0e10cSrcweir m_aInfo.c_class, 428*cdf0e10cSrcweir m_aInfo.depth, 429*cdf0e10cSrcweir m_aColormap ); 430*cdf0e10cSrcweir #endif 431*cdf0e10cSrcweir if( m_aInfo.c_class == TrueColor ) 432*cdf0e10cSrcweir { 433*cdf0e10cSrcweir int nRedSig, nGreenSig, nBlueSig; 434*cdf0e10cSrcweir m_nRedShift = m_nRedShift2 = 0; 435*cdf0e10cSrcweir getShift( m_aInfo.red_mask, m_nRedShift, nRedSig, m_nRedShift2 ); 436*cdf0e10cSrcweir m_nGreenShift = m_nGreenShift2 = 0; 437*cdf0e10cSrcweir getShift( m_aInfo.green_mask, m_nGreenShift, nGreenSig, m_nGreenShift2 ); 438*cdf0e10cSrcweir m_nBlueShift = m_nBlueShift2 = 0; 439*cdf0e10cSrcweir getShift( m_aInfo.blue_mask, m_nBlueShift, nBlueSig, m_nBlueShift2 ); 440*cdf0e10cSrcweir 441*cdf0e10cSrcweir m_nBlueShift2Mask = m_nBlueShift2 ? ~((unsigned long)((1<<m_nBlueShift2)-1)) : ~0L; 442*cdf0e10cSrcweir m_nGreenShift2Mask = m_nGreenShift2 ? ~((unsigned long)((1<<m_nGreenShift2)-1)) : ~0L; 443*cdf0e10cSrcweir m_nRedShift2Mask = m_nRedShift2 ? ~((unsigned long)((1<<m_nRedShift2)-1)) : ~0L; 444*cdf0e10cSrcweir } 445*cdf0e10cSrcweir } 446*cdf0e10cSrcweir 447*cdf0e10cSrcweir PixmapHolder::~PixmapHolder() 448*cdf0e10cSrcweir { 449*cdf0e10cSrcweir if( m_aPixmap != None ) 450*cdf0e10cSrcweir XFreePixmap( m_pDisplay, m_aPixmap ); 451*cdf0e10cSrcweir if( m_aBitmap != None ) 452*cdf0e10cSrcweir XFreePixmap( m_pDisplay, m_aBitmap ); 453*cdf0e10cSrcweir } 454*cdf0e10cSrcweir 455*cdf0e10cSrcweir unsigned long PixmapHolder::getTCPixel( sal_uInt8 r, sal_uInt8 g, sal_uInt8 b ) const 456*cdf0e10cSrcweir { 457*cdf0e10cSrcweir unsigned long nPixel = 0; 458*cdf0e10cSrcweir unsigned long nValue = (unsigned long)b; 459*cdf0e10cSrcweir nValue &= m_nBlueShift2Mask; 460*cdf0e10cSrcweir nPixel |= doLeftShift( nValue, m_nBlueShift ); 461*cdf0e10cSrcweir 462*cdf0e10cSrcweir nValue = (unsigned long)g; 463*cdf0e10cSrcweir nValue &= m_nGreenShift2Mask; 464*cdf0e10cSrcweir nPixel |= doLeftShift( nValue, m_nGreenShift ); 465*cdf0e10cSrcweir 466*cdf0e10cSrcweir nValue = (unsigned long)r; 467*cdf0e10cSrcweir nValue &= m_nRedShift2Mask; 468*cdf0e10cSrcweir nPixel |= doLeftShift( nValue, m_nRedShift ); 469*cdf0e10cSrcweir 470*cdf0e10cSrcweir return nPixel; 471*cdf0e10cSrcweir } 472*cdf0e10cSrcweir 473*cdf0e10cSrcweir void PixmapHolder::setBitmapDataPalette( const sal_uInt8* pData, XImage* pImage ) 474*cdf0e10cSrcweir { 475*cdf0e10cSrcweir // setup palette 476*cdf0e10cSrcweir XColor aPalette[256]; 477*cdf0e10cSrcweir 478*cdf0e10cSrcweir sal_uInt32 nColors = readLE32( pData+32 ); 479*cdf0e10cSrcweir sal_uInt32 nWidth = readLE32( pData+4 ); 480*cdf0e10cSrcweir sal_uInt32 nHeight = readLE32( pData+8 ); 481*cdf0e10cSrcweir sal_uInt16 nDepth = readLE16( pData+14 ); 482*cdf0e10cSrcweir 483*cdf0e10cSrcweir for( sal_uInt16 i = 0 ; i < nColors; i++ ) 484*cdf0e10cSrcweir { 485*cdf0e10cSrcweir if( m_aInfo.c_class != TrueColor ) 486*cdf0e10cSrcweir { 487*cdf0e10cSrcweir aPalette[i].red = ((unsigned short)pData[42 + i*4]) << 8 | ((unsigned short)pData[42 + i*4]); 488*cdf0e10cSrcweir aPalette[i].green = ((unsigned short)pData[41 + i*4]) << 8 | ((unsigned short)pData[41 + i*4]); 489*cdf0e10cSrcweir aPalette[i].blue = ((unsigned short)pData[40 + i*4]) << 8 | ((unsigned short)pData[40 + i*4]); 490*cdf0e10cSrcweir XAllocColor( m_pDisplay, m_aColormap, aPalette+i ); 491*cdf0e10cSrcweir } 492*cdf0e10cSrcweir else 493*cdf0e10cSrcweir aPalette[i].pixel = getTCPixel( pData[42+i*4], pData[41+i*4], pData[40+i*4] ); 494*cdf0e10cSrcweir } 495*cdf0e10cSrcweir const sal_uInt8* pBMData = pData + readLE32( pData ) + 4*nColors; 496*cdf0e10cSrcweir 497*cdf0e10cSrcweir sal_uInt32 nScanlineSize = 0; 498*cdf0e10cSrcweir switch( nDepth ) 499*cdf0e10cSrcweir { 500*cdf0e10cSrcweir case 1: 501*cdf0e10cSrcweir nScanlineSize = (nWidth+31)/32; 502*cdf0e10cSrcweir break; 503*cdf0e10cSrcweir case 4: 504*cdf0e10cSrcweir nScanlineSize = (nWidth+1)/2; 505*cdf0e10cSrcweir break; 506*cdf0e10cSrcweir case 8: 507*cdf0e10cSrcweir nScanlineSize = nWidth; 508*cdf0e10cSrcweir break; 509*cdf0e10cSrcweir } 510*cdf0e10cSrcweir // adjust scan lines to begin on %4 boundaries 511*cdf0e10cSrcweir if( nScanlineSize & 3 ) 512*cdf0e10cSrcweir { 513*cdf0e10cSrcweir nScanlineSize &= 0xfffffffc; 514*cdf0e10cSrcweir nScanlineSize += 4; 515*cdf0e10cSrcweir } 516*cdf0e10cSrcweir 517*cdf0e10cSrcweir // allocate buffer to hold header and scanlines, initialize to zero 518*cdf0e10cSrcweir for( unsigned int y = 0; y < nHeight; y++ ) 519*cdf0e10cSrcweir { 520*cdf0e10cSrcweir const sal_uInt8* pScanline = pBMData + (nHeight-1-y)*nScanlineSize; 521*cdf0e10cSrcweir for( unsigned int x = 0; x < nWidth; x++ ) 522*cdf0e10cSrcweir { 523*cdf0e10cSrcweir int nCol = 0; 524*cdf0e10cSrcweir switch( nDepth ) 525*cdf0e10cSrcweir { 526*cdf0e10cSrcweir case 1: nCol = (pScanline[ x/8 ] & (0x80 >> (x&7))) != 0 ? 0 : 1; break; 527*cdf0e10cSrcweir case 4: 528*cdf0e10cSrcweir if( x & 1 ) 529*cdf0e10cSrcweir nCol = (int)(pScanline[ x/2 ] >> 4); 530*cdf0e10cSrcweir else 531*cdf0e10cSrcweir nCol = (int)(pScanline[ x/2 ] & 0x0f); 532*cdf0e10cSrcweir break; 533*cdf0e10cSrcweir case 8: nCol = (int)pScanline[x]; 534*cdf0e10cSrcweir } 535*cdf0e10cSrcweir XPutPixel( pImage, x, y, aPalette[nCol].pixel ); 536*cdf0e10cSrcweir } 537*cdf0e10cSrcweir } 538*cdf0e10cSrcweir } 539*cdf0e10cSrcweir 540*cdf0e10cSrcweir void PixmapHolder::setBitmapDataTCDither( const sal_uInt8* pData, XImage* pImage ) 541*cdf0e10cSrcweir { 542*cdf0e10cSrcweir XColor aPalette[216]; 543*cdf0e10cSrcweir 544*cdf0e10cSrcweir int nNonAllocs = 0; 545*cdf0e10cSrcweir 546*cdf0e10cSrcweir for( int r = 0; r < 6; r++ ) 547*cdf0e10cSrcweir { 548*cdf0e10cSrcweir for( int g = 0; g < 6; g++ ) 549*cdf0e10cSrcweir { 550*cdf0e10cSrcweir for( int b = 0; b < 6; b++ ) 551*cdf0e10cSrcweir { 552*cdf0e10cSrcweir int i = r*36+g*6+b; 553*cdf0e10cSrcweir aPalette[i].red = r == 5 ? 0xffff : r*10922; 554*cdf0e10cSrcweir aPalette[i].green = g == 5 ? 0xffff : g*10922; 555*cdf0e10cSrcweir aPalette[i].blue = b == 5 ? 0xffff : b*10922; 556*cdf0e10cSrcweir aPalette[i].pixel = 0; 557*cdf0e10cSrcweir if( ! XAllocColor( m_pDisplay, m_aColormap, aPalette+i ) ) 558*cdf0e10cSrcweir nNonAllocs++; 559*cdf0e10cSrcweir } 560*cdf0e10cSrcweir } 561*cdf0e10cSrcweir } 562*cdf0e10cSrcweir 563*cdf0e10cSrcweir if( nNonAllocs ) 564*cdf0e10cSrcweir { 565*cdf0e10cSrcweir XColor aRealPalette[256]; 566*cdf0e10cSrcweir int nColors = 1 << m_aInfo.depth; 567*cdf0e10cSrcweir int i; 568*cdf0e10cSrcweir for( i = 0; i < nColors; i++ ) 569*cdf0e10cSrcweir aRealPalette[i].pixel = (unsigned long)i; 570*cdf0e10cSrcweir XQueryColors( m_pDisplay, m_aColormap, aRealPalette, nColors ); 571*cdf0e10cSrcweir for( i = 0; i < nColors; i++ ) 572*cdf0e10cSrcweir { 573*cdf0e10cSrcweir sal_uInt8 nIndex = 574*cdf0e10cSrcweir 36*(sal_uInt8)(aRealPalette[i].red/10923) + 575*cdf0e10cSrcweir 6*(sal_uInt8)(aRealPalette[i].green/10923) + 576*cdf0e10cSrcweir (sal_uInt8)(aRealPalette[i].blue/10923); 577*cdf0e10cSrcweir if( aPalette[nIndex].pixel == 0 ) 578*cdf0e10cSrcweir aPalette[nIndex] = aRealPalette[i]; 579*cdf0e10cSrcweir } 580*cdf0e10cSrcweir } 581*cdf0e10cSrcweir 582*cdf0e10cSrcweir sal_uInt32 nWidth = readLE32( pData+4 ); 583*cdf0e10cSrcweir sal_uInt32 nHeight = readLE32( pData+8 ); 584*cdf0e10cSrcweir 585*cdf0e10cSrcweir const sal_uInt8* pBMData = pData + readLE32( pData ); 586*cdf0e10cSrcweir sal_uInt32 nScanlineSize = nWidth*3; 587*cdf0e10cSrcweir // adjust scan lines to begin on %4 boundaries 588*cdf0e10cSrcweir if( nScanlineSize & 3 ) 589*cdf0e10cSrcweir { 590*cdf0e10cSrcweir nScanlineSize &= 0xfffffffc; 591*cdf0e10cSrcweir nScanlineSize += 4; 592*cdf0e10cSrcweir } 593*cdf0e10cSrcweir 594*cdf0e10cSrcweir for( int y = 0; y < (int)nHeight; y++ ) 595*cdf0e10cSrcweir { 596*cdf0e10cSrcweir const sal_uInt8* pScanline = pBMData + (nHeight-1-(sal_uInt32)y)*nScanlineSize; 597*cdf0e10cSrcweir for( int x = 0; x < (int)nWidth; x++ ) 598*cdf0e10cSrcweir { 599*cdf0e10cSrcweir sal_uInt8 b = pScanline[3*x]; 600*cdf0e10cSrcweir sal_uInt8 g = pScanline[3*x+1]; 601*cdf0e10cSrcweir sal_uInt8 r = pScanline[3*x+2]; 602*cdf0e10cSrcweir sal_uInt8 i = 36*(r/43) + 6*(g/43) + (b/43); 603*cdf0e10cSrcweir 604*cdf0e10cSrcweir XPutPixel( pImage, x, y, aPalette[ i ].pixel ); 605*cdf0e10cSrcweir } 606*cdf0e10cSrcweir } 607*cdf0e10cSrcweir } 608*cdf0e10cSrcweir 609*cdf0e10cSrcweir void PixmapHolder::setBitmapDataTC( const sal_uInt8* pData, XImage* pImage ) 610*cdf0e10cSrcweir { 611*cdf0e10cSrcweir sal_uInt32 nWidth = readLE32( pData+4 ); 612*cdf0e10cSrcweir sal_uInt32 nHeight = readLE32( pData+8 ); 613*cdf0e10cSrcweir 614*cdf0e10cSrcweir const sal_uInt8* pBMData = pData + readLE32( pData ); 615*cdf0e10cSrcweir sal_uInt32 nScanlineSize = nWidth*3; 616*cdf0e10cSrcweir // adjust scan lines to begin on %4 boundaries 617*cdf0e10cSrcweir if( nScanlineSize & 3 ) 618*cdf0e10cSrcweir { 619*cdf0e10cSrcweir nScanlineSize &= 0xfffffffc; 620*cdf0e10cSrcweir nScanlineSize += 4; 621*cdf0e10cSrcweir } 622*cdf0e10cSrcweir 623*cdf0e10cSrcweir for( int y = 0; y < (int)nHeight; y++ ) 624*cdf0e10cSrcweir { 625*cdf0e10cSrcweir const sal_uInt8* pScanline = pBMData + (nHeight-1-(sal_uInt32)y)*nScanlineSize; 626*cdf0e10cSrcweir for( int x = 0; x < (int)nWidth; x++ ) 627*cdf0e10cSrcweir { 628*cdf0e10cSrcweir unsigned long nPixel = getTCPixel( pScanline[3*x+2], pScanline[3*x+1], pScanline[3*x] ); 629*cdf0e10cSrcweir XPutPixel( pImage, x, y, nPixel ); 630*cdf0e10cSrcweir } 631*cdf0e10cSrcweir } 632*cdf0e10cSrcweir } 633*cdf0e10cSrcweir 634*cdf0e10cSrcweir bool PixmapHolder::needsConversion( const sal_uInt8* pData ) 635*cdf0e10cSrcweir { 636*cdf0e10cSrcweir if( pData[0] != 'B' || pData[1] != 'M' ) 637*cdf0e10cSrcweir return true; 638*cdf0e10cSrcweir 639*cdf0e10cSrcweir pData = pData+14; 640*cdf0e10cSrcweir sal_uInt32 nDepth = readLE32( pData+14 ); 641*cdf0e10cSrcweir if( nDepth == 24 ) 642*cdf0e10cSrcweir { 643*cdf0e10cSrcweir if( m_aInfo.c_class != TrueColor ) 644*cdf0e10cSrcweir return true; 645*cdf0e10cSrcweir } 646*cdf0e10cSrcweir else if( nDepth != (sal_uInt32)m_aInfo.depth ) 647*cdf0e10cSrcweir { 648*cdf0e10cSrcweir if( m_aInfo.c_class != TrueColor ) 649*cdf0e10cSrcweir return true; 650*cdf0e10cSrcweir } 651*cdf0e10cSrcweir 652*cdf0e10cSrcweir return false; 653*cdf0e10cSrcweir } 654*cdf0e10cSrcweir 655*cdf0e10cSrcweir Pixmap PixmapHolder::setBitmapData( const sal_uInt8* pData ) 656*cdf0e10cSrcweir { 657*cdf0e10cSrcweir if( pData[0] != 'B' || pData[1] != 'M' ) 658*cdf0e10cSrcweir return None; 659*cdf0e10cSrcweir 660*cdf0e10cSrcweir pData = pData+14; 661*cdf0e10cSrcweir 662*cdf0e10cSrcweir // reject compressed data 663*cdf0e10cSrcweir if( readLE32( pData + 16 ) != 0 ) 664*cdf0e10cSrcweir return None; 665*cdf0e10cSrcweir 666*cdf0e10cSrcweir sal_uInt32 nWidth = readLE32( pData+4 ); 667*cdf0e10cSrcweir sal_uInt32 nHeight = readLE32( pData+8 ); 668*cdf0e10cSrcweir 669*cdf0e10cSrcweir if( m_aPixmap != None ) 670*cdf0e10cSrcweir XFreePixmap( m_pDisplay, m_aPixmap ), m_aPixmap = None; 671*cdf0e10cSrcweir if( m_aBitmap != None ) 672*cdf0e10cSrcweir XFreePixmap( m_pDisplay, m_aBitmap ), m_aBitmap = None; 673*cdf0e10cSrcweir 674*cdf0e10cSrcweir m_aPixmap = XCreatePixmap( m_pDisplay, 675*cdf0e10cSrcweir RootWindow( m_pDisplay, m_aInfo.screen ), 676*cdf0e10cSrcweir nWidth, nHeight, m_aInfo.depth ); 677*cdf0e10cSrcweir 678*cdf0e10cSrcweir if( m_aPixmap != None ) 679*cdf0e10cSrcweir { 680*cdf0e10cSrcweir XImage aImage; 681*cdf0e10cSrcweir aImage.width = (int)nWidth; 682*cdf0e10cSrcweir aImage.height = (int)nHeight; 683*cdf0e10cSrcweir aImage.xoffset = 0; 684*cdf0e10cSrcweir aImage.format = ZPixmap; 685*cdf0e10cSrcweir aImage.data = NULL; 686*cdf0e10cSrcweir aImage.byte_order = ImageByteOrder( m_pDisplay ); 687*cdf0e10cSrcweir aImage.bitmap_unit = BitmapUnit( m_pDisplay ); 688*cdf0e10cSrcweir aImage.bitmap_bit_order = BitmapBitOrder( m_pDisplay ); 689*cdf0e10cSrcweir aImage.bitmap_pad = BitmapPad( m_pDisplay ); 690*cdf0e10cSrcweir aImage.depth = m_aInfo.depth; 691*cdf0e10cSrcweir aImage.red_mask = m_aInfo.red_mask; 692*cdf0e10cSrcweir aImage.green_mask = m_aInfo.green_mask; 693*cdf0e10cSrcweir aImage.blue_mask = m_aInfo.blue_mask; 694*cdf0e10cSrcweir aImage.bytes_per_line = 0; // filled in by XInitImage 695*cdf0e10cSrcweir if( m_aInfo.depth <= 8 ) 696*cdf0e10cSrcweir aImage.bits_per_pixel = m_aInfo.depth; 697*cdf0e10cSrcweir else 698*cdf0e10cSrcweir aImage.bits_per_pixel = 8*((m_aInfo.depth+7)/8); 699*cdf0e10cSrcweir aImage.obdata = NULL; 700*cdf0e10cSrcweir 701*cdf0e10cSrcweir XInitImage( &aImage ); 702*cdf0e10cSrcweir aImage.data = (char*)rtl_allocateMemory( nHeight*aImage.bytes_per_line ); 703*cdf0e10cSrcweir 704*cdf0e10cSrcweir if( readLE32( pData+14 ) == 24 ) 705*cdf0e10cSrcweir { 706*cdf0e10cSrcweir if( m_aInfo.c_class == TrueColor ) 707*cdf0e10cSrcweir setBitmapDataTC( pData, &aImage ); 708*cdf0e10cSrcweir else 709*cdf0e10cSrcweir setBitmapDataTCDither( pData, &aImage ); 710*cdf0e10cSrcweir } 711*cdf0e10cSrcweir else 712*cdf0e10cSrcweir setBitmapDataPalette( pData, &aImage ); 713*cdf0e10cSrcweir 714*cdf0e10cSrcweir // put the image 715*cdf0e10cSrcweir XPutImage( m_pDisplay, 716*cdf0e10cSrcweir m_aPixmap, 717*cdf0e10cSrcweir DefaultGC( m_pDisplay, m_aInfo.screen ), 718*cdf0e10cSrcweir &aImage, 719*cdf0e10cSrcweir 0, 0, 720*cdf0e10cSrcweir 0, 0, 721*cdf0e10cSrcweir nWidth, nHeight ); 722*cdf0e10cSrcweir 723*cdf0e10cSrcweir // clean up 724*cdf0e10cSrcweir rtl_freeMemory( aImage.data ); 725*cdf0e10cSrcweir 726*cdf0e10cSrcweir // prepare bitmap (mask) 727*cdf0e10cSrcweir m_aBitmap = XCreatePixmap( m_pDisplay, 728*cdf0e10cSrcweir RootWindow( m_pDisplay, m_aInfo.screen ), 729*cdf0e10cSrcweir nWidth, nHeight, 1 ); 730*cdf0e10cSrcweir XGCValues aVal; 731*cdf0e10cSrcweir aVal.function = GXcopy; 732*cdf0e10cSrcweir aVal.foreground = 0xffffffff; 733*cdf0e10cSrcweir GC aGC = XCreateGC( m_pDisplay, m_aBitmap, GCFunction | GCForeground, &aVal ); 734*cdf0e10cSrcweir XFillRectangle( m_pDisplay, m_aBitmap, aGC, 0, 0, nWidth, nHeight ); 735*cdf0e10cSrcweir XFreeGC( m_pDisplay, aGC ); 736*cdf0e10cSrcweir } 737*cdf0e10cSrcweir 738*cdf0e10cSrcweir return m_aPixmap; 739*cdf0e10cSrcweir } 740