Search - Articles
DevASP.NET for ASP.NET, VB.NET, XML and C# (C-Sharp) Developers Tuesday, March 03, 2009
Dev Articles
Search Directory
ASP.NET
VB.Net
C-Sharp
SQL Server
 

Get pixel format, raw format, property id list and property items image in VB.net - C#.net.

Author: Shehzad Hemani
Download Source Code : 1068_source.zip

In this simple article you will learn that how we can get pixel format, raw format, property id list and property items image in VB and C#.net.

 Get Pixel Format:

Image consists of pixels to get the format of the pixel we have a property named pixel format. This property returns an enumeration of pixel format. This enumeration tells the pixel format.

To demonstrate make a window application. Drag one button and a picture box on form.

Now write the following code on Button click event:

C#

        private void btn_pixelformat_Click(object sender, EventArgs e)

        {

            try

            {

                Bitmap img = new Bitmap(pictureBox1.Image);

                System.Drawing.Imaging.PixelFormat pf = img.PixelFormat;

                MessageBox.Show("pixel format : " + pf.ToString());

            }

            catch (Exception ex) { MessageBox.Show(ex.Message); }

 

        }

VB

Private Sub btn_pixelformat_Click(ByVal sender As ObjectByVal As EventArgs)
        
Try 
            Dim 
img As Bitmap = New Bitmap(pictureBox1.Image)
            
Dim pf As System.Drawing.Imaging.PixelFormat img.PixelFormat
            MessageBox.Show((
"pixel format : " + pf.ToString))
        
Catch ex As Exception
            
MessageBox.Show(ex.Message)
        
End Try
    End Sub

This is simple code to get pixel format.

Get Property Items:

To get the meta data or property items of the image, for this purpose we have a property of image class named propertyitems. This property returns the array of property item class. By using this class we can parse property items.

To demonstrate make a window application. Drag one button and a picture box on form.

Now write the following code on Button click event:

C#

        private void btn_propertyitem_Click(object sender, EventArgs e)

        {

            try

            {

                Bitmap img = new Bitmap(pictureBox1.Image);

                System.Drawing.Imaging.PropertyItem[] arr = img.PropertyItems;

                MessageBox.Show("sucessfully got the property items");

            }

            catch (Exception ex) { MessageBox.Show(ex.Message); }

        }

VB

Private Sub btn_propertyitem_Click(ByVal sender As ObjectByVal As EventArgs)
        
Try 
            Dim 
img As Bitmap = New Bitmap(pictureBox1.Image)
            
Dim arr() As System.Drawing.Imaging.PropertyItem img.PropertyItems
            MessageBox.Show(
"sucessfully got the property items")
        
Catch ex As Exception
            
MessageBox.Show(ex.Message)
        
End Try
    End Sub

This is simple code to get property items of image.

Get Raw Format:

To get the raw format of image, for this purpose we have a property of image class named rawformat. This property returns an object of imageformat class. This object contains the raw format of image.

To demonstrate make a window application. Drag one button and a picture box on form.

Now write the following code on Button click event:

C#

private void btn_raw_Click(object sender, EventArgs e)

        {

            try

            {

                Bitmap img = new Bitmap(pictureBox1.Image);

                System.Drawing.Imaging.ImageFormat raw = img.RawFormat;

                MessageBox.Show("SUCCESSFULLY DONE");

            }

            catch (Exception ex) { MessageBox.Show(ex.Message); }

      

        }

VB

Private Sub btn_raw_Click(ByVal sender As ObjectByVal As EventArgs)
        
Try 
            Dim 
img As Bitmap = New Bitmap(pictureBox1.Image)
            
Dim raw As System.Drawing.Imaging.ImageFormat img.RawFormat
            MessageBox.Show(
"SUCCESSFULLY DONE")
        
Catch ex As Exception
            
MessageBox.Show(ex.Message)
        
End Try
    End Sub

This is simple code to get raw format of image.

Get Property id list:

To get the property id list of image, for this purpose we have a property of image class named propertyidlist. This property returns integer array.

To demonstrate make a window application. Drag one button and a picture box on form.

Now write the following code on Button click event:

C#

private void btn_propertyidlist_Click(object sender, EventArgs e)

        {

            try

            {

                Bitmap img = new Bitmap(pictureBox1.Image);

                int[] arrt = img.PropertyIdList;

                MessageBox.Show("done");

            }

            catch (Exception ex) { MessageBox.Show(ex.Message); }

 

        }

VB

Private Sub btn_propertyidlist_Click(ByVal sender As ObjectByVal As EventArgs)
        
Try 
            Dim 
img As Bitmap = New Bitmap(pictureBox1.Image)
            
Dim arrt() As Integer = img.PropertyIdList
            MessageBox.Show(
"done")
        
Catch ex As Exception
            
MessageBox.Show(ex.Message)
        
End Try
    End Sub

This is simple code to get property id list of image.

Now write the following code on FORM LOAD event:

C#

private void Form1_Load(object sender, EventArgs e)

        {          

            this.Text = "DEVASP IMAGE APPLICATION";

        }

VB

 Private Sub Form1_Load(ByVal sender As ObjectByVal As EventArgs)
        
Me.Text "DEVASP IMAGE APPLICATION"
    
End Sub

This simple article tells that how we can get pixel format, raw format, property id list and property items image in VB and C#.net.

   
Add Article Comment:
Name :
Email Address :
   
Comments :
 
   
<< How to take a Negative of an image in VB.net - C#.net.

Disclaimer - Privacy
© 2002-2017 DevASP.net