cairo

Get pixel value on Gdk::Pixbuf, Set pixel value with Gdk::Cairo

对着背影说爱祢 提交于 2019-12-10 09:26:33
问题 I'm using a Gdk::Pixbuf to display an image with Gdk::Cairo in C++ : virtual bool on_draw(const Cairo::RefPtr<Cairo::Context>& cr) { Glib::RefPtr<Gdk::Pixbuf> image = Gdk::Pixbuf::create_from_file(filename); Gdk::Cairo::set_source_pixbuf(cr, image, (width - image->get_width())/2, (height - image->get_height())/2); cr->paint(); /* other displaying stuffs */ } This image is in B&W and I need to bring out some pixels whose luminance is above a certain threshold. For that, I would like to color

How can I render Text with transparent background over other widgets in GTK?

匆匆过客 提交于 2019-12-09 21:42:51
问题 I wish to render text with transparent/translucent background (or no background) over other gtk widgets like GtkImage or GtkButton etc. Primary goal is to have text display over Gtk Widgets (esp. GtkImage) in the background. I can render text on GtkFrame using pangocairo library but I am not able to get rid of the background of GtkFrame. I have seen examples of making GtkWindow transparent or translucent but I wish to have opaque GtkWindow with GtkLayout for placing the GtkWidgets, then place

rotate text around its center in pycairo

♀尐吖头ヾ 提交于 2019-12-09 17:53:48
问题 community. I know that there are many answers here, manuals, tutorials and references over the internets and amny more about this question. Also I know that knowledge of linear algebra is required. But when I think about time to figuring out all the theory and solving exercises in practice - my head is blowing off and I can't do the simplest things :( Please, if you know a little fast solution how to make rotation of text over its center before rendering it - tell me, pleeease. For now I have

Inkscape screws up EPS files

倖福魔咒の 提交于 2019-12-09 17:28:12
问题 I have been trying to use Inkscape to prepare artwork graphics for my scientific papers. I use LaTeX, and I need my figures to be prepared as high-quality Encapsulated PostScript (EPS) images. The work order is as follows. First, I plot parts of my figure using matplotlib and save them in EPS format. Second, I launch Inkscape and import the EPS files. Using Inkscape I compose a figure, leaving needed objects, killing unneeded, and adding some markups. So I used to do when I worked with

How to return an image in an HTTP response with CherryPy

╄→尐↘猪︶ㄣ 提交于 2019-12-09 11:31:20
问题 I have code which generates a Cairo ImageSurface , and I expose it like so: def preview(...): surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, width, height) ... cherrypy.response.headers['Content-Type'] = "image/png" return surface.get_data() preview.exposed = True This doesn't work (browsers report that the image has errors). I've tested that surface.write_to_png('test.png') works, but I'm not sure what to dump the data into to return it. I'm guessing some file-like object? According to

using cairo with gtk3

拥有回忆 提交于 2019-12-09 08:03:30
I am trying to draw a scatterplot with cairo in gtk3. To start, I am using the examples here: http://zetcode.com/tutorials/cairographicstutorial/ They compile with gtk2 successfully but display no image. They do not compile with gtk3 but give the following error: example.c: In function ‘on_expose_event’: example.c:17:31: error: ‘GtkWidget’ has no member named ‘window’ Any help on this would be greatly appreciated. btw I am using writing using ArchLinux for this if that helps. another.anon.coward There have been quite a few changes in Gtk3. There is no member window exposed as part of GtkWidget

Matplotlib PDF export uses wrong font

浪子不回头ぞ 提交于 2019-12-09 04:39:19
问题 I want to generate high-quality diagrams for a presentation. I’m using Python’s matplotlib to generate the graphics. Unfortunately, the PDF export seems to ignore my font settings. I tried setting the font both by passing a FontProperties object to the text drawing functions and by setting the option globally. For the record, here is a MWE to reproduce the problem: import scipy import matplotlib matplotlib.use('cairo') import matplotlib.pylab as pylab import matplotlib.font_manager as fm data

Cannot import matplotlib.pyplot in python 3

a 夏天 提交于 2019-12-08 09:42:26
I followed the instructions to install matplotlib for python 3 from here: How to install matplotlib with Python3.2 But I get an ImportError, which I have not been able to resolve, when importing pyplot: >>> import matplotlib >>> import matplotlib.pyplot as plt Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib/python3.2/dist-packages/matplotlib-1.4.x-py3.2-linux-i686.egg/matplotlib/pyplot.py", line 98, in <module> _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup() File "/usr/local/lib/python3.2/dist-packages/matplotlib-1.4.x

Checking if path is simple and closed using cairo

删除回忆录丶 提交于 2019-12-08 06:52:47
问题 I am using cairomm together with gtkmm for a GUI project. I have defined a GeometricShape abstract widget (which inherits from Gtk::DrawingArea ) to inherit from if one needs to draw a square, a circle, etc. This class defines three regions: a fill (or body area); a border; a background area. The fill area is used to fill in the shape with a certain body color. The border (usually black) defines the shape and the background area is used to fill the remaining space (everything but the border

How to get a PNG (alpha channel) screenshot of Gtk window?

为君一笑 提交于 2019-12-08 06:52:35
问题 Gtk windows support transparency using Cairo. I tried to get a screenshot with the code here. But it prints pure black for windows that use transparency. How can I make a screenshot (PNG) which caputures the alpha channel too? EDIT: I tried with alpha pixbuf, but the output is still with no alpha. Here's my code (sing Gtk#, but it's pretty identical to C): static void GetScreenshot(Gtk.Window win) { var pixbuf = new Gdk.Pixbuf(Gdk.Colorspace.Rgb, true, 8, 500, 500); var pix = pixbuf