tags:

views:

74

answers:

2

I have a program that draws some vector graphics using System.Drawing and the Graphics class. The anti-aliasing works, kindof okay, but for my need I neede oversampling, so I create the starting image to be n times larger and then scale back the final image by n. On Window and .NET the resulting image looks great! However, on Mono 2.4.2.3 (Ubuntu 9.10 stock install), the intropolation is horrible. Here's how I'm scaling my images:

Bitmap bmp = new Bitmap(Bmp.Width / OverSampling, Bmp.Height / OverSampling);
Graphics g = Graphics.FromImage(bmp);
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
g.DrawImage(Bmp, 0, 0, bmp.Width, bmp.Height);
g.Dispose();

From what I can tell there is no interpolation happening at all. Any ideas?

A: 

Well I found this: http://www.mail-archive.com/[email protected]/msg18099.html

I guess the underlying code of Mono's drawing routines are at fault. YAY! Now I get to write my own downscaler.

Timothy Baldridge
Hi Timothy. Just wondering if you ever came up with a good solution to this. Facing the same thing here :(
cantabilesoftware
Unfortunately no....it's a issue that goes very deep into the Linux code. Basically Mono's System.Drawing is based on Cairo which in turn is based on Pixman. The issue is in Pixman. I took a look at the Pixman code, and it would take some doing. The code is extremely flexible and therefore quite complex. Baiscaly what you're looking for is bilinear filtering in pixman. And as far as I know it doesn't exist. And if it gets added you'll manually have to recompile pixman to get the features. Either that or wait for a new distro release.
Timothy Baldridge
To be honest I ended up going with PySide and Python. And that's been great so far.
Timothy Baldridge
That's a real pity. The site I'm working on has been developed under .net. Spent about an hour getting running under mono - everything works perfectly except this one little quirk. Oh well. Thanks anyway.
cantabilesoftware