11 if(down && (key==
XK_Escape || key==
'q' || key==
'Q'))
16 int main(
int argc,
char** argv)
21 rfbScreenInfoPtr rfbScreen;
22 enum { BW, GRAY, TRUECOLOUR } picType=TRUECOLOUR;
23 int bytesPerPixel,bitsPerPixelInFile;
26 in=fopen(argv[1],
"rb");
28 printf(
"Couldn't find file %s.\n",argv[1]);
33 fgets(buffer,1024,in);
34 if(!strncmp(buffer,
"P6",2)) {
36 bytesPerPixel=4; bitsPerPixelInFile=3*8;
37 }
else if(!strncmp(buffer,
"P5",2)) {
39 bytesPerPixel=1; bitsPerPixelInFile=1*8;
40 }
else if(!strncmp(buffer,
"P4",2)) {
42 bytesPerPixel=1; bitsPerPixelInFile=1;
44 printf(
"Not a ppm.\n");
50 fgets(buffer,1024,in);
51 }
while(buffer[0]==
'#');
57 fgets(buffer,1024,in);
64 paddedWidth+=4-(
width&3);
67 rfbScreen =
rfbGetScreen(&argc,argv,paddedWidth,
height,8,(bitsPerPixelInFile+7)/8,bytesPerPixel);
71 rfbScreen->desktopName = argv[1];
73 rfbScreen->desktopName =
"Picture";
74 rfbScreen->alwaysShared =
TRUE;
75 rfbScreen->kbdAddEvent = HandleKey;
78 rfbScreen->httpDir =
"../webclients";
81 rfbScreen->frameBuffer = (
char*)malloc(paddedWidth*bytesPerPixel*
height);
82 if(!rfbScreen->frameBuffer)
84 fread(rfbScreen->frameBuffer,
width*bitsPerPixelInFile/8,
height,in);
87 if(picType!=TRUECOLOUR) {
88 rfbScreen->serverFormat.trueColour=
FALSE;
89 rfbScreen->colourMap.count=256;
90 rfbScreen->colourMap.is16=
FALSE;
91 rfbScreen->colourMap.data.bytes=malloc(256*3);
92 if(!rfbScreen->colourMap.data.bytes)
95 memset(rfbScreen->colourMap.data.bytes+3*i,i,3);
101 for(j=
height-1;j>=0;j--) {
102 for(i=
width-1;i>=0;i--)
104 rfbScreen->frameBuffer[(j*paddedWidth+i)*4+k]=
105 rfbScreen->frameBuffer[(j*
width+i)*3+k];
106 for(i=
width*4;i<paddedWidth*4;i++)
107 rfbScreen->frameBuffer[j*paddedWidth*4+i]=0;
115 for(i=
width-1;i>=0;i-=8) {
116 l=(
unsigned char)rfbScreen->frameBuffer[(j*
width+i)/8];
118 rfbScreen->frameBuffer[j*paddedWidth+i+7-k]=(l&(1<<k))?0:255;
void rfbInitServer(rfbScreenInfoPtr rfbScreen)
void rfbRunEventLoop(rfbScreenInfoPtr screenInfo, long usec, rfbBool runInBackground)
void rfbCloseClient(rfbClientPtr cl)
rfbScreenInfoPtr rfbGetScreen(int *argc, char **argv, int width, int height, int bitsPerSample, int samplesPerPixel, int bytesPerPixel)
int main(int argc, char **argv)