trying to get my head around a glide question. Maybe I’m too tired at the moment to nut it out so I’m going to post here and then sleep on it - either way Friday morning should see me with at least one answer
I have a number of direct bitmaps in my app, as resources. On my glide pane I have image object(s). I want to load the bitmap into the glide image - in the simplest case I have a single bitmap that will always be put to one image on the window, so I want to do that as simply as possible without duplicating objects in memory. In at least one other case I will need to swap images out occasionally (swap A with B and sometime back to A) so I’ll likely load both bitmaps from resources at the get-go and swap as needed. BUT, I actually have no idea how to start? Quick and dirty code snippets, or pointers on searches, or even more fishing instructions greatly appreciated
I do this all the time. I preload the bitmaps as I found that loading from the resources each time you want to update the display takes time. I do this for things like the status LED’s in the attached image which get updated every 0.5 seconds.
You need to reload them each time though that you create the page they will be used on. If you destroy that page the bitmaps will be destroyed too. I destroy the current window and the create the new window on the fly as I have about 30 in this current app and loading them all at the same time runs out of memory. So in this case, I call a function that loads all the bitmaps for that screen. This works well and this system has been running on permanent test for 2 months solid now with no failures.
Here is an example.
static void InitBitmaps()
{
gprs0 = new Bitmap(Resources.GetBytes(Resources.BinaryResources.gprs0), Bitmap.BitmapImageType.Jpeg);
gprs1 = new Bitmap(Resources.GetBytes(Resources.BinaryResources.gprs1), Bitmap.BitmapImageType.Jpeg);
gprs2 = new Bitmap(Resources.GetBytes(Resources.BinaryResources.gprs2), Bitmap.BitmapImageType.Jpeg);
gprs3 = new Bitmap(Resources.GetBytes(Resources.BinaryResources.gprs3), Bitmap.BitmapImageType.Jpeg);
gprs4 = new Bitmap(Resources.GetBytes(Resources.BinaryResources.gprs4), Bitmap.BitmapImageType.Jpeg);
}
Then to use them, simply do this.
switch (gsmModemClass.GSMstate.gsmState)
{
case 0:
gprsState.Bitmap = gprs0;
break;
case 1:
gprsState.Bitmap = gprs1;
break;
case 2:
gprsState.Bitmap = gprs2;
break;
case 3:
gprsState.Bitmap = gprs3;
break;
case 4:
gprsState.Bitmap = gprs4;
break;
case 6:
gprsState.Bitmap = gprs4; // GPRS
break;
}