public static Bitmap GetRandomLogo(Bitmap logo) { Bitmap bmp = new Bitmap(logo); if (mLogoRandomList.Count == 0) { List <int> numbers = Enumerable.Range(1, 7).ToList(); int count = numbers.Count; for (int x = 0; x < count; x++) { int r = Adapter.RandomNumber(0, numbers.Count - 1); mLogoRandomList.Add(numbers[r]); numbers.RemoveAt(r); } } switch (mLogoRandomList[0]) { case 1: logo = ColorMatrices.ApplyColorMatrix(bmp, ColorMatrices.InverseFilter()); break; case 2: logo = ColorMatrices.ApplyColorMatrix(bmp, ColorMatrices.GrayscaleFilter()); break; case 3: logo = ColorMatrices.ApplyColorMatrix(bmp, ColorMatrices.GrayscaleFilter()); logo = ColorMatrices.ApplyColorMatrix(bmp, ColorMatrices.InverseFilter()); break; case 4: logo = ColorMatrices.ApplyColorMatrix(bmp, ColorMatrices.InverseFilter()); logo = ColorMatrices.ApplyColorMatrix(bmp, ColorMatrices.SaturationFilter(Adapter.RandomNumber(100, 300))); break; case 5: logo = ColorMatrices.ApplyColorMatrix(bmp, ColorMatrices.InverseFilter()); logo = ColorMatrices.ApplyColorMatrix(bmp, ColorMatrices.SaturationFilter(Adapter.RandomNumber(-300, -100))); break; case 6: logo = ColorMatrices.ApplyColorMatrix(bmp, ColorMatrices.SaturationFilter(Adapter.RandomNumber(150, 300))); break; case 7: logo = ColorMatrices.ApplyColorMatrix(bmp, ColorMatrices.SaturationFilter(Adapter.RandomNumber(-300, -150))); break; } mLogoRandomList.RemoveAt(0); return(logo); }
/// <summary> /// Crop shot or Selected Window captures /// </summary> /// <param name="myImage">Fullscreen image</param> /// <param name="windowMode">True = Selected window, False = Crop shot</param> public Crop(Image myImage, bool windowMode) { InitializeComponent(); selectedWindowMode = windowMode; bmpClean = new Bitmap(myImage); bmpBackground = new Bitmap(bmpClean); bmpRegion = new Bitmap(bmpClean); Bounds = CaptureHelpers.GetScreenBounds(); this.CursorPos = this.PointToClient(Cursor.Position); rectIntersect.Size = new Size(Bounds.Width - 1, Bounds.Height - 1); SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true); CalculateBoundaryFromMousePosition(); timer.Tick += new EventHandler(TimerTick); windowCheck.Tick += new EventHandler(WindowCheckTick); if (selectedWindowMode) { captureObjects = Engine.ConfigUI.SelectedWindowCaptureObjects; myRectangle = new DynamicRectangle(CaptureType.SELECTED_WINDOW); WindowsListAdvanced wla = new WindowsListAdvanced(); wla.IgnoreWindows.Add(Handle); wla.IncludeChildWindows = captureObjects; windows = wla.GetWindowsRectangleList(); } else { myRectangle = new DynamicRectangle(CaptureType.CROP); if (Engine.ConfigUI.UseHardwareCursor) { Cursor = Cursors.Cross; } else { Cursor.Hide(); } } using (Graphics gBackground = Graphics.FromImage(bmpBackground)) using (Graphics gRegion = Graphics.FromImage(bmpRegion)) { gBackground.SmoothingMode = SmoothingMode.HighQuality; gRegion.SmoothingMode = SmoothingMode.HighQuality; if ((selectedWindowMode && Engine.ConfigUI.SelectedWindowRegionStyles == RegionStyles.REGION_TRANSPARENT) || (!selectedWindowMode && Engine.ConfigUI.CropRegionStyles == RegionStyles.REGION_TRANSPARENT)) { // If Region Transparent gRegion.FillRectangle(new SolidBrush(Color.FromArgb(Engine.ConfigUI.RegionTransparentValue, Color.White)), new Rectangle(0, 0, bmpRegion.Width, bmpRegion.Height)); } else if ((selectedWindowMode && Engine.ConfigUI.SelectedWindowRegionStyles == RegionStyles.REGION_BRIGHTNESS) || (!selectedWindowMode && Engine.ConfigUI.CropRegionStyles == RegionStyles.REGION_BRIGHTNESS)) { // If Region Brightness ImageAttributes imgattr = new ImageAttributes(); imgattr.SetColorMatrix(ColorMatrices.BrightnessFilter(Engine.ConfigUI.RegionBrightnessValue)); gRegion.DrawImage(bmpClean, new Rectangle(0, 0, bmpRegion.Width, bmpRegion.Height), 0, 0, bmpRegion.Width, bmpRegion.Height, GraphicsUnit.Pixel, imgattr); } else if ((selectedWindowMode && Engine.ConfigUI.SelectedWindowRegionStyles == RegionStyles.BACKGROUND_REGION_TRANSPARENT) || (!selectedWindowMode && Engine.ConfigUI.CropRegionStyles == RegionStyles.BACKGROUND_REGION_TRANSPARENT)) { // If Background Region Transparent gBackground.FillRectangle(new SolidBrush(Color.FromArgb(Engine.ConfigUI.BackgroundRegionTransparentValue, Color.White)), new Rectangle(0, 0, bmpBackground.Width, bmpBackground.Height)); } else if ((selectedWindowMode && Engine.ConfigUI.SelectedWindowRegionStyles == RegionStyles.BACKGROUND_REGION_BRIGHTNESS) || (!selectedWindowMode && Engine.ConfigUI.CropRegionStyles == RegionStyles.BACKGROUND_REGION_BRIGHTNESS)) { // If Background Region Brightness ImageAttributes imgattr = new ImageAttributes(); imgattr.SetColorMatrix(ColorMatrices.BrightnessFilter(Engine.ConfigUI.BackgroundRegionBrightnessValue)); gBackground.DrawImage(bmpClean, new Rectangle(0, 0, bmpBackground.Width, bmpBackground.Height), 0, 0, bmpBackground.Width, bmpBackground.Height, GraphicsUnit.Pixel, imgattr); } else if ((selectedWindowMode && Engine.ConfigUI.SelectedWindowRegionStyles == RegionStyles.BACKGROUND_REGION_GRAYSCALE) || (!selectedWindowMode && Engine.ConfigUI.CropRegionStyles == RegionStyles.BACKGROUND_REGION_GRAYSCALE)) { // If Background Region Grayscale ImageAttributes imgattr = new ImageAttributes(); imgattr.SetColorMatrix(ColorMatrices.GrayscaleFilter()); gBackground.DrawImage(bmpClean, new Rectangle(0, 0, bmpBackground.Width, bmpBackground.Height), 0, 0, bmpBackground.Width, bmpBackground.Height, GraphicsUnit.Pixel, imgattr); } } brushClean = new TextureBrush(bmpClean); brushBackground = new TextureBrush(bmpBackground); brushRegion = new TextureBrush(bmpRegion); }