2009-01-22, 01:44 AM
This is the gist of what I am trying
//class member vars
private Bitmap screenBitmap;
private GBPVRUiElement screenBitmapElement;
//in Activate, first run through
screenBitmap = new Bitmap(bWidth, bheight);
//draw on bitmap, add text, whatever
screenBitmapElement = new GBPVRUiElement("screenBitmap", startingLocationRect, screenBitmap );
//in GetRenderList()
renderList.Add(screenBitmapElement)
This all works like expected, displaying the bitmap. However, when I go to change the bitmap
private void changeBitmap()
{
using (Graphics g = Graphics.FromImage(screenBitmap)) {
//draw on it, add text, decide to move it around, whatever
}
screenBitmapElement = new GBPVRUiElement("screenBitmap", NewRect,
screenBitmap );
}
I think this bleeds memory, as I am not cleaning up the original screenBitmapElement, just pointing it to a new one.
I have tried variations along the lines of
using (Graphics g = ...
ArrayList disposeList = new ArrayList()
disposeList.Add( screenBitmapElement );
PluginHelper.DisposeResources(disposeList);
screenBitmapElement = new GBPVRUiElement("screenBitmap", NewLocationRect,
screenBitmap );
and it explodes.
How do I clean up the original
screenBitmapElement ? Do I need to?
Is there a better way of doing it?
thanks
//class member vars
private Bitmap screenBitmap;
private GBPVRUiElement screenBitmapElement;
//in Activate, first run through
screenBitmap = new Bitmap(bWidth, bheight);
//draw on bitmap, add text, whatever
screenBitmapElement = new GBPVRUiElement("screenBitmap", startingLocationRect, screenBitmap );
//in GetRenderList()
renderList.Add(screenBitmapElement)
This all works like expected, displaying the bitmap. However, when I go to change the bitmap
private void changeBitmap()
{
using (Graphics g = Graphics.FromImage(screenBitmap)) {
//draw on it, add text, decide to move it around, whatever
}
screenBitmapElement = new GBPVRUiElement("screenBitmap", NewRect,
screenBitmap );
}
I think this bleeds memory, as I am not cleaning up the original screenBitmapElement, just pointing it to a new one.
I have tried variations along the lines of
using (Graphics g = ...
ArrayList disposeList = new ArrayList()
disposeList.Add( screenBitmapElement );
PluginHelper.DisposeResources(disposeList);
screenBitmapElement = new GBPVRUiElement("screenBitmap", NewLocationRect,
screenBitmap );
and it explodes.
How do I clean up the original
screenBitmapElement ? Do I need to?
Is there a better way of doing it?
thanks