Generate multiple Bitmaps in memory
-
Hey Howzit? As you can see in the code below I am generating a Bitmap and saving it to disk, later in my program I display this .tiff file as the backgroundimage of a Panel. My question to you is, how can I generate multiple Bitmaps IN MEMORY (instead of saving to disk) and then display them later when I need to? Thanks using (Bitmap bitmap = new Bitmap((int)(scale * page.Width), (int)(scale * page.Height))) { Graphics graphics = Graphics.FromImage(bitmap); graphics.SmoothingMode = SmoothingMode.AntiAlias; graphics.ScaleTransform(scale, scale); graphics.Clear(Color.White); page.Draw(graphics); bitmap.Save("C:\\" + Convert.ToString(_currentDPI) + "dpi.tiff", ImageFormat.Tiff); }
-
Hey Howzit? As you can see in the code below I am generating a Bitmap and saving it to disk, later in my program I display this .tiff file as the backgroundimage of a Panel. My question to you is, how can I generate multiple Bitmaps IN MEMORY (instead of saving to disk) and then display them later when I need to? Thanks using (Bitmap bitmap = new Bitmap((int)(scale * page.Width), (int)(scale * page.Height))) { Graphics graphics = Graphics.FromImage(bitmap); graphics.SmoothingMode = SmoothingMode.AntiAlias; graphics.ScaleTransform(scale, scale); graphics.Clear(Color.White); page.Draw(graphics); bitmap.Save("C:\\" + Convert.ToString(_currentDPI) + "dpi.tiff", ImageFormat.Tiff); }
Use class local variables. Create an array of bitmaps (or an arraylist). Create the bitmaps. class BitmapGenerator { private ArrayList bitmaps = new ArrayList(); public YourFunction() { ...yourcode.. bitmaps.Add(bitmap); } } ------------------------------ A bug in a Microsoft Product? No! It's not a bug it's an undocumented feature!
-
Use class local variables. Create an array of bitmaps (or an arraylist). Create the bitmaps. class BitmapGenerator { private ArrayList bitmaps = new ArrayList(); public YourFunction() { ...yourcode.. bitmaps.Add(bitmap); } } ------------------------------ A bug in a Microsoft Product? No! It's not a bug it's an undocumented feature!
Hey, thanks works, but now how to assign one of the bitmaps in the array to the background image of my panel?