I was wondering if anyone perhaps knows of a workaround to improve the scale (stretch) quality when drawing images with the Canvas control.
Here is the code snippet I use to scale a picture with…
Sub Paint(g As Graphics, areas() As REALbasic.Rect)
g.DrawPicture myPicture, 0, 0, customXWidth, customYWidth, 0, 0, myPicture.Width, myPicture.Height
End Sub
…and here is a screenshot of the same image scaled (shrinked) with the Canvas control AND the HTMLViewer (Webkit) control. The difference in quality is very noticeable and I’m trying to achieve the same quality that the HTMLViewer renders with in the Canvas control.
Any suggestions are welcome, since I’ve already tried everything I could think of (enabling anti-aliasing, enabling GDI-plus, rendering with Object2D…).
If there is no workaround, then I’ll submit a feedback ticket.
I never had a chance to report it, you are right, scaling down images (depending on its contents) produce a bad result.
I get worst results with an image representing a data base card (so there are lines: vertical / horizontal, text in two different sizes, and surrounding rectangle).
Even the built in resize of Icons in the IDE is not good (compared to Preview).
Sometimes bug reports are lost in the hard disk hierarchy, unfortnately.
I get far better results using OS Xs Preview (OS X is my main OS).
Please do so, youll have my support. I use MacOSLibs NSCanvas/imagewell control for application buttons and, thinking of preparing the app to work on Retina screens, import bigger PNGs which I scale down. The scaling method gives such bad results that Im afraid I have to do different images in 100% for both screens though. Would be very helpful to have this feature handled with anti-aliasing and all those nifty features that the HTML viewer seems to have.
On the other hand, it would be great to handle vector images (EPS, PDF) the same easy way as the picture class.
This is striking indeed. If you can know in advance the size of the canvas, it seems worth it to do the shrinking outside of Xojo in Photoshop or Paint.NET to get the antialiasing. That is what I do. It’s not exactly an easy workaround, but the result is much nicer.
Lifting the picture from WebViewer would be nice as well, but the background does not seem transparent…
Absolutely. Support for SVG is #3 in my top cases in the feedback. I started implementing a SVG renderer, and soon realized it is not a trivial task.
Hmmm, not sure. Will have to look into this, but I still would prefer to do the scaling directly with the Canvas control if possible.
Nice suggestion, and definitely something I’ll keep in mind. Unfortunately in this instance I don’t know the resolutions beforehand, and the scaling needs to take place in real-time.
Seems to work even with Illustrator images. I havent checked the scale function yet, but seeing that it can handle vector graphics makes it very probable this will do.
Just downloaded the shareware app built with the ImagePlay library. Scaling works great! So in case you dont use GIMP or something, this library (or the shareware app) will do.