How to set the ios bookmark icon in HTML

To set the ios bookmark icon in HTML you can use the following snippet.

Sample HTML

<link rel="apple-touch-icon" href="iOs_Icon.png"/>

If your icon is already glossy, you can prevent the device from adding its own gloss by using.

Sample HTML

<link rel="apple-touch-icon-precomposed" href="iOs_Icon.png"/>

How to rotate a image in C# and VB.NET

To rotate a image in C# and VB.NET you can use the following snippet.

Sample C#

public enum RotateMode
{
	Ninetee = 0,
	OneHundretEighty = 1,
	TwoHundredSeventy = 2,
}

public static Image RotateImage(Image myImage, RotateMode myRotatemode)
{
	var ret = myImage;
	switch (myRotatemode)
	{
		case RotateMode.Ninetee:
			ret.RotateFlip(RotateFlipType.Rotate90FlipNone);
			break;
		case RotateMode.OneHundretEighty:
			ret.RotateFlip(RotateFlipType.Rotate180FlipNone);
			break;
		case RotateMode.TwoHundredSeventy:
			ret.RotateFlip(RotateFlipType.Rotate270FlipNone);
			break;
	}
	return ret;
}

Sample VB.NET

Public Enum RotateMode
	Ninetee = 0
	OneHundretEighty = 1
	TwoHundredSeventy = 2
End Enum

Public Shared Function RotateImage(myImage As Image, myRotatemode As RotateMode) As Image
	Dim ret = myImage
	Select Case myRotatemode
		Case RotateMode.Ninetee
			ret.RotateFlip(RotateFlipType.Rotate90FlipNone)
			Exit Select
		Case RotateMode.OneHundretEighty
			ret.RotateFlip(RotateFlipType.Rotate180FlipNone)
			Exit Select
		Case RotateMode.TwoHundredSeventy
			ret.RotateFlip(RotateFlipType.Rotate270FlipNone)
			Exit Select
	End Select
	Return ret
End Function

How to flip a image in C# and VB.NET

To flip a image in C# and VB.NET you can use the following snippet.

Sample C#

public enum FlipMode
{
	Horizontal = 0,
	Vertical = 1,
	Both = 2
}

public Image FlipImage(Image myImage, FlipMode myFlipmode)
{
	var ret = myImage;
	switch (myFlipmode)
	{
		case FlipMode.Horizontal:
			ret.RotateFlip(RotateFlipType.RotateNoneFlipX);
			break;
		case FlipMode.Vertical:
			ret.RotateFlip(RotateFlipType.RotateNoneFlipY);
			break;
		case FlipMode.Both:
			ret.RotateFlip(RotateFlipType.RotateNoneFlipXY);
			break;
	}
	return ret;
}

Sample Vb.NET

Public Enum FlipMode
	Horizontal = 0
	Vertical = 1
	Both = 2
End Enum

Public Function FlipImage(myImage As Image, myFlipmode As FlipMode) As Image
	Dim ret = myImage
	Select Case myFlipmode
		Case FlipMode.Horizontal
			ret.RotateFlip(RotateFlipType.RotateNoneFlipX)
			Exit Select
		Case FlipMode.Vertical
			ret.RotateFlip(RotateFlipType.RotateNoneFlipY)
			Exit Select
		Case FlipMode.Both
			ret.RotateFlip(RotateFlipType.RotateNoneFlipXY)
			Exit Select
	End Select
	Return ret
End Function

How to load image from web asynchron into picturebox in C# and VB.NET

To load image from web asynchron into picturebox in C# and VB.NET you can use the following snippet.

Sample C#

pictureBox1.WaitOnLoad = false;
pictureBox1.LoadAsync(@"https://upload.wikimedia.org/wikipedia/commons/3/3f/Fronalpstock_big.jpg");

Sample VB.NET

pictureBox1.WaitOnLoad = False
pictureBox1.LoadAsync("https://upload.wikimedia.org/wikipedia/commons/3/3f/Fronalpstock_big.jpg")

How to convert a bitmap to icon in C# and VB.NET

To convert a bitmap to icon in C# and VB.NET you can use the following extension method.

Sample C#

public static Icon ToIcon(this Bitmap img, bool makeTransparent, Color colorToMakeTransparent)
{
	if (makeTransparent)
	{
		img.MakeTransparent(colorToMakeTransparent);
	}
	var iconHandle = img.GetHicon();
	return Icon.FromHandle(iconHandle);
}

Sample VB.NET

