Results 1 to 5 of 5

Thread: Image vs Bitmap

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2012
    Posts
    7

    Image vs Bitmap

    Hello!

    I wanted to know what is best to use for a picturebox.image - a bitmap variable or an Image variable. I have embedded resources (.png, .ico, and .jpg). I access them through calling a function from a class.

    Code:
    Public Class Items
    
        '-----------------------------------------------------------------------------------------------------------------------------------------------------------
        'ITEM
        Public Function Get_Item(ByRef ItemName As String) as Bitmap 'or As Image
    
            Dim Item As Bitmap = New Bitmap(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("I_Res." + LTrim$(ItemName) + ".ico"))' can change the Item type to Image
            Return Item
            Item.Dispose()
    
        End Function
        '-----------------------------------------------------------------------------------------------------------------------------------------------------------
    
    End Class

    So what is best to do?

    1) Declare an Image variable and get an image type from the resources (if it is "As Image")

    Code:
    Dim tmpImage As Image = (Items.Get_Item("Item1"))
    or

    2) Declare a Bitmap variable and get a bitmap from the resources? (if it is "As Bitmap")

    Code:
    Dim tmpImage As Bitmap=new bitmap(Items.Get_Item("Item1"))
    3)-Is it best to declare a variable first as above and then put it in picturebox (PictureBox1.Image=tmpImage)
    -Or I can just put it in the picturebox straight ahead? (PictureBox1.Image=new bitmap(Items.Get_Item("Item1"))

    4)Do I need to call Dispose on the variables in the Function?

    Thank you in advance!
    Last edited by dday9; Feb 29th, 2016 at 11:29 AM. Reason: Code Tags

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width