Ignore:
Timestamp:
1/5/2009 10:47:44 AM (3 years ago)
Author:
lowjoel
Message:

Implemented a slightly (performance increase by 200%) faster about box drawing algorithm. Fixes #136.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eraser6/Eraser/AboutForm.cs

    r853 r856  
    192192        } 
    193193 
     194        private void AboutForm_Paint(object sender, PaintEventArgs e) 
     195        { 
     196            DrawComposite(e.Graphics); 
     197        } 
     198 
    194199        private void AboutForm_MouseMove(object sender, MouseEventArgs e) 
    195200        { 
     
    217222                AboutTextScrollTop -= 1; 
    218223 
    219             DrawComposite(); 
    220         } 
    221  
    222         private void DrawComposite() 
     224            using (Graphics g = CreateGraphics()) 
     225                DrawComposite(g); 
     226        } 
     227 
     228        private void DrawComposite(Graphics g) 
    223229        { 
    224230            if (DoubleBufferBitmap == null) 
    225231                DoubleBufferBitmap = new Bitmap(ClientSize.Width, ClientSize.Height); 
    226             using (Graphics g = Graphics.FromImage(DoubleBufferBitmap)) 
     232            using (Graphics bg = Graphics.FromImage(DoubleBufferBitmap)) 
    227233            { 
    228234                //Draw the parent image with a fading out effect 
     235                if (ParentOpacity > 128) 
     236                    bg.Clip = new Region(AboutTextRect); 
     237 
    229238                Brush brush = new SolidBrush(Color.FromArgb(ParentOpacity, 0, 0, 0)); 
    230                 g.DrawImageUnscaled(ParentBitmap, 0, 0); 
    231                 g.FillRectangle(brush, ClientRectangle); 
     239                bg.DrawImageUnscaled(ParentBitmap, 0, 0); 
     240                bg.FillRectangle(brush, ClientRectangle); 
    232241 
    233242                //Then draw the About bitmap (which we cached in the constructor) 
    234                 g.DrawImageUnscaled(AboutBitmap, AboutBitmapPos); 
     243                bg.DrawImageUnscaled(AboutBitmap, AboutBitmapPos); 
    235244 
    236245                //And the scrolling text 
    237                 g.Clip = new Region(AboutTextRect); 
    238                 g.DrawImageUnscaled(AboutTextBitmap, AboutTextRect.Left, 
     246                bg.Clip = new Region(AboutTextRect); 
     247                bg.DrawImageUnscaled(AboutTextBitmap, AboutTextRect.Left, 
    239248                    AboutTextRect.Top + AboutTextScrollTop); 
    240                 g.ResetClip(); 
    241             } 
    242  
    243             using (Graphics g = CreateGraphics()) 
    244                 g.DrawImageUnscaled(DoubleBufferBitmap, 0, 0); 
     249                bg.ResetClip(); 
     250            } 
     251 
     252            if (ParentOpacity > 128) 
     253                if (g.Clip != null) 
     254                    g.Clip.Complement(new Region(AboutTextRect)); 
     255                else 
     256                    g.Clip = new Region(AboutTextRect); 
     257            g.DrawImageUnscaled(DoubleBufferBitmap, 0, 0); 
    245258        } 
    246259    } 
Note: See TracChangeset for help on using the changeset viewer.