Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Generate multiple Bitmaps in memory

Generate multiple Bitmaps in memory

Scheduled Pinned Locked Moved C#
questiongraphicsperformance
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    NewbieDude
    wrote on last edited by
    #1

    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); }

    I 1 Reply Last reply
    0
    • N NewbieDude

      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); }

      I Offline
      I Offline
      Ingo
      wrote on last edited by
      #2

      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!

      N 1 Reply Last reply
      0
      • I Ingo

        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!

        N Offline
        N Offline
        NewbieDude
        wrote on last edited by
        #3

        Hey, thanks works, but now how to assign one of the bitmaps in the array to the background image of my panel?

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups