summaryrefslogtreecommitdiffstats
path: root/examples/rotatetemplate.c
diff options
context:
space:
mode:
Diffstat (limited to 'examples/rotatetemplate.c')
-rw-r--r--examples/rotatetemplate.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/examples/rotatetemplate.c b/examples/rotatetemplate.c
new file mode 100644
index 0000000..57dc052
--- /dev/null
+++ b/examples/rotatetemplate.c
@@ -0,0 +1,52 @@
+#define OUT_T CONCAT3E(uint,OUT,_t)
+#define FUNCTION CONCAT2E(FUNCNAME,OUT)
+
+static void FUNCTION(rfbScreenInfoPtr screen)
+{
+ OUT_T* buffer = (OUT_T*)screen->frameBuffer;
+ int i, j, w = screen->width, h = screen->height;
+ OUT_T* newBuffer = (OUT_T*)malloc(w * h * sizeof(OUT_T));
+
+ for (j = 0; j < h; j++)
+ for (i = 0; i < w; i++)
+ newBuffer[FUNC(i, j)] = buffer[i + j * w];
+
+ memcpy(buffer, newBuffer, w * h * sizeof(OUT_T));
+ free(newBuffer);
+
+#ifdef SWAPDIMENSIONS
+ screen->width = h;
+ screen->paddedWidthInBytes = h * OUT / 8;
+ screen->height = w;
+
+ {
+ rfbClientIteratorPtr iterator;
+ rfbClientPtr cl;
+ iterator = rfbGetClientIterator(screen);
+ while ((cl = rfbClientIteratorNext(iterator)) != NULL)
+ cl->newFBSizePending = 1;
+ }
+#endif
+
+ rfbMarkRectAsModified(screen, 0, 0, screen->width, screen->height);
+}
+
+#if OUT == 32
+void FUNCNAME(rfbScreenInfoPtr screen) {
+ if (screen->serverFormat.bitsPerPixel == 32)
+ CONCAT2E(FUNCNAME,32)(screen);
+ else if (screen->serverFormat.bitsPerPixel == 16)
+ CONCAT2E(FUNCNAME,16)(screen);
+ else if (screen->serverFormat.bitsPerPixel == 8)
+ CONCAT2E(FUNCNAME,8)(screen);
+ else {
+ rfbErr("Unsupported pixel depth: %d\n",
+ screen->serverFormat.bitsPerPixel);
+ return;
+ }
+}
+#endif
+
+#undef FUNCTION
+#undef OUT
+
OpenPOWER on IntegriCloud