Optmizing images in Windows Forms

  • Thread starter Thread starter Nicholas Paldino [.NET/C# MVP]
  • Start date Start date
N

Nicholas Paldino [.NET/C# MVP]

Bruno,

Why not have the base class reference a static imagelist which is loaded
as needed from the resources?

Hope this helps.
 
Hi,

Everytime I use a image in a Windows Form, Visual Studio.Net creates the
image in the respective resx file. This can be very expensive in a project
with about one hundred forms, where images of delete, insert and update (for
example) appear several times.

The only way I found to optimize this is creating a Windows Form with a
ImageList with all images, and inherit every form from this one. But then I
would be loading in memory all images in every form.

Some idea?

Regards,
Bruno Rodrigues
 
Nicholas,

How can I load the images as needed? Once I referr the imagelist, he is
not loaded in the memory with all images?

Thanks
Bruno Rodrigues

Nicholas Paldino said:
Bruno,

Why not have the base class reference a static imagelist which is loaded
as needed from the resources?

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Bruno Rodrigues said:
Hi,

Everytime I use a image in a Windows Form, Visual Studio.Net creates the
image in the respective resx file. This can be very expensive in a project
with about one hundred forms, where images of delete, insert and update (for
example) appear several times.

The only way I found to optimize this is creating a Windows Form
with
a
ImageList with all images, and inherit every form from this one. But
then
I
would be loading in memory all images in every form.

Some idea?

Regards,
Bruno Rodrigues
 
Bruno,

You have two ways you can go with this. You can place all of the images
in the image list in the static constructor. The imagelist would be
publically accessible, as well as static.

The other would be to expose a method which would take the identifier
for the image. You would then check a hashtable for the identifier, to see
if it item exists. If it doesn't, then load the image from the resource
file, and store it in the hashtable. Of course, this method would be static
as well.

The imagelist solution will allow you to just bind most controls that
accept an imagelist (which can provide benefits).


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Bruno Rodrigues said:
Nicholas,

How can I load the images as needed? Once I referr the imagelist, he is
not loaded in the memory with all images?

Thanks
Bruno Rodrigues

"Nicholas Paldino [.NET/C# MVP]" <[email protected]> escreveu
na mensagem news:%[email protected]...
Bruno,

Why not have the base class reference a static imagelist which is loaded
as needed from the resources?

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Bruno Rodrigues said:
Hi,

Everytime I use a image in a Windows Form, Visual Studio.Net
creates
the
image in the respective resx file. This can be very expensive in a project
with about one hundred forms, where images of delete, insert and
update
(for
example) appear several times.

The only way I found to optimize this is creating a Windows Form
with
a
ImageList with all images, and inherit every form from this one. But
then
I
would be loading in memory all images in every form.

Some idea?

Regards,
Bruno Rodrigues
 
Back
Top