Advice

  • Thread starter Thread starter Crirus
  • Start date Start date
C

Crirus

Do you think is a bad practice to declare graphics and bitmaps as globals in
an app in order to avoid dealocation if this is a speed issue?
I have to draw lots of small tiles that eventualy are drawed on a big buffer
bitmap that is painted on screen.
So each new tile require a tmp bitmap and a graphics, because I render that
tiles from multiple images
I was thinking on using the same bitmap and graphics to draw all tiles...
 
Hi Crirus,

This sounds as a classic style of programming. Nevertheless, what is the
difference when you place them in a shared class?

I think that I could not resist doing the last if it would give me some more
performance.

However, to get the ability to free memory I would in this case add a
dispose function to the class for the graphic maps.

Cor
 
* "Crirus said:
Do you think is a bad practice to declare graphics and bitmaps as globals in
an app in order to avoid dealocation if this is a speed issue?

This depends on the case.
I have to draw lots of small tiles that eventualy are drawed on a big buffer
bitmap that is painted on screen.
So each new tile require a tmp bitmap and a graphics, because I render that
tiles from multiple images
I was thinking on using the same bitmap and graphics to draw all tiles...

If it's a complex bitmap, it makes sense to store it for future use...
 
I would use a class with some shared (static) members too. This is the
"replacement" of global variables in the .NET world. I even think that if
you use Modules, they become compiled as classes with shared members behind
the scene.
 
Well, actually I havea control that deal with this drawings so I dont need
any other class, I only was wandering if is ok to make them globals
 
Ohh, by making globals I meant make it class members instead function
variables... not global as VB6 use it... my mistake

The ideea is that I have a function called to create each tile.. in that
function I use a temp bitmap and graphics to create a tile that is painted
in main buffer
So, I'm wandering if I should use that bitmap and graphics in the function
scope or declare them as Uprivate members and only use them in the function
 
Back
Top