SysTray() { InitializeComponent(); CreateHandle(); Icon = AssemblyRoutines.GetAppIcon(); Service.StateChanged += delegate { this.Invoke(() => { StartStop.Checked = Service.Running; string title = "Cistera Screen Capture"; if (Service.Running) { notifyIcon.Icon = Icon; title += " started"; } else { //notifyIcon.Icon = Icon.FromHandle(ImageRoutines.GetGreyScale(Icon.ToBitmap()).GetHicon()); notifyIcon.Icon = Icon.FromHandle(ImageRoutines.GetInverted(Icon.ToBitmap()).GetHicon()); title += " stopped"; } notifyIcon.Text = title; }); }; }
public void ServiceStateChanged(ServiceControllerStatus?status) { this.Invoke2(() => { StartStop.Checked = status == ServiceControllerStatus.Running; string title = "Cistera Screen Capture"; if (StartStop.Checked) { notifyIcon.Icon = Icon; title += " started"; } else { //notifyIcon.Icon = Icon.FromHandle(ImageRoutines.GetGreyScale(Icon.ToBitmap()).GetHicon()); notifyIcon.Icon = Icon.FromHandle(ImageRoutines.GetInverted(Icon.ToBitmap()).GetHicon()); if (status != null) { title += " stopped"; } else { title += " does not exist"; } } notifyIcon.Text = title; }); }
static void add_image(PdfContentByte pcb, System.Drawing.Image image, System.Drawing.Point point) { image = ImageRoutines.GetCroppedByColor(image, System.Drawing.Color.Transparent); Image i = Image.GetInstance(image, (BaseColor)null); var ratio = Math.Min((float)image_max_size.Width / image.Width, (float)image_max_size.Height / image.Height); i.ScalePercent(ratio * 100); i.SetAbsolutePosition(point.X, point.Y); pcb.AddImage(i); }
void setScaledImage() { if (pages == null) { return; } if (scaledCurrentPageBitmap != null) { scaledCurrentPageBitmap.Dispose(); } if (pages[currentPageI].ActiveTemplateBitmap == null) { pages.ActiveTemplate = getTemplateFromUI(false); } scaledCurrentPageBitmap = ImageRoutines.GetScaled(pages[currentPageI].ActiveTemplateBitmap, (float)pictureScale.Value * Settings.Constants.Image2PdfResolutionRatio); if (picture.Image != null) { picture.Image.Dispose(); } picture.Image = new Bitmap(scaledCurrentPageBitmap); }
static byte[,] getBitmapHash(Bitmap bitmap) { int w = bitmap.Width; int h = bitmap.Height; bitmap = ImageRoutines.GetResized(bitmap, w, h); Int32[] rawImageData = new Int32[w * h]; BitmapData bd = bitmap.LockBits(new Rectangle(0, 0, w, h), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb); Marshal.Copy(bd.Scan0, rawImageData, 0, w * h); bitmap.UnlockBits(bd); byte[,] hash = new byte[w, h]; for (int x = 0; x < w; x++) { for (int y = 0; y < h; y++) { Color c = Color.FromArgb(rawImageData[y * w + x]); //hash[x, y] = (byte)(c.GetBrightness() * 255); hash[x, y] = (byte)((c.R + c.G + c.B) / 3); //hash[x, y] = (byte)((c.GetBrightness() < 0.9 ? 0 : 1) * 255); } } return(hash); }