[Gtk-sharp-list] Scaling Gdk.Pixbuf in a thread

Christopher David Howie me at chrishowie.com
Mon Nov 8 17:04:13 EST 2010

On 11/05/2010 06:18 AM, blue_bob wrote:
> I'm afraid my entire approch is wrong so if anyone can come up with a tip I
> would be very grateful.

It may not be wrong, but there's an approach we can use to make it flow
better.  I'm not going to copy all of your code and rewrite it, but I'll
give you the basic skeleton code.

public void DoRescale() {
    // Assuming that you have access to all of the job data (pixbuf,
    // new size, etc.

    new Thread(delegate () {
        // Do the resize here.

        Application.Invoke(delegate {
            // Draw the pixbuf here; this will be run on the GTK+ main
            // loop thread.

Note that anonymous methods have access to locals in their defining
method, so you won't need to create a "job" class/object to ferry them
around; the compiler will actually do that all for you.

Chris Howie

If you correspond with me on a regular basis, please read this document:

PGP fingerprint: 2B7A B280 8B12 21CC 260A DF65 6FCE 505A CF83 38F5


This document should be read only by those persons to whom it is
addressed.  If you have received this message it was obviously addressed
to you and therefore you can read it.

Additionally, by sending an email to ANY of my addresses or to ANY
mailing lists to which I am subscribed, whether intentionally or
accidentally, you are agreeing that I am "the intended recipient," and
that I may do whatever I wish with the contents of any message received
from you, unless a pre-existing agreement prohibits me from so doing.

This overrides any disclaimer or statement of confidentiality that may
be included on your message.

More information about the Gtk-sharp-list mailing list