Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Performance Tipps for gc.drawImage() ?
Performance Tipps for gc.drawImage() ? [message #466725] |
Tue, 17 January 2006 01: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 19:39 |
Steve Northover Messages: 1636 Registered: July 2009 |
Senior Member |
|
|
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 #466810 is a reply to message #466805] |
Tue, 17 January 2006 20:24 |
Eclipse User |
|
|
|
Originally posted by: yen-chia.lin.liwest.at
Steve Northover schrieb:
> You can't. Please enter a bug report with the image and a stand alone
> snippet so we can investigate. Thanks!
>
is there no way to draw a image in doublebuffered or something like that?
because my image is not going to change. the text is the only thing that
will change in the time.
|
|
| |
Re: Performance Tipps for gc.drawImage() ? [message #466895 is a reply to message #466725] |
Thu, 19 January 2006 00:56 |
Adam Kumpf Messages: 14 Registered: July 2009 |
Junior Member |
|
|
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] |
Thu, 19 January 2006 02:14 |
Adam Kumpf Messages: 14 Registered: July 2009 |
Junior Member |
|
|
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: Sun Dec 08 10:16:42 GMT 2024
Powered by FUDForum. Page generated in 0.04581 seconds
|