Home | History | Annotate | Download | only in examples
      1 #define OUT_T CONCAT3E(uint,OUTBITS,_t)
      2 #define FUNCTION CONCAT2E(FUNCNAME,OUTBITS)
      3 
      4 static void FUNCTION(rfbScreenInfoPtr screen)
      5 {
      6 	OUT_T* buffer = (OUT_T*)screen->frameBuffer;
      7 	int i, j, w = screen->width, h = screen->height;
      8 	OUT_T* newBuffer = (OUT_T*)malloc(w * h * sizeof(OUT_T));
      9 
     10 	for (j = 0; j < h; j++)
     11 		for (i = 0; i < w; i++)
     12 			newBuffer[FUNC(i, j)] = buffer[i + j * w];
     13 
     14 	memcpy(buffer, newBuffer, w * h * sizeof(OUT_T));
     15 	free(newBuffer);
     16 
     17 #ifdef SWAPDIMENSIONS
     18 	screen->width = h;
     19 	screen->paddedWidthInBytes = h * OUTBITS / 8;
     20 	screen->height = w;
     21 
     22 	{
     23 		rfbClientIteratorPtr iterator;
     24 		rfbClientPtr cl;
     25 		iterator = rfbGetClientIterator(screen);
     26 		while ((cl = rfbClientIteratorNext(iterator)) != NULL)
     27 			cl->newFBSizePending = 1;
     28 	}
     29 #endif
     30 
     31 	rfbMarkRectAsModified(screen, 0, 0, screen->width, screen->height);
     32 }
     33 
     34 #if OUTBITS == 32
     35 void FUNCNAME(rfbScreenInfoPtr screen) {
     36 	if (screen->serverFormat.bitsPerPixel == 32)
     37 		CONCAT2E(FUNCNAME,32)(screen);
     38 	else if (screen->serverFormat.bitsPerPixel == 16)
     39 		CONCAT2E(FUNCNAME,16)(screen);
     40 	else if (screen->serverFormat.bitsPerPixel == 8)
     41 		CONCAT2E(FUNCNAME,8)(screen);
     42 	else {
     43 		rfbErr("Unsupported pixel depth: %d\n",
     44 			screen->serverFormat.bitsPerPixel);
     45 		return;
     46 	}
     47 }
     48 #endif
     49 
     50 #undef FUNCTION
     51 #undef OUTBITS
     52 
     53