Hi. I have about 30 picture boxes in my form. all pictures are the same. how can i save memory in this case? for example define a picture and bind it to all picture boxes. to increase application size and Reduce memory usage. thanks.
+4
A:
You can create a single Image
instance in your code and display the same instance in every PictureBox.
Writing a game with PictureBoxes for every sprite is an extremely bad idea.
You should draw your game by hand by handling the Paint event of a double-buffered control.
For more information, see here.
SLaks
2010-08-16 16:59:23
thanks you.i read picture from a file.how can i do it?
shaahin
2010-08-16 17:04:10
Call `new Bitmap(path)` or `Image.FromFile(path)`.
SLaks
2010-08-16 17:04:40
So.I Designed My board and NUT in photoshop and saved as PNG.i am creating Backgammon.I cant Design that nuts and board in .net .how can i optimize?what is correct way?
shaahin
2010-08-16 17:24:18
You should draw all of the PNG images manually in a single Paint event.
SLaks
2010-08-16 17:48:25