Re: pixbuf outermost pixels are white

2013-08-23 Thread Jan Kratochvil
On Fri, 23 Aug 2013 21:15:14 +0200, Søren Sandmann wrote:
 You probably want to set the extend mode to CAIRO_EXTEND_PAD by doing
 the C++ equivalent of this:
 
 cairo_pattern_set_extend (cairo_get_source (cr), CAIRO_EXTEND_PAD);
 
 after setting the pixbuf as the cairo source.

It really works, thanks!

Moreover I can even turn off the smoothing (not appropriate in my case):
auto 
surfacepattern(Cairo::RefPtrCairo::SurfacePattern::cast_dynamic(cr-get_source()));
surfacepattern-set_extend(Cairo::EXTEND_PAD);
surfacepattern-set_filter(Cairo::FILTER_NEAREST);

http://www.jankratochvil.net/t/2.png


Regards,
Jan Kratochvil


/*
g++ -o 1 1.C -Wall -Werror -std=gnu++11 -g $(pkg-config --cflags --libs 
gtkmm-3.0);./1
*/
#include gdkmm/general.h
#include gtkmm/main.h
#include gtkmm/window.h
#include gtkmm/drawingarea.h
#include vector
#include stdio.h
using namespace std;

class Area:public Gtk::DrawingArea {
  bool on_draw(const Cairo::RefPtrCairo::Context cr) {
//cr-translate(+0.5,+0.5);
class RGB {
public:
  guint8 r=0,g=0,b=0;
};
vectorRGB data24;
RGB rgb;
rgb.r=255; rgb.g=0  ; rgb.b=0  ; data24.push_back(rgb);
rgb.r=0  ; rgb.g=255; rgb.b=255; data24.push_back(rgb);
rgb.r=0  ; rgb.g=0  ; rgb.b=255; data24.push_back(rgb);
rgb.r=255; rgb.g=255; rgb.b=0  ; data24.push_back(rgb);
Glib::RefPtrGdk::Pixbuf pixbuf;
pixbuf=Gdk::Pixbuf::create_from_data((const guint8 
*)data24.data(),Gdk::COLORSPACE_RGB,false/*has_alpha*/,8/*bits_per_sample*/,
  2 /*width*/,
  2 /*height*/,
  2*3/*rowstride==width*/);
//cr-set_identity_matrix();
{
  cr-save();
  // Does not work: cr-set_antialias(Cairo::ANTIALIAS_NONE);
  // Does not work: cr-set_fill_rule(Cairo::FILL_RULE_EVEN_ODD);
  cr-scale(double(get_allocation().get_width ())/pixbuf-get_width (),
double(get_allocation().get_height())/pixbuf-get_height());
  Gdk::Cairo::set_source_pixbuf(cr,pixbuf);
  auto 
surfacepattern(Cairo::RefPtrCairo::SurfacePattern::cast_dynamic(cr-get_source()));
  surfacepattern-set_extend(Cairo::EXTEND_PAD);
  surfacepattern-set_filter(Cairo::FILTER_NEAREST);
  cr-rectangle(0,0,pixbuf-get_width(),pixbuf-get_height());
  cr-fill();
  cr-restore();
}
return true;
  }
};

int main() {
  Gtk::Main *app=new Gtk::Main();
  Gtk::Window *win=new Gtk::Window();
  win-set_default_size(500,500);
  win-maximize();
  win-add(*new Area());
  win-show_all();
  app-run(*win);
}
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: how can include just glib

2006-01-19 Thread Jan Kratochvil
Hi,

On Tue, 13 Dec 2005 16:36:44 +0100, Daniel Espinosa wrote:
...
 but HOW can I init the library. If you use gtk and gtk_init, it will init
 GLib too then, how do I do that?

What specific problem do you have?
glib - it does not need any init
gobject - it needs g_type_init()
gthread - it needs g_thread_init(NULL)
  (although gthread initialization is more specific)
