473,385 Members | 1,769 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

BackgroundImage: Slow Redraw for runtime loaded bitmaps

I have an application which configures the user interface (UI) at
runtime, meaning, the images that make up the UI are loaded based on
the current configuration when the application starts. The UI is
populated with normal controls (buttons, lists, etc.) but some controls
can load a bitmap to represent them. For instance, each button in the
window loads a bitmap as it's BackgroundImage. Also, the
BackgroundImage of each dialog is also specified so as to embed an
image as the background for the dialog. I am loading the bitmaps at
startup as follows:

this.BackgroundImage = new Bitmap(imagefile); // a
System.Windows.Forms.Form
or
this.mybutton.BackgroundImage = new Bitmap(imagefile); // a button

My problem comes when the screen is refreshed. For instance, when I
open a new dialog and then close it and return to the main window, the
main window refreshes very slowly. I am not overriding the Paint
method in the main window. The machine is also not underpowered as it
is a 3.2Ghz with 2GB of memory. The images themselves are either BMP
or GIF files and they are not large (e.g. my 800x600 window background
image is 1,407KB in BMP format and 21KB in GIF). Each window only
contains a few (~10) controls and the typical button file size is
around 3KB for the GIF files. The images are also not reloaded each
time a new dialog is opened; they are loaded only at startup.

Can someone help me improve the refresh performance under these
circumstances?

Thanks!

Nov 30 '05 #1
2 5236
raj
The problem may be that you are reloading the bitmap each time
i.e. if you have a constructor that draws the bitmap on a control
and the constructor loads them image
then everytime there is a refresh to window the control will be redrawn thus
it will call the constuctor and the constructor will reload the bitmap.

i would suggest you load the bitmaps to an array at the very first run and
save
them.

i have done this in the past

//private variable
ArrayList myList = new ArrayList();

string[] myBitmaps = new string[ {" path1.bmp", "path2.bmp"}

somefunction()
{
Bitmap b = null;
foreach(string s in myBitmaps)
{

b = new Bitmap.FromFile(s);
myList.Add(b);
}

to assign a bitmap

mypicbox.Bitmap = (Bitmap)myList[0];
hth

"jgraham" <ja***@rii.ricoh.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
I have an application which configures the user interface (UI) at
runtime, meaning, the images that make up the UI are loaded based on
the current configuration when the application starts. The UI is
populated with normal controls (buttons, lists, etc.) but some controls
can load a bitmap to represent them. For instance, each button in the
window loads a bitmap as it's BackgroundImage. Also, the
BackgroundImage of each dialog is also specified so as to embed an
image as the background for the dialog. I am loading the bitmaps at
startup as follows:

this.BackgroundImage = new Bitmap(imagefile); // a
System.Windows.Forms.Form
or
this.mybutton.BackgroundImage = new Bitmap(imagefile); // a button

My problem comes when the screen is refreshed. For instance, when I
open a new dialog and then close it and return to the main window, the
main window refreshes very slowly. I am not overriding the Paint
method in the main window. The machine is also not underpowered as it
is a 3.2Ghz with 2GB of memory. The images themselves are either BMP
or GIF files and they are not large (e.g. my 800x600 window background
image is 1,407KB in BMP format and 21KB in GIF). Each window only
contains a few (~10) controls and the typical button file size is
around 3KB for the GIF files. The images are also not reloaded each
time a new dialog is opened; they are loaded only at startup.

Can someone help me improve the refresh performance under these
circumstances?

Thanks!

Nov 30 '05 #2

raj wrote:
The problem may be that you are reloading the bitmap each time
i.e. if you have a constructor that draws the bitmap on a control
and the constructor loads them image
then everytime there is a refresh to window the control will be redrawn thus
it will call the constuctor and the constructor will reload the bitmap.

i would suggest you load the bitmaps to an array at the very first run and
save
them.


thanks for the response. however, i'm a bit confused (and i'm also new
to c# so maybe that helps explain why). i load the bitmaps in the
InitializeComponent() method which i assume is only run once, at
startup or when the object is instanciated. i understand the example
you provided, i just do not see how it differs from performing the
bitmap load when each control is created (which i assume is a one time
deal). Or, am i missing something?

jamey

Dec 1 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Ray Mitchell | last post by:
Hello, I realize this is probably a very ambiguous question but I don't know enough about the way everything works to ask it intelligently. I have a 3rd party application that can be installed...
1
by: James Dean | last post by:
In my program i create a 32ARGB bitmap. To actually create the bitmap seems very slow. In fairness the file size is very big. I support multiple bitmaps as well. I have to convert these bitmaps to...
14
by: Dino M. Buljubasic | last post by:
I would like to be able to compare BackgroundImage Property of two picture boxes on my form. How can I do that? I am using : if (pctOne.BackgroundImage Is pctTwo.BackgroundImage) then //...
1
by: kjon | last post by:
Hi, I'm trying to get the BackgroundImage of a form/control and draw it again in runtime. But if the Backgroundimage is "None", the DrawImage command will give an error. Is it possible to...
0
by: Jan Bockler | last post by:
Hi, i just want to set the backgroundimage of a datagrid @ runtime. but when i use the following code nothing happens, why? Code: DataGrid1.BackgroundImage = Image.FromFile("C:\temp\test.jpg")...
1
by: moi.romanowsky | last post by:
Does anyone know why the backgroundImage does not display in VB? I have tried setting it in the properties window (where the thumbnail shows) and explicitly in my code like so: ...
2
by: =?Utf-8?B?UmFodnlu?= | last post by:
Hi all; I have a windows desktop application in which I have set as a background image, a graphic that I whipped up. Its nothing fancey, just some gradient colors, shadows, glow, that sort of...
0
by: adstheman | last post by:
Hi all, I am maintaining a group of applications which share Access databases. In the newer version of the software products we have upgraded from DAO to ADO and also implemented routines to...
7
by: colin | last post by:
Hi, Ive written a 3dmodel editor, and it works fairly well it harldy uses any cpu exept when its loading a texture from bitmap in the debugger, at all other times it hardly uses any cpu but from...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.