HighTechTalks DotNet Forums  

background images slow

Dotnet Framework (Performance) microsoft.public.dotnet.framework.performance


Discuss background images slow in the Dotnet Framework (Performance) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Andreas van de Sand
 
Posts: n/a

Default background images slow - 10-15-2004 , 01:23 AM






Hi all,

I'm working on an application and want to use background images for forms
and controls. Using the images itself is not a problem, but when I run my
application it becomes really slow and my CPU usage goes up to 100% for a
time...
Is there a better way of setting background images?
It's just 3 images I think, all pretty small, and I already created the
objects for the images and set them to the controls at runtime so that it
uses only 3 objects and not new instances for every control.
But still...
It can't be that hard just to show a couple of images...?

Many thanks for your help...
Andreas

Reply With Quote
  #2  
Old   
Lloyd Dupont
 
Posts: n/a

Default Re: background images slow - 10-17-2004 , 10:16 PM






Quote:
It can't be that hard just to show a couple of images...?
I think it is....
GDI is pretty prehistoric in some ways....
It's why background image are so uncommon, prefer tghe background color
property...
or wait for longhorn ;-)

Quote:
Many thanks for your help...
Andreas



Reply With Quote
  #3  
Old   
Andreas van de Sand
 
Posts: n/a

Default Re: background images slow - 10-18-2004 , 12:04 AM



Quote:
It's why background image are so uncommon, prefer tghe background color
property...
Well it looks like this is my only option, because I don't want my program
to look so slow, just because of a simple background image... wanted to have
a simple multi colour bg as in office 2003... do you happen to know if
there's a way to have multiple colours with a transition as background?

Thanks,
Andreas




Reply With Quote
  #4  
Old   
Cablito
 
Posts: n/a

Default Re: background images slow - 10-18-2004 , 12:41 PM



use the gdi drawing gradient. If thats not good enough in performance, drop
..net and write MFC c++ code


"Andreas van de Sand" <andy206 (AT) aanet (DOT) com.au> escreveu na mensagem
news:%234tJz$MtEHA.3200 (AT) TK2MSFTNGP14 (DOT) phx.gbl...
Quote:
It's why background image are so uncommon, prefer tghe background color
property...

Well it looks like this is my only option, because I don't want my program
to look so slow, just because of a simple background image... wanted to
have
a simple multi colour bg as in office 2003... do you happen to know if
there's a way to have multiple colours with a transition as background?

Thanks,
Andreas





Reply With Quote
  #5  
Old   
Jay B. Harlow [MVP - Outlook]
 
Posts: n/a

Default Re: background images slow - 10-18-2004 , 06:19 PM



Andreas,
I've used the following In my Forms in both VS.NET 2002 & VS.NET 2003
without any real performance problems...

Protected Overrides Sub OnResize(ByVal e As System.EventArgs)
MyBase.OnResize(e)

If Not Me.BackgroundImage Is Nothing Then
Me.BackgroundImage.Dispose()
Me.BackgroundImage = Nothing
End If
Dim image As New Bitmap(Me.ClientSize.Width, Me.ClientSize.Height)
Dim gr As Graphics = Graphics.FromImage(image)
Dim rect As New Rectangle(New Point(0, 0), Me.ClientSize)

Dim brush As New LinearGradientBrush(rect, _
Color.RosyBrown, ControlPaint.LightLight(Color.RosyBrown), _
LinearGradientMode.Vertical)
brush.SetBlendTriangularShape(0.33)
gr.FillRectangle(brush, rect)
gr.Dispose()

Me.BackgroundImage = image
End Sub

The image is always the same size as the form, so there is no tiling going
on.

Just set the BackColor of controls that support it to Transparent, they will
then pick up the colors from the above Image.

Hope this helps
Jay

"Andreas van de Sand" <andy206 (AT) aanet (DOT) com.au> wrote

Quote:
It's why background image are so uncommon, prefer tghe background color
property...

Well it looks like this is my only option, because I don't want my program
to look so slow, just because of a simple background image... wanted to
have a simple multi colour bg as in office 2003... do you happen to know
if there's a way to have multiple colours with a transition as background?

Thanks,
Andreas




Reply With Quote
  #6  
Old   
Andreas van de Sand
 
Posts: n/a

Default Re: background images slow - 10-19-2004 , 02:01 AM



Quote:
I've used the following In my Forms in both VS.NET 2002 & VS.NET 2003
without any real performance problems...
Thanks Jay, tried this, and at least it's better. Still slow, but not as bad
as with an image.
Thanks very much for your help everyone!
Andreas




Reply With Quote
  #7  
Old   
Jay B. Harlow [MVP - Outlook]
 
Posts: n/a

Default Re: background images slow - 10-19-2004 , 09:12 AM



Andreas,
Only the form itself should have the background image.

All your controls should have BackColor = Transparent.

Can you define "slow", when is it "slow" specifically.

Can you post a 20-25 line program (or email me) that accurately shows that
it is slow?

As using the above routine, the only time it is even close to "slow" is when
you resize the form itself. Even then on a 866 PIII, I don't really notice
it as being slower then normal (it flickers slightly, but that's about it).

Hope this helps
Jay



"Andreas van de Sand" <andy206 (AT) aanet (DOT) com.au> wrote

Quote:
I've used the following In my Forms in both VS.NET 2002 & VS.NET 2003
without any real performance problems...

Thanks Jay, tried this, and at least it's better. Still slow, but not as
bad as with an image.
Thanks very much for your help everyone!
Andreas




Reply With Quote
  #8  
Old   
Andreas van de Sand
 
Posts: n/a

Default Re: background images slow - 10-19-2004 , 10:41 PM



Jay,

Quote:
Only the form itself should have the background image.

All your controls should have BackColor = Transparent.
yes, that's what it is.

Quote:
Can you define "slow", when is it "slow" specifically.
it's slow when I'm showing a panel which contains 3 listBox controls with
splitters in between and another (transparent) panel.
I'm setting the DockingState of the panel to Fill at runtime and change the
visibility of the panel to visible.
And that's what takes time... not the backgroundimage itself, just the
(automatic) resizing of the controls (according to their Fill state). You
see them appearing and resizing, one by one.
But it's really better now than before with an image from a file.
So again, many thanks!
Andreas




Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.