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")
orCode:Dim tmpImage As Image = (Items.Get_Item("Item1"))
2) Declare a Bitmap variable and get a bitmap from the resources? (if it is "As Bitmap")
3)-Is it best to declare a variable first as above and then put it in picturebox (PictureBox1.Image=tmpImage)Code:Dim tmpImage As Bitmap=new bitmap(Items.Get_Item("Item1"))
-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!




Reply With Quote