gmodule - it does not need any init



Regards,
Lace
___
gtk-devel-list mailing list
gtk-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-devel-list


Re: g_try_new and g_try_new0 + error reporting for g_object_set

2005-05-12 Thread Jan Kratochvil
Hi Stefan,

On Wed, 09 Mar 2005 02:21:16 +0900, Stefan Kost wrote:
 Matthias Clasen wrote:
...
  g_new and g_new0
...
 I am aware that I can write my own. But if many people do that it might make
 sense to have them in the lib.
 
 What do other do in this case?

Nothing as general UNIX libraries applications incl. the Gnome ones do not
handle the OOM case at all and they are expected to crash on swap exhaustion.
At least Linux kernel will start killing the processes itself anyway.

And it does not make sense to precisely handle each OOM case properly in your
code as any other library you call and even any other process on the system
will crash or gets killed in such OOM case anyway.

You need to secure your UNIX system against OOM on per-fork/exec case (with
same recoveries/restarts), not per-alloc case.


Regards,
Lace
___
gtk-devel-list mailing list
gtk-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-devel-list


Re: howto compile static gtk app?

2005-03-11 Thread Jan Kratochvil
On Wed, 09 Mar 2005 18:29:42 +0100, Andreas Rottmann wrote:
 Jan Kratochvil [EMAIL PROTECTED] writes:
  On Wed, 09 Mar 2005 11:22:50 +0100, Yang Hong wrote:
  ...
   I wan to compile a static gtk app, then it can run in a everiment
   without gtk libs.
 
 [...]
 
  GNU/Linux really is not suitable for end-user applications as long as you do
  not stick to a single release of a single GNU/Linux distribution vendor.
 
 I demand that GNU/Linux is perfectly suited for end-user applications - is 
 there a binary missing in the above ;-)?

[-1 flamebait]

Even if you spend $$$ for a qualified Gnome engineer to patch, maintain both
the patches and neverending rebuilt versions of all those libraries it will
have security + bug flaws as the already installed binary will not use the
system libraries being continually security/bugfix updated. You may notice
those $$$ are just not worth the Gnome market share.

Another issue is such static standalone build will not follow the specific OS
configuration files settings to prevent errors during their interpretation due
to the missing optional dynamically loaded .so modules.

Minor issue may also be the unshared multimegabyte HelloWorld binary file size
with all its performance consequences.

Compatibility becomes another level of mostly impossible challenge if you
happen to require to bundle some custom Linux kernel driver with your app as on
top of the missing reqd ABI compatibility there is also no API compatibility.



Have fun,
Lace
___
gtk-devel-list mailing list
gtk-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-devel-list


Re: howto compile static gtk app?

2005-03-09 Thread Jan Kratochvil
Hi,

On Wed, 09 Mar 2005 11:22:50 +0100, Yang Hong wrote:
...
 I wan to compile a static gtk app, then it can run in a everiment
 without gtk libs.

It is depends if you really want just GTK or if you use also other parts of the
Gnome framework. Gnome in general is not usable for 'static builds' without
patches. Not sure if the following patches are still valid these days:
http://www.jankratochvil.net/project/captive/CVS.html.pl#source

http://www.jankratochvil.net/project/captive/dist/build-captive-static-2003-12-14-00.tar.gz

Patches for standalone static application builds are required for:
gconf2: no daemon dependency
fontconfig: Makefile modifications for static builds
gtk2: fix compilation without Xft
pango: no external config files + fonts dependency
glibc (no Gnome): compat NSS fix for --enable-static-nss
Just static and/or feature-removed custom rebuilds are required for:
atk, gnomevfs2, libgnome, libgnomecanvas, libgnomeui, openssl

GNU/Linux really is not suitable for end-user applications as long as you do
not stick to a single release of a single GNU/Linux distribution vendor.


Regards,
Lace
___
gtk-devel-list mailing list
gtk-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-devel-list