Scale quality of Canvas control

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 X’s Preview (OS X is my main OS).

Forgot to mention… I’m developing on Windows (screenshots from Windows), but this particular program will be deployed on OS X, Windows and Linux.

If there is no easy workarounds, then I’ll report this in the Feedback system.

Please do so, you’ll have my support. I use MacOSLib’s 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 I’m 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.

BTW: Would it be a workaround to have an invisible html viewer do the scaling and forward the picture to a canvas?

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.

Do you have an MBS license? I’m sure Christian has a better algorithm than Xojo. Also, I remember a graphics library (“ImagePlay” ?).

I have The G.I.M.P., but I never tried to resize (scaled down) an image. Someone ?

Thanks for the hint, Beatrix!
Here it is:ImagePlay Library

Seems to work even with Illustrator images. I haven’t checked the scale function yet, but seeing that it can handle vector graphics makes it very probable this will do.

Yes, thanks Beatrix. Will look into your suggestions.

GIMP is a great tool, I use it all the time.

The GIMP is fine, but on PC I prefer Paint.NET which is freeware, and by many aspects almost as powerful as PhotoShop Elements.

I just make ONE try: works fine (it seems).

The G.I.M.P. is free too.

I’m downloadin Paint.NET and try to test it in the afternoon.

The old AppleWorks Paint module (Mac OS / Windows 32) was enough for most of my needs (not resizing).

I was fluent with PhotoShop (1.5.2 ?), but “It Was 20 Years Ago…”

[quote=66340:@Emile Schwarz]I was fluent with PhotoShop (1.5.2 ?), but “It Was 20 Years Ago…”

[/quote]

Paint. NET should make you right at home :slight_smile:

Just downloaded the shareware app built with the ImagePlay library. Scaling works great! So in case you don’t use GIMP or something, this library (or the shareware app) will do.

Where did you download it ?

Until Xojo update the resize code.

@Michel Bujardet: here: ImagePlay shareware app

Thanks.