67378

vb.net code to make a image transparent

Question:

I wish to make a bitmap image (.bmp) transparent using VB.NET code. Kindly help me.

Answer1:

<a href="http://www.bobpowell.net/transcontrols.htm" rel="nofollow">Everything you need to know</a> about transparency with GDI+ (.NET windows forms applications).

Answer2:

I found the key was using the imageAttributes class. Basically set the color key to the color you are using to represent the transparent area, and use one of the drawImage calls that accepts an imageAttribute parameter...

Imports System.Drawing.Imaging ' and in a sub somewhere: Private mImageAttributes As New ImageAttributes mImageAttributes.SetColorKey(Color.FromArgb(0, 220, 20, 255), Color.FromArgb(0, 220, 20, 255)) Dim imageRectangle As New Rectangle(pX, pY, pBitmap.Width, pBitmap.Height) e.Graphics.DrawImage(pBitmap, imageRectangle, 0, 0, pBitmap.Width, pBitmap.Height, GraphicsUnit.Pixel, mImageAttributes)

Answer3:

VS 2012

Dim watermark_bm2 As Bitmap = 'someimage(from file or global resource)

watermark_bm2.MakeTransparent()

Answer4:

This msdn article gives full details on <a href="http://msdn.microsoft.com/en-us/library/ms172507.aspx" rel="nofollow">how to do this</a>

Here is <a href="http://www.c-sharpcorner.com/UploadFile/mahesh/DrawTransparentImageUsingAB10102005010514AM/DrawTransparentImageUsingAB.aspx" rel="nofollow">another article, but code sample is in c#</a>

Recommend

  • Android SurfaceView: Show Video after Images
  • Get byte[] from
  • IndexSizeError on drawImage on IE and Edge
  • How can the java 'class' literal return different instances of the Class object for the sa
  • In BASH convert a string with . in float
  • Is there a way to link a linux's thread TID and a pthread_t “thread ID”
  • Ruby and class variables in inherit class
  • Insertion large number of Entities into SQL Server 2012 [duplicate]
  • Most efficient way to move table rows from one table to another
  • Cannot get text from text area
  • Why does it draw lines in the wrong place?
  • Validate child input components on submit with Vee-Validate and vue js 2
  • Android Activity.onWindowFocusChanged doesn't get called from within TabHost
  • Zoom in and out of jPanel
  • AndEngine Applying Transparancy to AndEngine View
  • Graphics.CopyFromScreen [Web application] + The handle is invalid
  • Debug.DrawLine not showing in the GameView
  • Unity3D & Android: Difference between “UnityMain” and “main” threads?
  • How to delay loading a property with linq to sql external mapping?
  • Projection media query: browser support and workarounds?
  • How reduce the height of an mschart by breaking up the y-axis
  • Why doesn't :active or :focus work on text links in webkit? (safari & chrome)
  • Does CUDA 5 support STL or THRUST inside the device code?
  • How to apply VCL Styles to DLL-based forms in Inno Setup?
  • Timeout for blocking function call, i.e., how to stop waiting for user input after X seconds?
  • Comma separated Values
  • PHP: When would you need the self:: keyword?
  • Windows forms listbox.selecteditem displaying “System.Data.DataRowView” instead of actual value
  • Proper folder structure for lots of source files
  • How to set the response of a form post action to a iframe source?
  • Java static initializers and reflection
  • Change div Background jquery
  • Android Google Maps API OnLocationChanged only called once
  • How does Linux kernel interrupt the application?
  • Qt: Run a script BEFORE make
  • How to get Windows thread pool to call class member function?
  • unknown Exception android
  • reshape alternating columns in less time and using less memory
  • Observable and ngFor in Angular 2
  • Unable to use reactive element in my shiny app