Graphics scaling [message #248079] |
Sun, 05 April 2009 03:04  |
Eclipse User |
|
|
|
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 17:38   |
Eclipse User |
|
|
|
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] |
Sat, 18 April 2009 22:19  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.47714 seconds