protected void FixupCustomLogo() { StopAnimation(); if (string.IsNullOrEmpty(customIcon)) { return; } Bitmap newImage = FastBitmap.FromFile(customIcon); if (newImage == null) { return; } if (Logo != null) { Logo.Dispose(); Logo = null; } AnimatedLogo = NativeMethods.IsAnimatedGIF(customIcon); if (AnimatedLogo) { Logo = newImage; } else { Logo = BitmapPainter.ResizeBitmap(newImage, FileImage.ImageSize, FileImage.ImageSize, true); } SaveLogoToCache(); }
private void LoadLogo(string name) { if (string.IsNullOrEmpty(name)) { LoadDefaultLogo(); } else { if (Logo != null) { Logo.Dispose(); Logo = null; } string fullName = FileOperations.StripFileName(name); if (FileOperations.FileExists(fullName)) { Bitmap tmp = FastBitmap.FromFile(fullName); if (tmp != null) { Logo = BitmapPainter.ConvertToRealColors(tmp, false); tmp.Dispose(); } } if (Logo == null) { LoadDefaultLogo(); } } }
static void Main(string[] args) { FastColor c = new FastColor(127, 192, 255); Console.WriteLine("Please select an image."); OpenFileDialog ofd = new OpenFileDialog() { Filter = "BMP Files|*.bmp|JPG Files|*.jpg|PNG Files|*.png", CheckFileExists = true, CheckPathExists = true }; SaveFileDialog sfd = new SaveFileDialog() { Filter = "BMP Files|*.bmp", CheckPathExists = true }; if (ofd.ShowDialog() == DialogResult.OK) { FastBitmap f = FastBitmap.FromFile(ofd.FileName); // Edge detection, yay! f.Effects.EdgeDetection(); Console.WriteLine("Please select the save path"); if (sfd.ShowDialog() == DialogResult.OK) { f.Save(sfd.FileName); } } }
public CatalogItem(string fullPath, string shortName, string iconPath, ItemType itemType) { this.FullPath = fullPath; this.ShortName = shortName; this.ItemType = itemType; this.icon = FastBitmap.FromFile(iconPath); }
private void UpdateTarget() { KrentoRing ring = new KrentoRing(fileName); edtTarget.Text = ring.Caption; if (!string.IsNullOrEmpty(ring.Description)) { edtDescription.Text = ring.Description; } else { edtDescription.Text = ring.Caption; } if (!string.IsNullOrEmpty(ring.LogoFile)) { if (FileOperations.FileExists(ring.LogoFile)) { if (imgLogo.Image != null) { imgLogo.Image.Dispose(); } imgLogo.Image = FastBitmap.FromFile(FileOperations.StripFileName(ring.LogoFile)); customIcon = ring.LogoFile; } else { AssignDefaultImage(); } } else { AssignDefaultImage(); } ring.Dispose(); }
public void AssignIcon() { if (icon != null) { icon.Dispose(); icon = null; } string fileCustomIcon = FileImage.CustomFileIcon(FileOperations.ExtractFileNameFromShellLink(FullPath)); if (string.IsNullOrEmpty(fileCustomIcon)) { icon = (Bitmap)FileImage.FileNameImage(FullPath); if (icon == null) { if (FileOperations.DirectoryExists(FullPath)) { icon = NativeThemeManager.LoadBitmap("Folder.png"); } else { icon = NativeThemeManager.LoadBitmap("UnknownFile.png"); } } } else { icon = FastBitmap.FromFile(fileCustomIcon); } }
/// <summary> /// Updates the target icon if the custom icon file name is provided /// </summary> private void UpdateTargetIcon() { if (!string.IsNullOrEmpty(customIcon)) { string fullCustomIcon = FileOperations.StripFileName(customIcon); if (FileOperations.FileExists(fullCustomIcon)) { Bitmap tmp = FastBitmap.FromFile(fullCustomIcon); if (tmp != null) { if (imgLogo.Image != null) { imgLogo.Image.Dispose(); imgLogo.Image = null; } imgLogo.Image = new Bitmap(tmp); tmp.Dispose(); } else { AssignDefaultImage(); } } } else { AssignDefaultImage(); } }
private void btnSelectImage_Click(object sender, EventArgs e) { if (openIconDialog.ShowDialog() == DialogResult.OK) { imgLogo.Image = FastBitmap.FromFile(openIconDialog.FileName); customIcon = openIconDialog.FileName; } }
public SplashWindow() : base() { Text = "Krento Splash Screen"; if (!string.IsNullOrEmpty(GlobalSettings.SplashName)) { if (FileOperations.FileExists(GlobalSettings.SplashName)) { background = FastBitmap.FromFile(FileOperations.StripFileName(GlobalSettings.SplashName)); } } if (background == null) { background = NativeThemeManager.LoadBitmap("WindowKrentoSplash.png"); } bmpHeight = background.Height; bmpWidth = background.Width; this.Width = background.Width + 16; this.Height = background.Height + 16; this.Alpha = 240; this.ColorKey = ColorUtils.WhiteKey; StringBuilder sb = new StringBuilder("Version "); sb.Append(Application.ProductVersion); #if PORTABLE sb.Append(" Portable"); #endif if (NativeMethods.IsNativeWin64()) { sb.Append(" x64"); } else { sb.Append(" x86"); } versionInfo = sb.ToString(); using (Graphics g = Graphics.FromImage(background)) { using (Font versionFont = new Font("Tahoma", 11.0f, FontStyle.Bold, GraphicsUnit.Pixel)) { TextPainter.DrawStringHalo(g, versionInfo, versionFont, -16, 120, bmpWidth, 50, Color.White, true); } } this.Canvas.DrawImage(background, 8, 8, bmpWidth, bmpHeight); this.Update(); }
private void LoadLogo() { string fullLogoFile = FileOperations.StripFileName(logoFile); if (FileOperations.FileExists(fullLogoFile)) { if (imgLogo.Image != null) { imgLogo.Image.Dispose(); } Bitmap tmp = FastBitmap.FromFile(fullLogoFile); imgLogo.Image = BitmapPainter.ConvertToRealColors(tmp, false); tmp.Dispose(); } }
private bool IsImageFile(string fileName, out FastBitmap image) { // TODO: Better to use FreeImage or something that will // detect an image format by reading the first few bytes try { image = FastBitmap.FromFile(fileName); } catch { image = null; } return(image != null); }
/// <summary> /// Updates the target icon if the custom icon file name is provided /// </summary> private void UpdateTargetIcon() { if (!string.IsNullOrEmpty(customIcon)) { string fullCustomIcon = FileOperations.StripFileName(customIcon); if (FileOperations.FileExists(fullCustomIcon)) { Bitmap tmp = FastBitmap.FromFile(fullCustomIcon); if (imgLogo.Image != null) { imgLogo.Image.Dispose(); imgLogo.Image = null; } imgLogo.Image = BitmapPainter.ConvertToRealColors(tmp, true); } } }
public GameBackground(string fname, int fighterInTeam) { this.fighterInTeam = fighterInTeam; eth = new string[2][]; eth[0] = new string[fighterInTeam]; eth[1] = new string[fighterInTeam]; deadCount = new int[2]; FastBitmap bmp = FastBitmap.FromFile(fname); bitmap = bmp.ToBitmap(); map = new int[bmp.Width, bmp.Height]; for (int x = 0; x < bmp.Width; x++) { for (int y = 0; y < bmp.Height; y++) { map[x, y] = bmp.GetPixel(x, y).GetBrightness() < 0.5 ? 1 : 0; } } }
public void StartSmoke(int x, int y) { Bitmap tmp = null; if (!string.IsNullOrEmpty(fileName)) { if (FileOperations.FileExists(fileName)) { tmp = FastBitmap.FromFile(FileOperations.StripFileName(fileName)); } } if (tmp == null) { tmp = NativeThemeManager.LoadBitmap("animation-poof.png"); } animation.Image = tmp; UpdatePosition(x - Width / 2, y - Width / 2); Update(); ShowDialog(); }
public AboutWindow() : base() { this.Text = "About Krento"; if (!string.IsNullOrEmpty(GlobalSettings.AboutBoxName)) { if (FileOperations.FileExists(GlobalSettings.AboutBoxName)) { background = FastBitmap.FromFile(FileOperations.StripFileName(GlobalSettings.AboutBoxName)); } } if (background == null) { background = NativeThemeManager.LoadBitmap("WindowKrentoAbout.png"); } this.Width = background.Width + 16; this.Height = background.Height + 16; this.Alpha = 230; this.ColorKey = ColorUtils.WhiteKey; Canvas.SmoothingMode = SmoothingMode.HighQuality; this.Canvas.DrawImage(background, 8, 8, background.Width, background.Height); if (!TextHelper.SameText(Language.Culture.Name, "en-US")) { translatorName = SR.GetCaption("Translator"); if (TextHelper.SameText(translatorName, "Put your name here")) { translatorName = ""; } } if (!string.IsNullOrEmpty(translatorName)) { translator = "Translator: " + translatorName; } versionInfo = "Version " + Application.ProductVersion; this.Repaint(); }
public void AddCustomIcon(string fileName) { bool found = false; if (!string.IsNullOrEmpty(fileName)) { if (FileOperations.FileExists(fileName)) { found = true; } } if (found) { Bitmap tmp = FastBitmap.FromFile(fileName); icons.Add(BitmapPainter.ResizeBitmap(tmp, 32, 32, true)); } else { icons.Add(BitmapPainter.ResizeBitmap(NativeThemeManager.Load("SmallKrento.png"), 32, 32, true)); } }
protected void FixupCacheLogo() { //Reload image from cache Bitmap cacheOriginal; if (FileOperations.FileExists(CacheLogoName)) { if (Logo != null) { Logo.Dispose(); Logo = null; } cacheOriginal = FastBitmap.FromFile(CacheLogoName); if (cacheOriginal != null) { if (cacheOriginal.Width == FileImage.ImageSize) { Logo = BitmapPainter.ConvertToRealColors(cacheOriginal, true); AnimatedLogo = false; } } } }
public AboutWindow(RollingStoneBase stone) : base() { this.stone = stone; if (!string.IsNullOrEmpty(GlobalSettings.AboutStoneName)) { if (FileOperations.FileExists(GlobalSettings.AboutStoneName)) { background = FastBitmap.FromFile(FileOperations.StripFileName(GlobalSettings.AboutStoneName)); } } if (background == null) { background = NativeThemeManager.LoadBitmap("WindowBackground.png"); } this.Width = background.Width + 16; this.Height = background.Height + 16; this.Alpha = 230; this.ColorKey = ColorUtils.WhiteKey; Canvas.SmoothingMode = SmoothingMode.HighQuality; this.Canvas.DrawImage(background, 8, 8, background.Width, background.Height); if (!string.IsNullOrEmpty(stone.StoneAuthor)) { this.author = "Author: " + stone.StoneAuthor; } this.description = stone.StoneDescription; this.stoneIcon = stone.StoneIcon; versionInfo = "Version: " + stone.StoneVersion; copyright = stone.StoneCopyright; }
public void ActivateEngine() { TraceDebug.Trace("Activate Engine"); bool doCheck = GlobalSettings.CheckUpdate; bool disableCheck = false; Visible = false; NativeMethods.ShowWindow(this.Handle, 0); NativeMethods.RemoveSystemMenu(this.Handle); #region First Instance Execution if (context.FirstInstance) { if (!string.IsNullOrEmpty(GlobalSettings.IconName)) { Icon customIcon = null; if (FileOperations.FileExists(GlobalSettings.IconName)) { Icon loadIcon = new Icon(FileOperations.StripFileName(GlobalSettings.IconName)); try { customIcon = (Icon)loadIcon.Clone(); } finally { loadIcon.Dispose(); loadIcon = null; } notifyIcon.Icon = customIcon; //this.Icon = customIcon; } } if (splashScreen != null) { splashScreen.Show(); } if (!string.IsNullOrEmpty(GlobalSettings.GlyphName)) { if (FileOperations.FileExists(GlobalSettings.GlyphName)) { Bitmap tmp = FastBitmap.FromFile(GlobalSettings.GlyphName); notifier.Glyph = BitmapPainter.ResizeBitmap(tmp, notifier.GlyphSize, notifier.GlyphSize, true); } } if (notifier.Glyph == null) { notifier.Glyph = NativeThemeManager.Load("BigKrento.png"); } context.Manager.SetHookMessage(context); ReloadAll(); PreparePulsar(); context.Manager.Rotate(0); if (!GlobalSettings.ShowManagerButtons) { context.Manager.DrawText(SR.KrentoWelcome); } context.Manager.Update(); context.Manager.Visible = false; notifyIcon.Visible = GlobalSettings.ShowTrayIcon; if (splashScreen != null) { if (KrentoContext.FirstRun) { splashScreen.Hide(); NativeMethods.PostMessage(InteropHelper.MainWindow, NativeMethods.CM_SPLASHCLOSE, IntPtr.Zero, IntPtr.Zero); } else { splashScreen.Close(200); } } systemReady = true; string keyMessage = HotKeyMessage; notifier.Caption = SR.KrentoWelcome; if (GlobalSettings.MouseHook == MouseHookButton.None) { notifier.Text = SR.WelcomeMessage(keyMessage, "", ""); } else { string mouseText = ""; switch (GlobalSettings.MouseHook) { case MouseHookButton.Wheel: mouseText = MouseKeyMessage + SR.MouseWheelButton; break; case MouseHookButton.XButton1: mouseText = MouseKeyMessage + SR.MouseXButton1; break; case MouseHookButton.XButton2: mouseText = MouseKeyMessage + SR.MouseXButton2; break; default: mouseText = ""; break; } notifier.Text = SR.WelcomeMessage(keyMessage, SR.OrClick, mouseText); } //Only show popup window when asked if (GlobalSettings.ShowPopupAlerts) { if (GlobalConfig.LowMemory) { notifyIcon.BalloonTipTitle = notifier.Caption; notifyIcon.BalloonTipText = notifier.Text; notifyIcon.BalloonTipIcon = ToolTipIcon.Info; notifyIcon.ShowBalloonTip(5000); } else { notifier.Show(); } } Manager.ClearUnusedMemory(); #region manage autoupdate DateTime lastCheck = Settings.Default.LastCheck; TimeSpan ts = DateTime.Now - lastCheck; if (ts.Days >= 7) { Settings.Default.LastCheck = DateTime.Now; Settings.Default.Save(); if (Settings.Default.AskForCheck) { UpdateDialog upd = new UpdateDialog(); try { upd.ShowDialog(); doCheck = (upd.DialogResult == DialogResult.OK); disableCheck = (upd.btnDisable.Checked); if (disableCheck) { GlobalSettings.CheckUpdate = doCheck; Settings.Default.AskForCheck = false; Settings.Default.Save(); } } finally { upd.Dispose(); } } if ((GlobalSettings.CheckUpdate) && (doCheck)) { checker.CheckNewVersion(); } } #endregion if (GlobalSettings.StartVisible || KrentoContext.FirstRun) { InteropHelper.ShowDesktop(); if (!Manager.Visible) { if (KrentoContext.FirstRun) { Manager.ShowAndExecute(Manager.SimulateWheelRotation); } else { ChangeVisibility(); } } } } #endregion else { systemReady = false; context.FirstInstance = false; } }
public static void Main(string[] args) { Console.WriteLine("FastBitmap (v1.2.0) Benchmarking App"); Console.WriteLine("------------------------------------------------"); // // Single-Core Passthrough Benchmarks // BenchmarkTest pt = new BenchmarkTest { Name = "Single-Core Passthrough Benchmark", IterationCount = 3 }; // System.Drawing.Bitmap Coord Benchmark pt.AddBenchmark("SysBitmap Coord", () => { using (Bitmap src = new Bitmap(Image.FromFile("image.jpg"))) using (Bitmap dst = new Bitmap(src.Width, src.Height)) { Stopwatch sw = new Stopwatch(); sw.Start(); for (int x = 0; x < dst.Width; x++) { for (int y = 0; y < dst.Height; y++) { dst.SetPixel(x, y, src.GetPixel(x, y)); } } sw.Stop(); dst.Save("SystemBitmap.jpg"); return(src.Width * src.Height / sw.Elapsed.TotalSeconds); } }); // FastBitmap Coord Benchmark pt.AddBenchmark("FastBitmap Coord", () => { using (FastBitmap src = FastBitmap.FromFile("image.jpg")) using (FastBitmap dst = new FastBitmap(src.Width, src.Height)) { Stopwatch sw = new Stopwatch(); sw.Start(); for (int x = 0; x < dst.Width; x++) { for (int y = 0; y < dst.Height; y++) { dst.Set(x, y, src.Get(x, y)); } } sw.Stop(); dst.Save("FastBitmapCoord.jpg"); return(src.Length / sw.Elapsed.TotalSeconds); } }); // FastBitmap Index Benchmark pt.AddBenchmark("FastBitmap Index", () => { using (FastBitmap src = FastBitmap.FromFile("image.jpg")) using (FastBitmap dst = new FastBitmap(src.Width, src.Height)) { Stopwatch sw = new Stopwatch(); sw.Start(); for (int i = 0; i < dst.Length; i++) { dst.Set(i, src.Get(i)); } sw.Stop(); dst.Save("FastBitmapIndex.jpg"); return(src.Length / sw.Elapsed.TotalSeconds); } }); // FastBitmap Int32 Coord Benchmark pt.AddBenchmark("FastBitmap Int32 Coord", () => { using (FastBitmap src = FastBitmap.FromFile("image.jpg")) using (FastBitmap dst = new FastBitmap(src.Width, src.Height)) { Stopwatch sw = new Stopwatch(); sw.Start(); for (int x = 0; x < dst.Width; x++) { for (int y = 0; y < dst.Height; y++) { dst.SetI(x, y, src.GetI(x, y)); } } sw.Stop(); dst.Save("FastBitmapInt32Coord.jpg"); return(src.Length / sw.Elapsed.TotalSeconds); } }); // FastBitmap Int32 Index Benchmark pt.AddBenchmark("FastBitmap Int32 Index", () => { using (FastBitmap src = FastBitmap.FromFile("image.jpg")) using (FastBitmap dst = new FastBitmap(src.Width, src.Height)) { Stopwatch sw = new Stopwatch(); sw.Start(); for (int i = 0; i < dst.Length; i++) { dst.SetI(i, src.GetI(i)); } sw.Stop(); dst.Save("FastBitmapInt32Index.jpg"); return(src.Length / sw.Elapsed.TotalSeconds); } }); // Run Passthrough pt.Run(); // Render Graph FastBitmap graph = pt.DrawGraph(); graph.Save("graph.png", ImageFormat.Png); graph.Dispose(); // Finished. Console.Write("\nAll Benchmarks Completed"); Console.Read(); }
/// <summary> /// Instantiates a new <see cref="IndexObject"/> using the supplied path. This method will compute the hash of the file - this is an expensive operation. /// </summary> /// <param name="path"> /// The path to the image. /// </param> public IndexObject(string path) { this.Path = path; this.Hash = FastBitmap.FromFile(path).GetPerceptualHash(); this.categories = new List <Category>(); }