Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

ScreenClient.cpp

Go to the documentation of this file.
00001 // ScreenClient.cpp: implementation of the ScreenClient class.
00004 
00005 
00006 #include "stdafx.h"
00007 #include "ScreenClient.h"
00008 
00010 // Construction
00012 
00017 ScreenClient::ScreenClient(const TString &name)
00018 :PClient(TString( TEXT("SCREEN") ) + name, true)
00019 {}
00020 
00022 // Member Functions
00024 
00036 bool ScreenClient::write(const int width, 
00037                       const int height, 
00038                       const int clrUsed, 
00039                       const int bitCount, 
00040                       const RGBTRIPLE* palette, 
00041                       const LPBYTE imageBits)
00042 {
00043     screenInfo header;
00044     DWORD numBytesWritten;
00045     bool fOk;
00046 
00047     if( (palette == NULL && clrUsed > 0) || imageBits == NULL )
00048         return false;
00049 
00050     header.hdrSize = sizeof(screenInfo);
00051     header.width = width;
00052     header.height = height;
00053     header.clrUsed = clrUsed;
00054     header.bitCount = bitCount;
00055 
00056     fOk = !WriteFile(hPipe,
00057             &header,
00058             sizeof(screenInfo),
00059             &numBytesWritten,
00060             NULL);
00061 
00062     if( fOk || (numBytesWritten != sizeof(screenInfo)) )
00063         return false;
00064 
00065     if(palette != NULL){
00066         fOk = !WriteFile(hPipe,
00067             palette,
00068             sizeof(RGBTRIPLE) * clrUsed,
00069             &numBytesWritten,
00070             NULL);
00071 
00072         if( fOk || (numBytesWritten != (sizeof(RGBTRIPLE) * clrUsed)) )
00073             return false;
00074 
00075     }
00076 
00077     /* \note see DIBitmap documentation for an explanation of this formula */
00078     DWORD size = (((( width * bitCount ) + 31) & ~31) >> 3) * height;
00079 
00080     fOk = !WriteFile(hPipe,
00081             imageBits,
00082             size,
00083             &numBytesWritten,
00084             NULL);
00085 
00086     if( fOk || (numBytesWritten != size) )
00087         return false;
00088 
00089     return true;
00090 }

Generated on Mon Mar 25 06:29:59 2002 for Window Dressing by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001