pnmshow24 is like pnmshow, but it uses 3 bytes/pixel internally, which is not as efficient as 4 bytes/pixel for translation, because there is no native data type of that size, so you have to memcpy pixels and be real cautious with endianness.
pnmshow24 is like pnmshow, but it uses 3 bytes/pixel internally, which is not as efficient as 4 bytes/pixel for translation, because there is no native data type of that size, so you have to memcpy pixels and be real cautious with endianness. Anyway, it works.
#include <stdio.h>
#ifndef LIBVNCSERVER_ALLOW24BPP
printf("I need the ALLOW24BPP LibVNCServer flag to work\n");
exit(1);
}
#else
{
if(down && (key==
XK_Escape || key==
'q' || key==
'Q'))
}
int main(
int argc,
char** argv)
{
FILE* in=stdin;
char buffer[1024];
rfbScreenInfoPtr rfbScreen;
if(argc>1) {
in=fopen(argv[1],"rb");
if(!in) {
printf("Couldn't find file %s.\n",argv[1]);
exit(1);
}
}
fgets(buffer,1024,in);
if(strncmp(buffer,"P6",2)) {
printf("Not a ppm.\n");
exit(2);
}
do {
fgets(buffer,1024,in);
} while(buffer[0]=='#');
printf("Failed to get width or height.\n");
exit(3);
}
fgets(buffer,1024,in);
paddedWidth+=4-(
width&3);
if(!rfbScreen)
return 1;
if(argc>1)
rfbScreen->desktopName = argv[1];
else
rfbScreen->desktopName = "Picture";
rfbScreen->alwaysShared =
TRUE;
rfbScreen->kbdAddEvent = HandleKey;
rfbScreen->httpDir = "../webclients";
if (paddedWidth>SIZE_MAX/3 || (
height!=0 && paddedWidth*3>SIZE_MAX/
height))
return 1;
rfbScreen->frameBuffer = (
char*)malloc(paddedWidth*3*
height);
if(!rfbScreen->frameBuffer)
return 1;
fclose(in);
if(
width != paddedWidth) {
int padCount = 3*(paddedWidth -
width);
memmove(rfbScreen->frameBuffer+3*paddedWidth*j,
rfbScreen->frameBuffer+3*
width*j,
memset(rfbScreen->frameBuffer+3*paddedWidth*(j+1)-padCount,
0,padCount);
}
}
return(0);
}
#endif
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)