Board index » delphi » Best way to manage GDI rsources with app that needs graphics

Best way to manage GDI rsources with app that needs graphics

I've got an app that has a form with LOTS of TImage's on that hold BMPs &
ICOs
(About 192 TImages with ICOs (32x32,16 cols) & around 30 other TImages with
BMPs (no bigger than 64x64, 16cols))

Another form referrs to this to dynamically change images on the fly, with
one from that form above.

PROBLEM: The app requires about 36% GDI resources (Pete's CrashGuard told me
so!), which although not massive, is quite a bit for what the app actually
is (a GDI monitoring program (no only kidding about that!!!:-)))

QUESTION: What's the best way to store the images for use on the fly liek
this?  I could use loadfromfile etc but 1. The source graphic files may be
deleted, but this is also a fair bit slower (until they're in the cache).

Is there a way to store an array of TImage's?

How?

And with the array, how do I initially get the graphics loaded into them?

Many thanks

Geraint Letherby
PS. Does Intel VTune work with D4?

 

Re:Best way to manage GDI rsources with app that needs graphics


Im Artikel <7ee850$m7...@infoserv.netkonect.net>, "Geraint Letherby"
<gera...@micromount.com> schreibt:

Quote
>And with the array, how do I initially get the graphics loaded into them?

Perhaps you shouldn't have all graphics loaded all the time? Resources of 32
bit programs are part of the memory adress space, and should not require much
time when a resource is accessed. IMO TImages are OLE components, with a
considerable overhead. Try to use simpler components, like arrays of bitmaps.

Another solution might be combined bitmaps, that are stored as a single bitmap
in memory, and are BitBlt'ed when needed. But I'm not yet familiar with Delphi,
so I don't know what components are appropriate in any case.

DoDi

Re:Best way to manage GDI rsources with app that needs graphics


Yup, I knew how do do a component array with VB but haven't learned with
Delphi yet!

Thanks anyway.
GL

Re:Best way to manage GDI rsources with app that needs graphics


Im Artikel <7eirii$he...@infoserv.netkonect.net>, "Geraint Letherby"
<gera...@micromount.com> schreibt:

Quote
>Yup, I knew how do do a component array with VB but haven't learned with
>Delphi yet!

Delphi allows to share event procedures for all components. This approach is
more flexible than the control arrays in VB, since the same code can be used
for components of different classes, and you can select a common or private
event handler for any single event of any single component.

When you have created multiple components on a form, you can create a new event
handler with a double click into the events name field in the Object Inspector,
or select an existing event handler from the drop down list in the same field.
Perhaps it's possible to select multiple components, and then set their event
handlers all at once, similar to setting properties of multiple controls in VB?

DoDi

Re:Best way to manage GDI rsources with app that needs graphics


Yup,

I know and use that too!!

But I don't know a way to specify different bitmaps for the same timage
(without using loadfromfile as specified in original post)

Thanks, I guess it'll just have to use 30+% of GDI !  ;-/

GL

Re:Best way to manage GDI rsources with app that needs graphics


Quote
Geraint Letherby wrote in message <7ee850$m7...@infoserv.netkonect.net>...
>I've got an app that has a form with LOTS of TImage's on that hold BMPs &
>ICOs
>(About 192 TImages with ICOs (32x32,16 cols) & around 30 other TImages with
>BMPs (no bigger than 64x64, 16cols))

>Another form referrs to this to dynamically change images on the fly, with
>one from that form above.

>PROBLEM: The app requires about 36% GDI resources (Pete's CrashGuard told
me
>so!), which although not massive, is quite a bit for what the app actually
>is (a GDI monitoring program (no only kidding about that!!!:-)))

>QUESTION: What's the best way to store the images for use on the fly liek
>this?  I could use loadfromfile etc but 1. The source graphic files may be
>deleted, but this is also a fair bit slower (until they're in the cache).

>Is there a way to store an array of TImage's?

It is possible to declare an array of TImage, but this
isn't going to help you. Perhaps try compiling the
bitmaps into .res files (brcc32.exe), and linking them
into your application. You then use the LoadImage
API call to retrieve them at runtime.

As for speed, perhaps you could invent some simple
caching scheme - perhaps load (say) three bitmaps
at a time before they are needed, so that they are ready
in memory.

HTH
--
Jeremy Collins
Kansai Business Systems
http://www.kansai.co.uk/

Other Threads