Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Graphics scaling
Graphics scaling [message #248079] Sun, 05 April 2009 07:04 Go to next message
Madhu Samuel is currently offline Madhu SamuelFriend
Messages: 199
Registered: July 2009
Senior Member
Hello group,

I created an SWT image. I put some drawing into the image. I created a
ScaledGraphics object for this swt image.

If I draw the image into the display using this ScaledGraphics object, it
draws perfectly. But if I scale down (using ScaledGraphics.scale() method)
and draw, the quality of the image is reduced.

Is there anyway this can be resolved? I had posted this into the GEF group
since I am using the ScaledGraphics object.

Regards,
Madhu


Re: Graphics scaling [message #248382 is a reply to message #248079] Fri, 17 April 2009 21:38 Go to previous messageGo to next message
Marc Gobeil is currently offline Marc GobeilFriend
Messages: 2
Registered: July 2009
Junior Member
Madhu Samuel wrote:
> Hello group,
>
> I created an SWT image. I put some drawing into the image. I created a
> ScaledGraphics object for this swt image.
> If I draw the image into the display using this ScaledGraphics object,
> it draws perfectly. But if I scale down (using ScaledGraphics.scale()
> method) and draw, the quality of the image is reduced.
> Is there anyway this can be resolved? I had posted this into the GEF
> group since I am using the ScaledGraphics object.
>
> Regards,
> Madhu
>
>

The scale() function only sets a multiplication factor for the
destination rectangle of the image when calling drawImage(), and that
target size is passed all the way down to the platform by SWT before
scaling the image actually occurs. So, I'd say it's the platform's
native scaling function that's responsible for your low image quality.
There's also ImageData.scaledTo(), but from what I can see, I wouldn't
expect any better quality out of that either.

If you really need higher image quality on-the-fly, you may want to
consider using AWT:
http://today.java.net/pub/a/today/2007/04/03/perils-of-image -getscaledinstance.html

....and then converting to SWT:
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.sni ppets/src/org/eclipse/swt/snippets/Snippet156.java?view=co

And if it doesn't need to be on-the-fly, try creating multiple
pre-scaled copies of the image with something like Photoshop or
Paint.NET that use slower high quality algorithms.

- Marc
Re: Graphics scaling [message #248394 is a reply to message #248382] Sun, 19 April 2009 02:19 Go to previous message
Madhu Samuel is currently offline Madhu SamuelFriend
Messages: 199
Registered: July 2009
Senior Member
Marc Gobeil wrote:

> Madhu Samuel wrote:
>> Hello group,
>>
>> I created an SWT image. I put some drawing into the image. I created a
>> ScaledGraphics object for this swt image.
>> If I draw the image into the display using this ScaledGraphics object,
>> it draws perfectly. But if I scale down (using ScaledGraphics.scale()
>> method) and draw, the quality of the image is reduced.
>> Is there anyway this can be resolved? I had posted this into the GEF
>> group since I am using the ScaledGraphics object.
>>
>> Regards,
>> Madhu
>>
>>

> The scale() function only sets a multiplication factor for the
> destination rectangle of the image when calling drawImage(), and that
> target size is passed all the way down to the platform by SWT before
> scaling the image actually occurs. So, I'd say it's the platform's
> native scaling function that's responsible for your low image quality.
> There's also ImageData.scaledTo(), but from what I can see, I wouldn't
> expect any better quality out of that either.

> If you really need higher image quality on-the-fly, you may want to
> consider using AWT:
>
http://today.java.net/pub/a/today/2007/04/03/perils-of-image -getscaledinstance.html

> ....and then converting to SWT:
>
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.sni ppets/src/org/eclipse/swt/snippets/Snippet156.java?view=co

> And if it doesn't need to be on-the-fly, try creating multiple
> pre-scaled copies of the image with something like Photoshop or
> Paint.NET that use slower high quality algorithms.

> - Marc

Hello Marc,

Thanks for your reply. I appreciate that.

Infact I was creating a print preview page for my GEF application. Hence I
created images of the GEF canvas based on the size of the printer paper.
This images are displayed on the preview screen and even send to the
printer. Later if the end-user wants to change the scale of the image, if
I use scaledGraphics.scale() method the image quality is reduced.

Anyway I got a workaround, when I create the image for the first time, if
I change the scale the quality will be good. That means when ever the
end-user changes the scale I have to create images with the new scale.
Even though this is a little heavy it is giving good results.

Regards,
Madhu


Previous Topic:Palette group backgound change problem
Next Topic:Question about Property Sheet
Goto Forum:
  


Current Time: Fri Apr 26 04:06:49 GMT 2024

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

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

Back to the top