diff options
-rw-r--r-- | TODO | 3 | ||||
-rw-r--r-- | main.c | 3 | ||||
-rw-r--r-- | pnmshow.c | 23 |
3 files changed, 19 insertions, 10 deletions
@@ -1,8 +1,8 @@ immediate: ---------- -fix bug with odd width (depends on client depth: width has to be multiple of server.bytesPerPixel/client.bytesPerPixel). only raw!! fix bug in http (java) client with big endian server: byte swapping is broken +cursor "smears" sometimes when not using cursor encoding in the works: ------------- @@ -28,4 +28,5 @@ done: .httpd .other encodings .test drawing of cursors when not using xcursor or rich cursor encoding +fix bug with odd width (depends on client depth: width has to be multiple of server.bytesPerPixel/client.bytesPerPixel). only raw!! -> bug of vncviewer! @@ -345,6 +345,9 @@ rfbScreenInfoPtr rfbDefaultScreenInit(int argc,char** argv,int width,int height, rfbScreenInfoPtr rfbScreen=malloc(sizeof(rfbScreenInfo)); rfbPixelFormat* format=&rfbScreen->rfbServerFormat; + if(width&3) + fprintf(stderr,"WARNING: Width (%d) is not a multiple of 4. VncViewer has problems with that.\n",width); + rfbScreen->rfbPort=5900; rfbScreen->socketInitDone=FALSE; rfbScreen->inetdSock=-1; @@ -11,7 +11,7 @@ void HandleKey(Bool down,KeySym key,rfbClientPtr cl) int main(int argc,char** argv) { FILE* in=stdin; - int i,width,height; + int i,j,k,width,height,paddedWidth; unsigned char buffer[1024]; rfbScreenInfoPtr rfbScreen; @@ -36,9 +36,14 @@ int main(int argc,char** argv) /* get width & height */ sscanf(buffer,"%d %d",&width,&height); - fprintf(stderr,"Got width %d and height %d (%s).\n",width,height,buffer); + fprintf(stderr,"Got width %d and height %d.\n",width,height); fgets(buffer,1024,in); + /* vncviewers have problems with widths which are no multiple of 4. */ + paddedWidth = width; + if(width&3) + paddedWidth+=4-(width&3); + /* initialize data for vnc server */ rfbScreen = rfbDefaultScreenInit(argc,argv,width,height,8,3,4); if(argc>1) @@ -52,16 +57,16 @@ int main(int argc,char** argv) rfbScreen->httpDir = "./classes"; /* allocate picture and read it */ - rfbScreen->frameBuffer = (char*)malloc(width*height*4); + rfbScreen->frameBuffer = (char*)calloc(paddedWidth*4,height); fread(rfbScreen->frameBuffer,width*3,height,in); fclose(in); - /* correct the format to 4 bytes instead of 3 */ - for(i=width*height-1;i>=0;i--) { - rfbScreen->frameBuffer[i*4+2]=rfbScreen->frameBuffer[i*3+2]; - rfbScreen->frameBuffer[i*4+1]=rfbScreen->frameBuffer[i*3+1]; - rfbScreen->frameBuffer[i*4+0]=rfbScreen->frameBuffer[i*3+0]; - } + /* correct the format to 4 bytes instead of 3 (and pad to paddedWidth) */ + for(j=height-1;j>=0;j--) + for(i=width-1;i>=0;i--) + for(k=2;k>=0;k--) + rfbScreen->frameBuffer[(j*paddedWidth+i)*4+k]= + rfbScreen->frameBuffer[(j*width+i)*3+k]; /* run event loop */ runEventLoop(rfbScreen,40000,FALSE); |