473,692 Members | 2,105 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Background Image = new Bitmap(imagefil e); // a
System.Windows. Forms.Form
or
this.mybutton.B ackgroundImage = new Bitmap(imagefil e); // 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 5258
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.rico h.com> wrote in message
news:11******** **************@ o13g2000cwo.goo glegroups.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.Background Image = new Bitmap(imagefil e); // a
System.Windows. Forms.Form
or
this.mybutton.B ackgroundImage = new Bitmap(imagefil e); // 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
InitializeCompo nent() 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
1677
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 as a control. It's purpose is to provide generic x-y coordinate 2D line graphs. It's actually really a neat and versatile application. I have a dialog that has 8 of these graphs on it. Whenever I drag another window over it, then drag it...
1
2614
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 thumbnails also which again seems very slow. There is a memory bitmap but i can't seem to find any good information about it. I want to be able to create a 32bpp bitmap as fast as possible and also try to make a thumbnail as fast as possible too....
14
10001
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 // blah, blah, blah end if
1
323
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 programmaticaly check the Backgroundimage property of the form/control in runtime whether it is "None" or has an image inside? Please advice. Thanks in advance. Regards, KJon
0
1088
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") For example setting the backgroundimage of the main form works fine. Greets,
1
2200
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: Me.BackgroundImage = WindowsApplication1.My.Resources.Resources.Chile Nevertheless, nothing happens. Incidentally, setting the BackColor works just fine, such as: Me.BackColor = Color.Blue
2
2827
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 stuff. I have tried different formats, jpg, png, gif, bmp, and with every one, when the application starts, and when I focus to a different window, then come back to the main one, it seems to redraw the screen slowly. Each control will flash on the...
0
1325
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 upgrade the databases from Access 97 to Access 2000. However, bitmaps stored in the Access 97 databases when retrieved into a recordset using the older versions of our software (that used DAO) were accessed at a good speed. However, in the newer...
7
2099
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 the debugger even in release mode it takes a second or so to load a 65k texture, with a 2ghz pc this is 10k instructions per pixel ! I cant understand what its doing here, can anyone shed any light on this ? I have the d3d debug turned off...
0
8600
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8535
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9079
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8954
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8796
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7626
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4555
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2968
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2234
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.