Lumiera 0.pre.04~rc.1
»edit your freedom«
Loading...
Searching...
No Matches
pixbuf-displayer.cpp
Go to the documentation of this file.
1/*
2 PixbufDisplayer - displaying video via bitmap image
3
4 Copyright (C)
5 2000, Arne Schirmacher <arne@schirmacher.de>
6 2001-2007, Dan Dennedy <dan@dennedy.org>
7 2008, Joel Holdsworth <joel@airwebreathe.org.uk>
8 2025, Hermann Vosseler <Ichthyostega@web.de>
9
10  **Lumiera** is free software; you can redistribute it and/or modify it
11  under the terms of the GNU General Public License as published by the
12  Free Software Foundation; either version 2 of the License, or (at your
13  option) any later version. See the file COPYING for further details.
14
15* *****************************************************************/
16
17
24#include "stage/gtk-base.hpp"
26
27
28namespace stage {
29namespace output {
30
31 PixbufDisplayer::PixbufDisplayer (Gtk::Image& drawing_area,
32 uint width, uint height)
33 : Displayer{width,height}
34 , drawingArea_{drawing_area}
35 {
36 REQUIRE (width > 0);
37 REQUIRE (height > 0);
38 auto iconSet = Gtk::IconSet::lookup_default (Gtk::StockID("panel_play"));
39 drawingArea_.set(iconSet, Gtk::IconSize(Gtk::ICON_SIZE_DIALOG));
40 INFO(stage, "Using Pixbuf with RGB output within Gtk::Image");
41 }
42
43 bool
45 {
46 return true;
47 }
48
49 void
50 PixbufDisplayer::put (void* const image)
51 {
52 int orgX = 0,
53 orgY = 0,
54 destWidth = 0,
55 destHeight = 0;
56
58 drawingArea_.get_width(),
59 drawingArea_.get_height(),
60 orgX, orgY, destWidth, destHeight);
61
62 auto* imageData = static_cast<const guint8*> (image);
63 auto imgBuf = Gdk::Pixbuf::create_from_data (imageData
64 ,Gdk::COLORSPACE_RGB
65 ,false // has_alpha
66 ,8 // bits_per_sample
69 ,3 * videoWidth // rowstride (offset between consecutive rows)
70 );
71 ASSERT (imgBuf);
72 if (uint(destWidth) != videoWidth
73 or uint(destHeight) != videoHeight)
74 imgBuf = imgBuf->scale_simple (destWidth, destHeight, Gdk::INTERP_NEAREST);
75 drawingArea_.set (imgBuf);
76 drawingArea_.queue_draw();
77 }
78
79
80}} // namespace stage::output
A Displayer is a class which is responsible for rendering an image in some way (ie: Xvideo,...
Definition displayer.hpp:62
void calculateVideoLayout(int widgetWidth, int widgetHeight, int &imgOrg_x, int &imgOrg_y, int &imgWidth, int &imgHeight)
Calculates the coordinates for placing a video image inside a widget.
Definition displayer.cpp:45
bool usable() override
Indicates if this object can be used to render images on the running system.
PixbufDisplayer(Gtk::Image &drawing_area, uint width, uint height)
Constructor.
void put(void *const image)
Put an image of a given width and height with the expected input format (as indicated by the format m...
A set of basic GTK includes for the UI.
unsigned int uint
Definition integral.hpp:29
Lumiera GTK UI implementation root.
Definition guifacade.cpp:37
Display video as bitmap image with the UI toolkit.