Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Xwt.Context.DrawImage prevents further painting (GTK backend) #12

Closed
luiscubal opened this issue Feb 14, 2012 · 2 comments
Closed

Xwt.Context.DrawImage prevents further painting (GTK backend) #12

luiscubal opened this issue Feb 14, 2012 · 2 comments

Comments

@luiscubal
Copy link
Contributor

Attempting to e.g. fill a rectangle after DrawImage has no effect.
However, surrounding the DrawImage call with ctx.Save() and ctx.Restore() seems to solve the problem.

I believe this a GTK+ backend bug. Save()/Restore() should be called automatically within DrawImage.

@luiscubal
Copy link
Contributor Author

The following code reproduces the issue on my Linux Ubuntu system.

using System;
using Xwt;
using Xwt.Drawing;

namespace BugTest
{
    public class Program : Xwt.Canvas
    {
        public static void Main() {
            Application.Initialize();

            var win = new Window();
            win.Size = new Size(200, 200);
            win.Content = new Program();
            win.Show();

            Application.Run();
        }

        private Image myImage;

        public Program() {
            myImage = Image.FromFile("foo.png");

            Show();
        }

        protected override void OnDraw (Context ctx)
        {
            base.OnDraw (ctx);

            ctx.SetColor(Color.Black);
            ctx.Rectangle(new Rectangle(0, 0, 100, 100));
            ctx.Fill();

            //ctx.Save();
            ctx.DrawImage(myImage, new Point(0, 0));
            //ctx.Restore();

            //ctx.SetColor(Color.Black);
            ctx.Rectangle(new Rectangle(64, 64, 32, 32));
            ctx.Fill();
        }
    }
}

The weird part is that, just like Save()/Restore() can be used to fix the issue. Uncommenting the second SetColor call also fixes the problem.

@luiscubal
Copy link
Contributor Author

Seems to be fixed now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant