Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Remove Flicker before drawing Splash Screen

Remove Flicker before drawing Splash Screen

Scheduled Pinned Locked Moved C#
graphicscsharp
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sukhjinder_K
    wrote on last edited by
    #1

    Creating Spalsh Screen from an Image in C# Hi I need to create a Splash Screen from an Image file. The Splash Screen form should be of the same dimensions as the image file. The program should hide the Splash Screen when my MainForm is displayed. Here is what I'm doingclass SplashScreen : Form { Image splashImage; public SplashScreen() { this.TopMost = true; this.ShowInTaskbar = false; this.FormBorderStyle = FormBorderStyle.None; this.StartPosition = FormStartPosition.CenterScreen; this.BackColor = this.TransparencyKey = Color.White; Image img = Bitmap.FromFile("splash.png"); Bitmap b = new Bitmap(img); b.MakeTransparent(b.GetPixel(1,1)); this.BackgroundImage = splashImage = (Image) b; this.Size = this.splashImage.Size; } } class MainForm : Form { public static void main(String[] args) { // Some Code SplashScreen splash = new SplashScreen(); splash.Show(); MainForm mainForm = new MainForm(); mainForm.Shown += delegate(object o, EventArgs ev) { splash.Hide(); //Hide and Dispose the Splash Form When mainForm is shown for the first Time splash.Dispose(); mainForm.GetFocus(); }; // More Code } }
    The Splash File to be used is available here. With the above code I do get the splash screen and the behaviour as expected but before the splash screen is drawn I see a Black Rectangle flashing, with same dimensions as the splash image. Please suggest. If you have a different approach please go ahead. All I want is to see a nice Splash Screen Thanks Sukhjinder http://sukhjinder.cn/

    B S 2 Replies Last reply
    0
    • S Sukhjinder_K

      Creating Spalsh Screen from an Image in C# Hi I need to create a Splash Screen from an Image file. The Splash Screen form should be of the same dimensions as the image file. The program should hide the Splash Screen when my MainForm is displayed. Here is what I'm doingclass SplashScreen : Form { Image splashImage; public SplashScreen() { this.TopMost = true; this.ShowInTaskbar = false; this.FormBorderStyle = FormBorderStyle.None; this.StartPosition = FormStartPosition.CenterScreen; this.BackColor = this.TransparencyKey = Color.White; Image img = Bitmap.FromFile("splash.png"); Bitmap b = new Bitmap(img); b.MakeTransparent(b.GetPixel(1,1)); this.BackgroundImage = splashImage = (Image) b; this.Size = this.splashImage.Size; } } class MainForm : Form { public static void main(String[] args) { // Some Code SplashScreen splash = new SplashScreen(); splash.Show(); MainForm mainForm = new MainForm(); mainForm.Shown += delegate(object o, EventArgs ev) { splash.Hide(); //Hide and Dispose the Splash Form When mainForm is shown for the first Time splash.Dispose(); mainForm.GetFocus(); }; // More Code } }
      The Splash File to be used is available here. With the above code I do get the splash screen and the behaviour as expected but before the splash screen is drawn I see a Black Rectangle flashing, with same dimensions as the splash image. Please suggest. If you have a different approach please go ahead. All I want is to see a nice Splash Screen Thanks Sukhjinder http://sukhjinder.cn/

      B Offline
      B Offline
      Bekjong
      wrote on last edited by
      #2

      Sukhjinder_K wrote:

      this.BackColor = this.TransparencyKey = Color.White; Image img = Bitmap.FromFile("splash.png"); Bitmap b = new Bitmap(img); b.MakeTransparent(b.GetPixel(1,1)); this.BackgroundImage = splashImage = (Image) b;

      I don't really get what you're trying to achieve here. Why not just use

      this.BackColor = Color.Transparent;
      this.BackgroundImage = Bitmap.FromFile"splash.png");

      If you include the tranparency in your image you should be pretty much done. If that doesn't work, you can always fill up the form with a PictureBox control. Oh, as for the flicer problem, try using this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true); on your form.

      Standards are great! Everybody should have one!

      1 Reply Last reply
      0
      • S Sukhjinder_K

        Creating Spalsh Screen from an Image in C# Hi I need to create a Splash Screen from an Image file. The Splash Screen form should be of the same dimensions as the image file. The program should hide the Splash Screen when my MainForm is displayed. Here is what I'm doingclass SplashScreen : Form { Image splashImage; public SplashScreen() { this.TopMost = true; this.ShowInTaskbar = false; this.FormBorderStyle = FormBorderStyle.None; this.StartPosition = FormStartPosition.CenterScreen; this.BackColor = this.TransparencyKey = Color.White; Image img = Bitmap.FromFile("splash.png"); Bitmap b = new Bitmap(img); b.MakeTransparent(b.GetPixel(1,1)); this.BackgroundImage = splashImage = (Image) b; this.Size = this.splashImage.Size; } } class MainForm : Form { public static void main(String[] args) { // Some Code SplashScreen splash = new SplashScreen(); splash.Show(); MainForm mainForm = new MainForm(); mainForm.Shown += delegate(object o, EventArgs ev) { splash.Hide(); //Hide and Dispose the Splash Form When mainForm is shown for the first Time splash.Dispose(); mainForm.GetFocus(); }; // More Code } }
        The Splash File to be used is available here. With the above code I do get the splash screen and the behaviour as expected but before the splash screen is drawn I see a Black Rectangle flashing, with same dimensions as the splash image. Please suggest. If you have a different approach please go ahead. All I want is to see a nice Splash Screen Thanks Sukhjinder http://sukhjinder.cn/

        S Offline
        S Offline
        Sukhjinder_K
        wrote on last edited by
        #3

        [DllImport("user32.dll")] public static extern bool LockWindowUpdate(IntPtr hWndLock); public SplashScreen() { this.TopMost = true; this.ShowInTaskbar = false; this.FormBorderStyle = FormBorderStyle.None; this.StartPosition = FormStartPosition.CenterScreen; Image img = Bitmap.FromFile(LetsYoConfig.SplashFileName); this.Size = img.Size; LockWindowUpdate(this.Handle); try { this.BackColor = this.TransparencyKey = Color.White; Bitmap b = new Bitmap(img); this.BackgroundImage = splashImage = (Image) b; } finally { LockWindowUpdate(IntPtr.Zero); } }

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups