private IntPtr WndProc( IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) { try { if (msg == 803) { lock (DummyTaskbarWindow.sync) { int num1 = lParam.ToInt32() >> 16 & (int)ushort.MaxValue; int num2 = lParam.ToInt32() & (int)ushort.MaxValue; BitmapImage bitmapImage = new BitmapImage(); bitmapImage.BeginInit(); bitmapImage.UriSource = new Uri(this.TaskbarThumbnailPath); bitmapImage.DecodePixelWidth = num1; bitmapImage.DecodePixelHeight = num2; bitmapImage.EndInit(); Bitmap bitmap = ImageUtils.BitmapImage2Bitmap(bitmapImage); DwmApi.DwmSetIconicThumbnail(new HWND(DummyTaskbarWindow.sThisHandle), (HBITMAP)bitmap.GetHbitmap(), DwmApi.DWM_SETICONICPREVIEW_Flags.DWM_SIT_NONE); } } } catch (Exception ex) { Logger.Warning("Exception in setting taskbar thumbnail : " + ex.ToString()); } return(IntPtr.Zero); }
private BitmapImage GetPlayerImage(BitmapImage image, int numbner) { BitmapImage bitmapImage; if (this.imageByNumberCache.TryGetValue(numbner, out bitmapImage)) { return(bitmapImage); } var text = $"#{numbner}"; var bitmap = ImageUtils.BitmapImage2Bitmap(image); float width = 150; float height = 50; float x = 0; float y = (float)image.Height - height; var rectf = new RectangleF(x, y, width, height); Graphics g = Graphics.FromImage(bitmap); g.SmoothingMode = SmoothingMode.AntiAlias; g.InterpolationMode = InterpolationMode.HighQualityBicubic; g.PixelOffsetMode = PixelOffsetMode.HighQuality; g.DrawString(text, new Font("Tahoma", 28), Brushes.DarkBlue, rectf); g.Flush(); bitmapImage = ImageUtils.BitMapToBitMapImage(bitmap); this.imageByNumberCache[numbner] = bitmapImage; return(bitmapImage); }
public void FloodFill(XRayImage xRayImage) { ImageHistory.Push(xRayImage.XRayBitmap); var originalImage = xRayImage.XRayBitmap; using (var bitmap = ImageUtils.BitmapImage2Bitmap(originalImage)) { var floodFill = new FloodFill(); // top & bottom borders for (var x = 0; x < bitmap.Width; x += 100) { floodFill.Fill(bitmap, new System.Drawing.Point(x, 0), System.Drawing.Color.Black, System.Drawing.Color.Transparent); floodFill.Fill(bitmap, new System.Drawing.Point(x, bitmap.Height - 1), System.Drawing.Color.Black, System.Drawing.Color.Transparent); } // left & right borders for (var y = 0; y < bitmap.Height; y += 100) { floodFill.Fill(bitmap, new System.Drawing.Point(0, y), System.Drawing.Color.Black, System.Drawing.Color.Transparent); floodFill.Fill(bitmap, new System.Drawing.Point(bitmap.Width - 1, y), System.Drawing.Color.Black, System.Drawing.Color.Transparent); } xRayImage.XRayBitmap = bitmap.Bitmap2BitmapImage(); } }