From 90c7c8459744dcfd4346db905567509154ac44ee Mon Sep 17 00:00:00 2001 From: the_fiddler Date: Sun, 13 Apr 2008 21:31:24 +0000 Subject: [PATCH] Call Dispose on the loaded bitmap. --- Source/Examples/OpenGL/T11_Julia_Set.cs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Source/Examples/OpenGL/T11_Julia_Set.cs b/Source/Examples/OpenGL/T11_Julia_Set.cs index fa26ee61..27dbbaaa 100644 --- a/Source/Examples/OpenGL/T11_Julia_Set.cs +++ b/Source/Examples/OpenGL/T11_Julia_Set.cs @@ -148,6 +148,7 @@ namespace Examples.Tutorial #endregion Shaders #region Textures + // Load&Bind the 1D texture for color lookups GL.ActiveTexture(TextureUnit.Texture0); // select TMU0 GL.GenTextures(1, out TextureObject); @@ -155,10 +156,14 @@ namespace Examples.Tutorial GL.TexParameter(TextureTarget.Texture1D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear); GL.TexParameter(TextureTarget.Texture1D, TextureParameterName.TextureWrapS, (int)(TextureWrapMode)All.ClampToEdge); - Bitmap bitmap = new Bitmap("Data/JuliaColorTable.bmp"); - BitmapData data = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height), ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format24bppRgb); - GL.TexImage1D(TextureTarget.Texture1D, 0, PixelInternalFormat.Rgb8, data.Width, 0, OpenTK.Graphics.PixelFormat.Bgr, PixelType.UnsignedByte, data.Scan0); - bitmap.UnlockBits(data); + using (Bitmap bitmap = new Bitmap("Data/JuliaColorTable.bmp")) + { + BitmapData data = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height), ImageLockMode.ReadOnly, + System.Drawing.Imaging.PixelFormat.Format24bppRgb); + GL.TexImage1D(TextureTarget.Texture1D, 0, PixelInternalFormat.Rgb8, data.Width, 0, OpenTK.Graphics.PixelFormat.Bgr, + PixelType.UnsignedByte, data.Scan0); + bitmap.UnlockBits(data); + } #endregion Textures }