Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Performance Tipps for gc.drawImage() ?
Performance Tipps for gc.drawImage() ? [message #466725] |
Mon, 16 January 2006 20:48  |
Eclipse User |
|
|
|
Originally posted by: yen-chia.lin.liwest.at
Hi,
I have a question.
How can i improve the performance from my SWT Shell with just a Canvas
in it?
I want to draw a image as Background Image for the window and then draw
some Text on it.
it looks like this:
public void paintControl(org.eclipse.swt.events.PaintEvent e) {
gc = e.gc;
gc.setFont(fontSWT);
gc.drawImage(backgroundImage, startingX, startingY);
.....
gc.drawText(text, x, y, true);
gc.drawText(text, x2, y2, true);
gc.drawText(text, x3, y3, true);
}
Thats it!
The size of the Shell and BackgroundImage are fix. They are NOT
resizable. And the backgroundImage is a *.png file.
So how can i set/draw a background image that is faster than the above
methods? ^^
tia,
Yen-chia
|
|
|
Re: Performance Tipps for gc.drawImage() ? [message #466805 is a reply to message #466725] |
Tue, 17 January 2006 14:39   |
Eclipse User |
|
|
|
You can't. Please enter a bug report with the image and a stand alone
snippet so we can investigate. Thanks!
"Lin Yen-Chia" <yen-chia.lin@liwest.at> wrote in message
news:dqhi0c$4qf$1@utils.eclipse.org...
> Hi,
>
> I have a question.
>
> How can i improve the performance from my SWT Shell with just a Canvas
> in it?
>
> I want to draw a image as Background Image for the window and then draw
> some Text on it.
>
> it looks like this:
>
> public void paintControl(org.eclipse.swt.events.PaintEvent e) {
> gc = e.gc;
> gc.setFont(fontSWT);
> gc.drawImage(backgroundImage, startingX, startingY);
> .....
> gc.drawText(text, x, y, true);
> gc.drawText(text, x2, y2, true);
> gc.drawText(text, x3, y3, true);
> }
>
> Thats it!
>
> The size of the Shell and BackgroundImage are fix. They are NOT
> resizable. And the backgroundImage is a *.png file.
>
> So how can i set/draw a background image that is faster than the above
> methods? ^^
>
> tia,
>
> Yen-chia
|
|
| | |
Re: Performance Tipps for gc.drawImage() ? [message #466895 is a reply to message #466725] |
Wed, 18 January 2006 19:56   |
Eclipse User |
|
|
|
Lin Yen-Chia wrote:
> Hi,
> I have a question.
> How can i improve the performance from my SWT Shell with just a Canvas
> in it?
> I want to draw a image as Background Image for the window and then draw
> some Text on it.
> it looks like this:
> public void paintControl(org.eclipse.swt.events.PaintEvent e) {
> gc = e.gc;
> gc.setFont(fontSWT);
> gc.drawImage(backgroundImage, startingX, startingY);
> .....
> gc.drawText(text, x, y, true);
> gc.drawText(text, x2, y2, true);
> gc.drawText(text, x3, y3, true);
> }
> Thats it!
> The size of the Shell and BackgroundImage are fix. They are NOT
> resizable. And the backgroundImage is a *.png file.
> So how can i set/draw a background image that is faster than the above
> methods? ^^
> tia,
> Yen-chiaHi Yen-Chia,
I think I've run into something similar to this. What I did was to keep
track of some state of the canvas. only draw the background image once,
and then draw text and lines over the top of it.. but do not invalidate
it. however, when the text changes, that area of the canvas will need to
be redrawn. Try to figure out which area is "dirty" and then only repaint
your image in that region instead of the entire canvas.
I'm still a little new with SWT, so I hope that helps a bit..but I may be
way off.
Best Regards,
Adam
|
|
|
Re: Performance Tipps for gc.drawImage() ? [message #466897 is a reply to message #466895] |
Wed, 18 January 2006 21:14  |
Eclipse User |
|
|
|
Adam Kumpf wrote:
> Lin Yen-Chia wrote:
>> Hi,
>> I have a question.
>> How can i improve the performance from my SWT Shell with just a Canvas
>> in it?
>> I want to draw a image as Background Image for the window and then draw
>> some Text on it.
>> it looks like this:
>> public void paintControl(org.eclipse.swt.events.PaintEvent e) {
>> gc = e.gc;
>> gc.setFont(fontSWT);
>> gc.drawImage(backgroundImage, startingX, startingY);
>> .....
>> gc.drawText(text, x, y, true);
>> gc.drawText(text, x2, y2, true);
>> gc.drawText(text, x3, y3, true);
>> }
>> Thats it!
>> The size of the Shell and BackgroundImage are fix. They are NOT
>> resizable. And the backgroundImage is a *.png file.
>> So how can i set/draw a background image that is faster than the above
>> methods? ^^
>> tia,
>> Yen-chiaHi Yen-Chia,
> I think I've run into something similar to this. What I did was to keep
> track of some state of the canvas. only draw the background image once,
> and then draw text and lines over the top of it.. but do not invalidate
> it. however, when the text changes, that area of the canvas will need to
> be redrawn. Try to figure out which area is "dirty" and then only repaint
> your image in that region instead of the entire canvas.
> I'm still a little new with SWT, so I hope that helps a bit..but I may be
> way off.
> Best Regards,
> Adamoh, a couple more suggestions while I'm thinking about it...
I found that setting the GC to "Advanced" before you draw the background
image really slows things down a lot! (Advanced turns on Anti-aliasing,
and some other stuff too).
I also found that loading the image from the file is quite expensive in
terms of time. Make sure you only load the image from the file once, then
re-use that image when you need to redraw.
hope that helps a bit.
Best Regards,
Adam
kumpf@mit.edu
|
|
|
Goto Forum:
Current Time: Wed Jul 23 02:23:21 EDT 2025
Powered by FUDForum. Page generated in 0.05970 seconds
|