예제 #1
0
 public void DrawBitmapManaged(int ObjectDesiredWidth, int ObjectDesiredHeight, bool ChangePosition, int NewLeft, int NewTop, bool ShowOverlay, int OverlayDesiredLeft, int OverlayDesiredTop, int OverlayDesiredWidth, int OverlayDesiredHeight, bool ChangeOpacity, int NewOpacity)
 {
     try
     {
         if (this.ObjectBitmap != null)
         {
             this.CurrentObjectBitmap = BitmapOperations.ScaleBySizeBestFit(ref this.ObjectBitmap, ObjectDesiredWidth, ObjectDesiredHeight);
             if (ShowOverlay && this.OverlayBitmap != null)
             {
                 using (Graphics graphics = Graphics.FromImage(this.CurrentObjectBitmap))
                 {
                     graphics.SmoothingMode      = SmoothingMode.HighSpeed;
                     graphics.PixelOffsetMode    = PixelOffsetMode.HighSpeed;
                     graphics.CompositingQuality = CompositingQuality.HighSpeed;
                     graphics.InterpolationMode  = InterpolationMode.HighQualityBicubic;
                     graphics.DrawImage(this.CurrentObjectBitmap, new Rectangle(OverlayDesiredLeft, OverlayDesiredTop, OverlayDesiredWidth, OverlayDesiredHeight), new Rectangle(0, 0, this.OverlayBitmap.Width, this.OverlayBitmap.Height), GraphicsUnit.Pixel);
                 }
             }
             if (this.ObjectSize.Width != ObjectDesiredWidth || this.ObjectSize.Height != ObjectDesiredHeight)
             {
                 this.ObjectSize = new Size(ObjectDesiredWidth, ObjectDesiredHeight);
             }
             if (this.OverlaySize.Width != OverlayDesiredWidth || this.OverlaySize.Height != OverlayDesiredHeight)
             {
                 this.OverlaySize = new Size(OverlayDesiredWidth, OverlayDesiredHeight);
             }
             if (ChangeOpacity)
             {
                 if (NewOpacity < 0)
                 {
                     this.ObjectOpacity = 0;
                 }
                 else if (NewOpacity > 255)
                 {
                     this.ObjectOpacity = 255;
                 }
                 else
                 {
                     this.ObjectOpacity = NewOpacity;
                 }
             }
             this.SetBitmap(ref this.CurrentObjectBitmap, (byte)this.ObjectOpacity, ChangePosition, NewLeft, NewTop);
         }
     }
     catch (Exception)
     {
     }
 }