FrameBuffer FrameSource::getDepthCorrectionCoefficients(void) const { /* Get the source's frame size and create a result frame buffer: */ const unsigned int* frameSize=getActualFrameSize(DEPTH); FrameBuffer result(frameSize[0],frameSize[1],frameSize[1]*frameSize[0]*sizeof(PixelDepthCorrection)); /* Initialize the frame buffer to the identity transformation: */ PixelDepthCorrection* pdcPtr=static_cast<PixelDepthCorrection*>(result.getBuffer()); for(unsigned int y=0;y<frameSize[1];++y) for(unsigned int x=0;x<frameSize[0];++x,++pdcPtr) { pdcPtr->scale=1.0f; pdcPtr->offset=0.0f; } /* Return the identity correction map: */ return result; }
// Redraw function, called by GTK each time we ask for a frame redraw static gboolean on_expose_event (GtkWidget *widget, GdkEventExpose *event, gpointer data) { display_stage_cfg_t *cfg = (display_stage_cfg_t *)data; if (2.0 != cfg->bpp) { return FALSE; } uint32_t width = 0, height = 0, stride = 0; getPicSizeFromBufferSize (cfg->fbSize, &width, &height); stride = cfg->bpp * width; if (0 == stride) { return FALSE; } uint32_t actual_width = 0, actual_height = 0; getActualFrameSize (cfg, &actual_width, &actual_height); gtk_window_resize (GTK_WINDOW (widget), actual_width, actual_height); cairo_t *cr = gdk_cairo_create (widget->window); cairo_surface_t *surface = cairo_image_surface_create_for_data (cfg->frameBuffer, CAIRO_FORMAT_RGB16_565, width, height, stride); cairo_set_source_surface (cr, surface, 0.0, 0.0); cairo_paint (cr); cairo_surface_destroy (surface); cairo_destroy (cr); return FALSE; }