<System.Runtime.CompilerServices.Extension> _
Public Shared Function ToIcon(img As Bitmap, makeTransparent As Boolean, colorToMakeTransparent As Color) As Icon
	If makeTransparent Then
		img.MakeTransparent(colorToMakeTransparent)
	End If
	Dim iconHandle = img.GetHicon()
	Return Icon.FromHandle(iconHandle)
End Function

How to resize a image using C# or VB.NET

To resize a image using C# or VB.NET you can use the following snippet.

Sample C#

public static Image ResizeImage(Image img, int width, int height)
{
    var newImage = new Bitmap(width, height);
    using (var gr = Graphics.FromImage(newImage))
    {
       gr.SmoothingMode = SmoothingMode.HighQuality;
       gr.InterpolationMode = InterpolationMode.HighQualityBicubic;
       gr.PixelOffsetMode = PixelOffsetMode.HighQuality;
       gr.DrawImage(img, new Rectangle(0, 0, width, height));
     }
     return newImage;
}

public static Image ResizeImage(Image img, Size size)
{
	return ResizeImage(img, size.Width, size.Height);
}

public static Image ResizeImage(Bitmap bmp, int width, int height)
{
	return ResizeImage((Image)bmp, width, height);
}

public static Image ResizeImage(Bitmap bmp, Size size)
{
	return ResizeImage((Image)bmp, size.Width, size.Height);
}

Sample VB.NET

Public Shared Function ResizeImage(img As Image, width As Integer, height As Integer) As Image
	Dim newImage = New Bitmap(width, height)
	Using gr = Graphics.FromImage(newImage)
		gr.SmoothingMode = SmoothingMode.HighQuality
		gr.InterpolationMode = InterpolationMode.HighQualityBicubic
		gr.PixelOffsetMode = PixelOffsetMode.HighQuality
		gr.DrawImage(img, New Rectangle(0, 0, width, height))
	End Using
	Return newImage
End Function

Public Shared Function ResizeImage(img As Image, size As Size) As Image
	Return ResizeImage(img, size.Width, size.Height)
End Function

Public Shared Function ResizeImage(bmp As Bitmap, width As Integer, height As Integer) As Image
	Return ResizeImage(DirectCast(bmp, Image), width, height)
End Function

Public Shared Function ResizeImage(bmp As Bitmap, size As Size) As Image
	Return ResizeImage(DirectCast(bmp, Image), size.Width, size.Height)
End Function

Here are the same methods as Extensions Methods

Sample C#

public static Image ResizeImage(this Image img, int width, int height)
{
    var newImage = new Bitmap(width, height);
    using (var gr = Graphics.FromImage(newImage))
    {
       gr.SmoothingMode = SmoothingMode.HighQuality;
       gr.InterpolationMode = InterpolationMode.HighQualityBicubic;
       gr.PixelOffsetMode = PixelOffsetMode.HighQuality;
       gr.DrawImage(img, new Rectangle(0, 0, width, height));
     }
     return newImage;
}

public static Image ResizeImage(this Image img, Size size)
{
	return ResizeImage(img, size.Width, size.Height);
}

public static Image ResizeImage(this Bitmap bmp, int width, int height)
{
	return ResizeImage((Image)bmp, width, height);
}

public static Image ResizeImage(this Bitmap bmp, Size size)
{
	return ResizeImage((Image)bmp, size.Width, size.Height);
}

Sample VB.NET

<System.Runtime.CompilerServices.Extension> _
Public Shared Function ResizeImage(img As Image, width As Integer, height As Integer) As Image
	Dim newImage = New Bitmap(width, height)
	Using gr = Graphics.FromImage(newImage)
		gr.SmoothingMode = SmoothingMode.HighQuality
		gr.InterpolationMode = InterpolationMode.HighQualityBicubic
		gr.PixelOffsetMode = PixelOffsetMode.HighQuality
		gr.DrawImage(img, New Rectangle(0, 0, width, height))
	End Using
	Return newImage
End Function

<System.Runtime.CompilerServices.Extension> _
Public Shared Function ResizeImage(img As Image, size As Size) As Image
	Return ResizeImage(img, size.Width, size.Height)
End Function

<System.Runtime.CompilerServices.Extension> _
Public Shared Function ResizeImage(bmp As Bitmap, width As Integer, height As Integer) As Image
	Return ResizeImage(DirectCast(bmp, Image), width, height)
End Function

<System.Runtime.CompilerServices.Extension> _
Public Shared Function ResizeImage(bmp As Bitmap, size As Size) As Image
	Return ResizeImage(DirectCast(bmp, Image), size.Width, size.Height)
End Function