#include <ScreenPipe.h>
Inherits PServer.
Public Methods | |
DWORD | readToDIB (DIBitmap &) |
ScreenPipe (const TString &) | |
Private Types | |
typedef ScreenPipe::screenInfo | screenInfo |
The structure of the header for each screen buffer. More... | |
Private Methods | |
DWORD | readError () |
Definition at line 26 of file ScreenPipe.h.
|
This is the first information on the pipe for each screen buffer. The size of the message is calculated from this information |
|
Definition at line 25 of file ScreenPipe.cpp. References BUFFER_SIZE.
00026 :PServer(TString( TEXT("Screen") ) + name, 00027 false, 00028 BUFFER_SIZE) 00029 {} |
|
Error function for readToDIB() Definition at line 96 of file ScreenPipe.cpp. References PServer::disconnect(), SP_NOT_CONNECTED, and SP_UNKNOWN_ERROR. Referenced by readToDIB().
00097 { 00098 switch(GetLastError()) { 00099 case ERROR_SECTOR_NOT_FOUND: 00100 disconnect(); 00101 return SP_NOT_CONNECTED; 00102 case ERROR_SUCCESS: // EOF? 00103 case ERROR_READ_FAULT: 00104 default: 00105 return SP_UNKNOWN_ERROR; 00106 } 00107 } |
|
A blocking function which reads data from the screen pipe and sets the given DIBitmap accordingly.
Definition at line 40 of file ScreenPipe.cpp. References ScreenPipe::screenInfo::bitCount, ScreenPipe::screenInfo::clrUsed, DIBitmap::createCompatible(), DIBitmap::getPBITMAPINFOHEADER(), DIBitmap::getPBytes(), DIBitmap::getPPalette(), ScreenPipe::screenInfo::hdrSize, ScreenPipe::screenInfo::height, Pipe::hPipe, readError(), SP_ERROR_CREATING_BITMAP, SP_INVALID_DATA, SP_SUCCESS, and ScreenPipe::screenInfo::width. Referenced by UpdateHandler::update().
00041 { 00042 DWORD numBytesRead; 00043 bool isOk; 00044 00045 screenInfo header; 00046 isOk = ReadFile( 00047 hPipe, // Read from 00048 &header, // data buffer 00049 sizeof(screenInfo), // number of bytes to read 00050 &numBytesRead, // number of bytes read 00051 NULL); // not overlapped 00052 00053 if( !isOk || (numBytesRead != sizeof(screenInfo)) ) 00054 return readError(); 00055 00056 if( header.hdrSize != sizeof(screenInfo) ){ 00057 return SP_INVALID_DATA; 00058 } 00059 00061 if( !(destination.getPBITMAPINFOHEADER()->biBitCount == header.bitCount 00062 && destination.getPBITMAPINFOHEADER()->biHeight == header.height 00063 && destination.getPBITMAPINFOHEADER()->biWidth == header.width) ){ 00064 00065 if( !destination.createCompatible(header.width, header.height, header.bitCount)) 00066 return SP_ERROR_CREATING_BITMAP; 00067 } 00068 00069 LPRGBQUAD palette = destination.getPPalette(); 00070 RGBTRIPLE entry; 00071 for(int i=0; i < header.clrUsed; i++, palette++){ 00072 00073 isOk = ReadFile(hPipe, &entry, sizeof(RGBTRIPLE), &numBytesRead, NULL); 00074 if( !isOk || (numBytesRead != sizeof(RGBTRIPLE)) ) 00075 return readError(); 00076 00077 palette->rgbBlue = entry.rgbtBlue; 00078 palette->rgbGreen = entry.rgbtGreen; 00079 palette->rgbRed = entry.rgbtRed; 00080 palette->rgbReserved = 0; 00081 } 00082 00083 // See DIBitmap documentation for explanation of this formula 00084 const DWORD size = (((( header.width * header.bitCount ) + 31) & ~31) >> 3) * header.height; 00085 00086 isOk = ReadFile(hPipe, destination.getPBytes(), size, &numBytesRead, NULL); 00087 if( !isOk || (numBytesRead != size ) ) 00088 return readError(); 00089 00090 return SP_SUCCESS; 00091 } |