Commit d6082b69 authored by dscho's avatar dscho

adapted pnmshow to aligned width

parent 74c7c6cd
immediate: 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 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: in the works:
------------- -------------
...@@ -28,4 +28,5 @@ done: ...@@ -28,4 +28,5 @@ done:
.httpd .httpd
.other encodings .other encodings
.test drawing of cursors when not using xcursor or rich cursor encoding .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, ...@@ -345,6 +345,9 @@ rfbScreenInfoPtr rfbDefaultScreenInit(int argc,char** argv,int width,int height,
rfbScreenInfoPtr rfbScreen=malloc(sizeof(rfbScreenInfo)); rfbScreenInfoPtr rfbScreen=malloc(sizeof(rfbScreenInfo));
rfbPixelFormat* format=&rfbScreen->rfbServerFormat; 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->rfbPort=5900;
rfbScreen->socketInitDone=FALSE; rfbScreen->socketInitDone=FALSE;
rfbScreen->inetdSock=-1; rfbScreen->inetdSock=-1;
......
...@@ -11,7 +11,7 @@ void HandleKey(Bool down,KeySym key,rfbClientPtr cl) ...@@ -11,7 +11,7 @@ void HandleKey(Bool down,KeySym key,rfbClientPtr cl)
int main(int argc,char** argv) int main(int argc,char** argv)
{ {
FILE* in=stdin; FILE* in=stdin;
int i,width,height; int i,j,k,width,height,paddedWidth;
unsigned char buffer[1024]; unsigned char buffer[1024];
rfbScreenInfoPtr rfbScreen; rfbScreenInfoPtr rfbScreen;
...@@ -36,9 +36,14 @@ int main(int argc,char** argv) ...@@ -36,9 +36,14 @@ int main(int argc,char** argv)
/* get width & height */ /* get width & height */
sscanf(buffer,"%d %d",&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); 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 */ /* initialize data for vnc server */
rfbScreen = rfbDefaultScreenInit(argc,argv,width,height,8,3,4); rfbScreen = rfbDefaultScreenInit(argc,argv,width,height,8,3,4);
if(argc>1) if(argc>1)
...@@ -52,16 +57,16 @@ int main(int argc,char** argv) ...@@ -52,16 +57,16 @@ int main(int argc,char** argv)
rfbScreen->httpDir = "./classes"; rfbScreen->httpDir = "./classes";
/* allocate picture and read it */ /* 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); fread(rfbScreen->frameBuffer,width*3,height,in);
fclose(in); fclose(in);
/* correct the format to 4 bytes instead of 3 */ /* correct the format to 4 bytes instead of 3 (and pad to paddedWidth) */
for(i=width*height-1;i>=0;i--) { for(j=height-1;j>=0;j--)
rfbScreen->frameBuffer[i*4+2]=rfbScreen->frameBuffer[i*3+2]; for(i=width-1;i>=0;i--)
rfbScreen->frameBuffer[i*4+1]=rfbScreen->frameBuffer[i*3+1]; for(k=2;k>=0;k--)
rfbScreen->frameBuffer[i*4+0]=rfbScreen->frameBuffer[i*3+0]; rfbScreen->frameBuffer[(j*paddedWidth+i)*4+k]=
} rfbScreen->frameBuffer[(j*width+i)*3+k];
/* run event loop */ /* run event loop */
runEventLoop(rfbScreen,40000,FALSE); runEventLoop(rfbScreen,40000,FALSE);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment