Option strict ON problem ..
-
I can not figure out how load the file into my bitmap without getting an error with Option Strict set to ON (It works fine with Option Strict OFF ..:-))
Public BitmapImage As Bitmap BitmapImage = Bitmap.FromFile(filename) ' where file name is soemthing like ' "C:\Project\Prolasspecial.bmp"
What's the "correct" way of coding this, so that Option Strict On will not complain :rolleyes: ?? Georg -
I can not figure out how load the file into my bitmap without getting an error with Option Strict set to ON (It works fine with Option Strict OFF ..:-))
Public BitmapImage As Bitmap BitmapImage = Bitmap.FromFile(filename) ' where file name is soemthing like ' "C:\Project\Prolasspecial.bmp"
What's the "correct" way of coding this, so that Option Strict On will not complain :rolleyes: ?? GeorgOption Strict OFF is the same as 'I am not a programmer'. The problem is simple. Bitmap.FromFile returns an image, not a bitmap. Yes, this is stupid.
Christian Graus No longer a Microsoft MVP, but still happy to answer your questions.
-
Option Strict OFF is the same as 'I am not a programmer'. The problem is simple. Bitmap.FromFile returns an image, not a bitmap. Yes, this is stupid.
Christian Graus No longer a Microsoft MVP, but still happy to answer your questions.
I understand that .fromFile returns an Image = question remains what's the correct function to use to load my Bitmap file into my bitmap ?? How do I Convert it? I goggled it - but it seems everybody else has figured this one out or the offered solutions seem rather "complicated" to me Im I using the wrong Load function ? Is there a direct conversion from Image to Bitmap? Whats the "proper" way of doing this? Do I need to load it into an Image first and then use a conversion ??? Georg
-
I can not figure out how load the file into my bitmap without getting an error with Option Strict set to ON (It works fine with Option Strict OFF ..:-))
Public BitmapImage As Bitmap BitmapImage = Bitmap.FromFile(filename) ' where file name is soemthing like ' "C:\Project\Prolasspecial.bmp"
What's the "correct" way of coding this, so that Option Strict On will not complain :rolleyes: ?? GeorgThe
Bitmap
class has a constructor that takes a path to a file and a constructor which takes an image. The best option would be something like this:Public BitmapImage As Bitmap
BitmapImage = New Bitmap(filename)
' or
BitmapImage = New Bitmap(Bitmap.FromFile(filename))
I think the first option is simpler.
Scott Dorman
Microsoft® MVP - Visual C# | MCPD President - Tampa Bay IASA [Blog][Articles][Forum Guidelines]
Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai
-
Option Strict OFF is the same as 'I am not a programmer'. The problem is simple. Bitmap.FromFile returns an image, not a bitmap. Yes, this is stupid.
Christian Graus No longer a Microsoft MVP, but still happy to answer your questions.
Christian Graus wrote:
The problem is simple. Bitmap.FromFile returns an image, not a bitmap. Yes, this is stupid.
Well...not entirely since
FromFile
is actually inherited from theImage
class.Scott Dorman
Microsoft® MVP - Visual C# | MCPD President - Tampa Bay IASA [Blog][Articles][Forum Guidelines]
Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai
-
The
Bitmap
class has a constructor that takes a path to a file and a constructor which takes an image. The best option would be something like this:Public BitmapImage As Bitmap
BitmapImage = New Bitmap(filename)
' or
BitmapImage = New Bitmap(Bitmap.FromFile(filename))
I think the first option is simpler.
Scott Dorman
Microsoft® MVP - Visual C# | MCPD President - Tampa Bay IASA [Blog][Articles][Forum Guidelines]
Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai
Thanks - you guys are great! I knew there had to be a simple solution .... ;) georg
-
Thanks - you guys are great! I knew there had to be a simple solution .... ;) georg
Georg Kohler wrote:
Thanks - you guys are great! I knew there had to be a simple solution ....
You're welcome. Best place to look first is always the documentation. :)
Scott Dorman
Microsoft® MVP - Visual C# | MCPD President - Tampa Bay IASA [Blog][Articles][Forum Guidelines]
Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai