logo
down
shadow

Partially transparent splash screen in C#


Partially transparent splash screen in C#

By : Daniel Pascual
Date : November 21 2020, 07:31 AM
To fix this issue Why magenta? Try using White. I set the back color White and transparency key White. In the image below, the random box with a picture is my splash.
code :


Share : facebook icon twitter icon
Semi Transparent PNG as Splash Screen

Semi Transparent PNG as Splash Screen


By : DunderBoy
Date : March 29 2020, 07:55 AM
it helps some times I spent a few hours looking for a way to do this in Win Forms as well so I thought I would share my solution.
My splash screen image is a .png with a transparent background and various shadows that extend over the transparent background. Using uncommon colors as the background of the control along with a transparency key left ugly patches underneath the semi-transparent shadows.
code :
    bool painted = false
    protected override void OnPaintBackground(System.Windows.Forms.PaintEventArgs e)
    {
        if (painted) return;
        e.Graphics.DrawImage(BackgroundImage, new System.Drawing.Point(0, 0));
        painted = true;
    }
In c# how do I remove the halo from a transparent splash screen

In c# how do I remove the halo from a transparent splash screen


By : Raphael Jud
Date : March 29 2020, 07:55 AM
it fixes the issue Create the image again and don't do antialiasing towards the green. The TransparencyKey property works by making all pixels with an exact color transparent, which means if you have antialiasing for making the shape smoother it won't work and leave those half-green/half-content pixels there.
iPhone app: avoiding white screen after splash screen. Let splash screen linger, hide it after UIWebview loads? Splash s

iPhone app: avoiding white screen after splash screen. Let splash screen linger, hide it after UIWebview loads? Splash s


By : Michael Tschida
Date : March 29 2020, 07:55 AM
should help you out Here's a way to achieve it, get rid of all the code in your AppDelegate first of all. In your root view controller add an instance variable of class UIImageView called "splash".
Now in the rootViewController.m:
code :
-(void) viewWillAppear:(BOOL) animated {

    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{

        self.view.userInteractionEnabled = NO;

        splash = [[UIImageView alloc] initWithFrame:[UIScreen mainScreen].bounds];

        splash.image = [UIImage imageNamed:@"Default.png"];
        [self.view addSubview:splash];
    });
    }
static dispatch_once_t onceToken;
        dispatch_once(&onceToken, ^{

          [splash removeFromSuperView];
        });
-(void) viewDidLoad{

    CGRect webFrame = CGRectMake(0.0, 0.0, 320.0, 460.0);
    UIWebView *webView = [[UIWebView alloc] initWithFrame:webFrame];

    webView.delegate = self;

    [webView setBackgroundColor:[UIColor clearColor]];
    NSString *urlAddress = @"http://www.cnn.com";
    NSURL *url = [NSURL URLWithString:urlAddress];
    NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
    [webView loadRequest:requestObj];
}
-(void) webViewDidFinishLoad:(UIWebView *)webView {

    static dispatch_once_t onceToken;
        dispatch_once(&onceToken, ^{

          [splash removeFromSuperView];
        });
}
Transparent splash screen on the first (and only first) startup of an app for instructions (iOS)

Transparent splash screen on the first (and only first) startup of an app for instructions (iOS)


By : Taha Shahzad
Date : March 29 2020, 07:55 AM
Hope this helps check for your NSUserDefaults for the first launc and if it is then you could display your image as a modalViewController and to dismiss it on touch use touchesBegan metod to dismiss this controller.
Creating transparent splash screen without any noises

Creating transparent splash screen without any noises


By : Javier Gonzalez
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , I've found a way to solve the problem thanks to Rui Godinho Lopes (rui@Rui lopes.com) Per Pixel Alpha Blend post on codeproject.com
First I added PerPixelAlphaForm to my project.
code :
using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.Windows.Forms;
using System.Runtime.InteropServices;



// class that exposes needed win32 gdi functions.
class Win32
{
    public enum Bool
    {
        False= 0,
        True
    };


    [StructLayout(LayoutKind.Sequential)]
    public struct Point
    {
        public Int32 x;
        public Int32 y;

        public Point(Int32 x, Int32 y) { this.x= x; this.y= y; }
    }


    [StructLayout(LayoutKind.Sequential)]
    public struct Size {
        public Int32 cx;
        public Int32 cy;

        public Size(Int32 cx, Int32 cy) { this.cx= cx; this.cy= cy; }
    }


    [StructLayout(LayoutKind.Sequential, Pack=1)]
    struct ARGB
    {
        public byte Blue;
        public byte Green;
        public byte Red;
        public byte Alpha;
    }


    [StructLayout(LayoutKind.Sequential, Pack=1)]
    public struct BLENDFUNCTION
    {
        public byte BlendOp;
        public byte BlendFlags;
        public byte SourceConstantAlpha;
        public byte AlphaFormat;
    }


    public const Int32 ULW_COLORKEY = 0x00000001;
    public const Int32 ULW_ALPHA    = 0x00000002;
    public const Int32 ULW_OPAQUE   = 0x00000004;

    public const byte AC_SRC_OVER  = 0x00;
    public const byte AC_SRC_ALPHA = 0x01;


    [DllImport("user32.dll", ExactSpelling=true, SetLastError=true)]
    public static extern Bool UpdateLayeredWindow(IntPtr hwnd, IntPtr hdcDst, ref Point pptDst, ref Size psize, IntPtr hdcSrc, ref Point pprSrc, Int32 crKey, ref BLENDFUNCTION pblend, Int32 dwFlags);

    [DllImport("user32.dll", ExactSpelling=true, SetLastError=true)]
    public static extern IntPtr GetDC(IntPtr hWnd);

    [DllImport("user32.dll", ExactSpelling=true)]
    public static extern int ReleaseDC(IntPtr hWnd, IntPtr hDC);

    [DllImport("gdi32.dll", ExactSpelling=true, SetLastError=true)]
    public static extern IntPtr CreateCompatibleDC(IntPtr hDC);

    [DllImport("gdi32.dll", ExactSpelling=true, SetLastError=true)]
    public static extern Bool DeleteDC(IntPtr hdc);

    [DllImport("gdi32.dll", ExactSpelling=true)]
    public static extern IntPtr SelectObject(IntPtr hDC, IntPtr hObject);

    [DllImport("gdi32.dll", ExactSpelling=true, SetLastError=true)]
    public static extern Bool DeleteObject(IntPtr hObject);
}



/// <para>Your PerPixel form should inherit this class</para>
/// <author><name>Rui Godinho Lopes</name><email>rui@ruilopes.com</email></author>
public class PerPixelAlphaForm : Form
{
    public PerPixelAlphaForm()
    {
        // This form should not have a border or else Windows will clip it.
        FormBorderStyle = FormBorderStyle.None;
    }


    /// <para>Changes the current bitmap.</para>
    public void SetBitmap(Bitmap bitmap)
    {
        SetBitmap(bitmap, 255);
    }


    /// <para>Changes the current bitmap with a custom opacity level.  Here is where all happens!</para>
    public void SetBitmap(Bitmap bitmap, byte opacity)
    {
        if (bitmap.PixelFormat != PixelFormat.Format32bppArgb)
            throw new ApplicationException("The bitmap must be 32ppp with alpha-channel.");

        // The ideia of this is very simple,
        // 1. Create a compatible DC with screen;
        // 2. Select the bitmap with 32bpp with alpha-channel in the compatible DC;
        // 3. Call the UpdateLayeredWindow.

        IntPtr screenDc = Win32.GetDC(IntPtr.Zero);
        IntPtr memDc = Win32.CreateCompatibleDC(screenDc);
        IntPtr hBitmap = IntPtr.Zero;
        IntPtr oldBitmap = IntPtr.Zero;

        try {
            hBitmap = bitmap.GetHbitmap(Color.FromArgb(0));  // grab a GDI handle from this GDI+ bitmap
            oldBitmap = Win32.SelectObject(memDc, hBitmap);

            Win32.Size size = new Win32.Size(bitmap.Width, bitmap.Height);
            Win32.Point pointSource = new Win32.Point(0, 0);
            Win32.Point topPos = new Win32.Point(Left, Top);
            Win32.BLENDFUNCTION blend = new Win32.BLENDFUNCTION();
            blend.BlendOp             = Win32.AC_SRC_OVER;
            blend.BlendFlags          = 0;
            blend.SourceConstantAlpha = opacity;
            blend.AlphaFormat         = Win32.AC_SRC_ALPHA;

            Win32.UpdateLayeredWindow(Handle, screenDc, ref topPos, ref size, memDc, ref pointSource, 0, ref blend, Win32.ULW_ALPHA);
        }
        finally {
            Win32.ReleaseDC(IntPtr.Zero, screenDc);
            if (hBitmap != IntPtr.Zero) {
                Win32.SelectObject(memDc, oldBitmap);
                //Windows.DeleteObject(hBitmap); // The documentation says that we have to use the Windows.DeleteObject... but since there is no such method I use the normal DeleteObject from Win32 GDI and it's working fine without any resource leak.
                Win32.DeleteObject(hBitmap);
            }
            Win32.DeleteDC(memDc);
        }
    }


    protected override CreateParams CreateParams
    {
        get {
            CreateParams cp = base.CreateParams;
            cp.ExStyle |= 0x00080000; // This form has to have the WS_EX_LAYERED extended style
            return cp;
        }
    }
}
namespace MoballeghanPro.Client
{
    public partial class frmSplashScreen : PerPixelAlphaForm
    {
        public frmSplashScreen()
        {
            InitializeComponent();
        }

        private void frmSplashScreen_Load(object sender, EventArgs e)
        {
            SetBitmap(Properties.Resources.IntroMobaleghan); //Png picture in the resources

        }
    }
}
// Copyright © 2002-2004 Rui Godinho Lopes <rui@ruilopes.com>
// All rights reserved.
//
// This source file(s) may be redistributed unmodified by any means
// PROVIDING they are not sold for profit without the authors expressed
// written consent, and providing that this notice and the authors name
// and all copyright notices remain intact.
//
// Any use of the software in source or binary forms, with or without
// modification, must include, in the user documentation ("About" box and
// printed documentation) and internal comments to the code, notices to
// the end user as follows:
//
// "Portions Copyright © 2002-2004 Rui Godinho Lopes"
//
// An email letting me know that you are using it would be nice as well.
// That's not much to ask considering the amount of work that went into
// this.
//
// THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
// EXPRESS OR IMPLIED. USE IT AT YOUT OWN RISK. THE AUTHOR ACCEPTS NO
// LIABILITY FOR ANY DATA DAMAGE/LOSS THAT THIS PRODUCT MAY CAUSE.
Related Posts Related Posts :
  • Can I organize Git submodules in a flat hierarchy?
  • How to make a server reply after receiving a request/data
  • Stored Procedure works in DB but not in C# code
  • MVVM WPF Programmatically add Child Elements
  • NCrunch and PostSharp Logging clash
  • Increasing memory usage in socket client
  • Multiple DropDownList but same action
  • How to get application memory usage as shown in Task Manager?
  • Exposing interfaces instead of concrete classes
  • How to get only postal_code data from google api?
  • Is there a way to get rid of the (by dot42) using community licence?
  • Why must I implement a function for an interface in vb.net which apparently doesn't need to be implemented in C#
  • How to remove HTML tags from the gridview Row
  • Get public post from Facebook's Graph Search API 2.x with Facebook SDK for .NET
  • C# DLL Export to Inno-Setup - Error E0434F4D
  • syntax error insert into database
  • By-pass else block of int.TryParse in Lambda Syntax
  • Retrieve "property getter" from the property name
  • Implementing generic class and multiple interfaces
  • data bind DropDownList with OleDbDataReader from Ms access 2013
  • extract specific data from HTML -CDATA- pattern in C#
  • how to compare password with salted hashed password
  • Excluding one item from list (by Index), and take all others
  • How do I find out which argument is invalid when receiving 'The best overloaded match for (...) has some invalid argumen
  • How do I use a linq query to update the underlying database table
  • How to change the coordinates of a text in a pdf page from lower left to upper left
  • Entity Framework Error: error loading specified metadata resource
  • Writing one character at a time in a C# Console Application?
  • Read write barcode data without using barcode scanner device
  • Asp.net Website is only accessible on our company internet connection and not from other network
  • Generic method to map objects of different types
  • Back button control in windows phone app
  • Get matching enum int values from list of strings
  • Ajax Control Toolkit AutoCompleteExtender displays html source character by character of the current page as autocomplet
  • How to select a node with namespace from XmlDocument?
  • multiple foreach loops inside while loop
  • Why does setting a MinimumSize break the table layout?
  • WatIn SelectList().SelectByValue() return error Run script failed
  • SignalR not works on Google Chrome
  • Sync sent mail with Sent folder
  • return a View and File in a single method in ASP.Net MVC
  • FastReport mvc GetParameter() returns null
  • How to check datatable select method returns datatable c#
  • How to sort an array based on the occurrences of the elements in a string in C#?
  • App crashes without throwing any exception in windows phone 8.1 xaml
  • How to get values from command argument from gridview on link button's click?
  • What's the proper way to convert a Vector3DF into byte array?
  • Is there a way to place a default image for control in edit/view mode?
  • How to set a click event for button in repeater control
  • how to make communication with two different process in same computer?
  • Which is the best crash logging tool for Windows Phone 8 Apps
  • Custom MarkerStyle in MS Chart Control
  • while opening the page getting error there is no row at position 0
  • Error message in Monogame: Unhandled Exception: System.DllNotFoundException: SDL2.dll
  • How to extract "Message" part from Google API error message
  • Receiving Gigs of data from Mobile Service on UpdateAsync method
  • Can't figure out what this is? Unrecognized escape sequence (Mono)
  • Calling stored procedure from another stored procedure with parameters
  • Bind Strings from an .resw file with ReswFileCodeGenerator in XAML
  • wpf DataGrid column index is not saved
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org