In fact, I figured it out. I'll explain what I did for those who want to know.
I still have the bitmap as a public variable. When the user selects a new file, I first set the Picturebox.BackgroundImage property to Nothing. Then I dispose the Bitmap file, after which I make it a new Bitmap with the correct width and height. I then apply the algorithm, after which I update the height of the Picturebox (width is constant) to the height of the Bitmap. Last I set the Picturebox.BackgroundImage property to the Bitmap, and then I invalidate it to show the bitmap.
Here's the code;
Thanks for the help, jmcilhinney. I really appreciate the time you're taking to look at my (and everyone's) problemsCode:' first prepare the background image MDIParent1.pcbTileSet.BackgroundImage = Nothing gTileSetViewBitmap.Dispose() gTileSetViewBitmap = New Bitmap(224, CInt(Math.Ceiling(tTileInfo.sTileCount / 7) * 32)) ' algorithm ' redraw MDIParent1.pcbTileSet.Height = gTileSetViewBitmap.Height MDIParent1.pcbTileSet.BackgroundImage = gTileSetViewBitmap MDIParent1.pcbTileSet.Invalidate()
PS: In the Load event of the application, I first do this;
Otherwise, it throws an error when I dispose the Bitmap (which is logical, of course).Code:gTileSetViewBitmap = New Bitmap(1, 1)





Reply With Quote