Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » GC.drawImage to shrink does not look good on Windows
GC.drawImage to shrink does not look good on Windows [message #467342] Sun, 29 January 2006 16:20 Go to next message
Barry Andrews is currently offline Barry AndrewsFriend
Messages: 27
Registered: July 2009
Junior Member
Hi All,

I use GC.drawImage to shrink an image on the canvas. When I shrink to
50% or greater the image quality is very poor, text is not readable,
broken segments, etc. This only happens on Windows! On Linux, it looks
great. I can shrink the image as small as I want as it still looks good.
Is this a bug in SWT or is there something I can do to make it look
better on Windows?

many thanks,

Barry
Re: GC.drawImage to shrink does not look good on Windows [message #467345 is a reply to message #467342] Sun, 29 January 2006 17:40 Go to previous messageGo to next message
Alex Blewitt is currently offline Alex BlewittFriend
Messages: 946
Registered: July 2009
Senior Member
What you're describing sounds like anti-aliasing (or lack thereof). I don't know if Windows does anti-aliasing by default when changing image sizes; by the sounds of things, your graphics card isn't doing that.

I suspect the only way around this would be to perform the image shrinking yourself (by implementing your own anti-aliasing mechanism), and then draw it with a 1-1 image size via the Windows API.

The image resizing is a function of the graphics card and driver on your Windows system, so a different graphics card (or different driver settings) may have an effect. 3D graphics cards, for example, often have various anti-aliasing effects which affect how they perform.

If you want to use different sizes, then it might be worth preparing different image sizes in advance; for example, there's a bunch of 32x32 and 16x16 icons that are used at different sizes instead of doing on-the-fly conversion. Also, dropping size by exactly 1/2 sometimes has benefits (since it can use a different anti-aliasing mechanism).

Have a look at the images in Internet Explorer, with a simple IMG="src.gif" width="32" height="32" type tag, and then change it to a different size (e.g. width="30" height="30"). You'll almost certainly see the same pixelation that you see with Eclipse. However, on other operating systems (Mac,Linux etc.) you will probably see a better anti-aliasing of the image in question (and maybe even for Firefox too, since it probably implements its own routine).

For more information, search wikipedia for anti-aliasing if you want to knnow more.

Alex.
Re: GC.drawImage to shrink does not look good on Windows [message #467349 is a reply to message #467345] Mon, 30 January 2006 00:50 Go to previous messageGo to next message
Barry Andrews is currently offline Barry AndrewsFriend
Messages: 27
Registered: July 2009
Junior Member
Thanks Alex! I fixed the problem with setAntialias() and
setTextAntialias()

Still doesn't look quite as good as it does on Linux but it's a huge
improvement.

-Barry


Alex Blewitt wrote:
> What you're describing sounds like anti-aliasing (or lack thereof). I don't know if Windows does anti-aliasing by default when changing image sizes; by the sounds of things, your graphics card isn't doing that.
>
> I suspect the only way around this would be to perform the image shrinking yourself (by implementing your own anti-aliasing mechanism), and then draw it with a 1-1 image size via the Windows API.
>
> The image resizing is a function of the graphics card and driver on your Windows system, so a different graphics card (or different driver settings) may have an effect. 3D graphics cards, for example, often have various anti-aliasing effects which affect how they perform.
>
> If you want to use different sizes, then it might be worth preparing different image sizes in advance; for example, there's a bunch of 32x32 and 16x16 icons that are used at different sizes instead of doing on-the-fly conversion. Also, dropping size by exactly 1/2 sometimes has benefits (since it can use a different anti-aliasing mechanism).
>
> Have a look at the images in Internet Explorer, with a simple IMG="src.gif" width="32" height="32" type tag, and then change it to a different size (e.g. width="30" height="30"). You'll almost certainly see the same pixelation that you see with Eclipse. However, on other operating systems (Mac,Linux etc.) you will probably see a better anti-aliasing of the image in question (and maybe even for Firefox too, since it probably implements its own routine).
>
> For more information, search wikipedia for anti-aliasing if you want to knnow more.
>
> Alex.
Re: GC.drawImage to shrink does not look good on Windows [message #467446 is a reply to message #467349] Tue, 31 January 2006 16:21 Go to previous messageGo to next message
Adrian Yiu is currently offline Adrian YiuFriend
Messages: 1
Registered: July 2009
Junior Member
You may also try setInterpolation(SWT.HIGH) and see whether it can improve
further in windows.

Adrian
Re: GC.drawImage to shrink does not look good on Windows [message #467490 is a reply to message #467446] Wed, 01 February 2006 00:37 Go to previous message
Barry Andrews is currently offline Barry AndrewsFriend
Messages: 27
Registered: July 2009
Junior Member
Yes, that does help with images that are shrunk by say 50% or more. But
the closer the new image's size is to the original ( less shrinkage ),
the worse the image looks. ( It starts getting blurry. ) So based on my
initial tests, I would say if you are shrinking the image a lot then use
it, otherwise don't because it will actually make the image look worse.
I did not try this on Linux.

Thanks for the hint!

-Barry

Adrian Yiu wrote:
> You may also try setInterpolation(SWT.HIGH) and see whether it can
> improve further in windows.
>
> Adrian
>
Previous Topic:Obscured Widget?
Next Topic:swt_awt bridge
Goto Forum:
  


Current Time: Sat Apr 20 04:26:45 GMT 2024

Powered by FUDForum. Page generated in 0.02849 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top