[Ikvm-commit] ikvm/awt graphics.cs,1.77,1.78
Brought to you by:
jfrijters
From: Small S. <sma...@us...> - 2015-09-03 15:00:31
|
Update of /cvsroot/ikvm/ikvm/awt In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv26841/awt Modified Files: graphics.cs Log Message: Dispose temporary Bitmap objects immediately to prevent OutOfMemoryException Index: graphics.cs =================================================================== RCS file: /cvsroot/ikvm/ikvm/awt/graphics.cs,v retrieving revision 1.77 retrieving revision 1.78 diff -C2 -d -r1.77 -r1.78 *** graphics.cs 1 Jun 2015 13:33:49 -0000 1.77 --- graphics.cs 3 Sep 2015 15:00:28 -0000 1.78 *************** *** 89,98 **** public override void copyArea(int x, int y, int width, int height, int dx, int dy) { ! Bitmap copy = new Bitmap(width, height); ! using (Graphics gCopy = Graphics.FromImage(copy)) { ! gCopy.DrawImage(bitmap, new Rectangle(0, 0, width, height), x, y, width, height, GraphicsUnit.Pixel); } - g.DrawImageUnscaled(copy, x + dx, y + dy); } } --- 89,100 ---- public override void copyArea(int x, int y, int width, int height, int dx, int dy) { ! using (Bitmap copy = new Bitmap(width, height)) { ! using (Graphics gCopy = Graphics.FromImage(copy)) ! { ! gCopy.DrawImage(bitmap, new Rectangle(0, 0, width, height), x, y, width, height, GraphicsUnit.Pixel); ! } ! g.DrawImageUnscaled(copy, x + dx, y + dy); } } } *************** *** 133,142 **** Matrix t = g.Transform; Point src = getPointToScreen(new Point(x + (int)t.OffsetX, y + (int)t.OffsetY)); ! Bitmap copy = new Bitmap(width, height); ! using (Graphics gCopy = Graphics.FromImage(copy)) { ! gCopy.CopyFromScreen(src, new Point(0, 0), new Size(width, height)); } - g.DrawImageUnscaled(copy, x + dx, y + dy); } --- 135,146 ---- Matrix t = g.Transform; Point src = getPointToScreen(new Point(x + (int)t.OffsetX, y + (int)t.OffsetY)); ! using (Bitmap copy = new Bitmap(width, height)) { ! using (Graphics gCopy = Graphics.FromImage(copy)) ! { ! gCopy.CopyFromScreen(src, new Point(0, 0), new Size(width, height)); ! } ! g.DrawImageUnscaled(copy, x + dx, y + dy); } } *************** *** 2008,2038 **** const int h = 3; ! Bitmap bitmap = new Bitmap(w, h); ! Graphics g = Graphics.FromImage(bitmap); ! g.TextRenderingHint = hint; ! g.FillRectangle(new SolidBrush(Color.White), 0, 0, w, h); ! g.DrawString("A", font, new SolidBrush(Color.Black), 0, -baseline, FORMAT); ! g.DrawString("X", font, new SolidBrush(Color.Black), 0, -baseline, FORMAT); ! g.Dispose(); ! ! int y = 0; ! LINE: ! while (y < h) { ! for (int x = 0; x < w; x++) { ! Color color = bitmap.GetPixel(x, y); ! if (color.GetBrightness() < 0.5) { ! //there is a black pixel, we continue in the next line. ! baseline++; ! y++; ! goto LINE; } } - break; // there was a line without black pixel } - baselines[key] = baseline; } --- 2012,2044 ---- const int h = 3; ! using (Bitmap bitmap = new Bitmap(w, h)) { ! Graphics g = Graphics.FromImage(bitmap); ! g.TextRenderingHint = hint; ! g.FillRectangle(new SolidBrush(Color.White), 0, 0, w, h); ! g.DrawString("A", font, new SolidBrush(Color.Black), 0, -baseline, FORMAT); ! g.DrawString("X", font, new SolidBrush(Color.Black), 0, -baseline, FORMAT); ! g.Dispose(); ! ! ! int y = 0; ! LINE: ! while (y < h) { ! for (int x = 0; x < w; x++) { ! Color color = bitmap.GetPixel(x, y); ! if (color.GetBrightness() < 0.5) ! { ! //there is a black pixel, we continue in the next line. ! baseline++; ! y++; ! goto LINE; ! } } + break; // there was a line without black pixel } } baselines[key] = baseline; } |