Arch4ngel Posted April 1, 2004 Posted April 1, 2004 (edited) I found this code on the internet and thought that it would be nice to share with everyone who want to make a nice spash screen or something like it. files : - Bitmap2Region.cs - Mouse.bmp namespace : BitmapToRegion How it work: [size=2]Bitmap bmp = [/size][size=2][color=#0000ff]new[/color][/size][size=2] Bitmap(@"C:\mouse.bmp"); Region reg = BitmapToRegion.BitmapToRegion.Convert(bmp, Color.White, BitmapToRegion.TransparencyMode.ColorKeyTransparent); [/size][size=2][color=#0000ff]this[/color][/size][size=2].BackgroundImage = Image.FromFile(@"C:\mouse.bmp"); [/size][size=2][color=#0000ff]this[/color][/size][size=2].Region = reg;[/size] This is my code that I used with the current bmp. Just try it ! You'll probably find many utility to this little piece of code. N.B.: It contains UNSAFE CODE. To allow compilation of Unsafe code : Project / Properties Configuration Properties Under "Code Generation" set Allow unsafe code blocks to true. Have fun ! ------------------------------------- [edit]I found that some "white" stay or that the image got cut sometime. I don't know what's the bug and if some find it... tell me ![/edit]Bitmap2Region.zip Edited April 1, 2004 by Arch4ngel Quote "If someone say : "Die mortal !"... don't stay to see if he isn't." - Unknown "Learning to program is like going out with a new girl friend. There's always something that wasn't mentioned in the documentation..." - Me "A drunk girl is like an animal... it scream at everything like a cat and roll in the grass like a dog." - Me after seeing my girlfriend drunk and some of her drunk friend. C# TO VB TRANSLATOR
ThePentiumGuy Posted April 3, 2004 Posted April 3, 2004 why is the code "unsafe"? Quote My VB.NET Game Programming Tutorial Site (GDI+, Direct3D, Tetris [coming soon], a full RPG.... you name it!) vbprogramming.8k.com My Project (Need VB.NET Programmers) http://workspaces.gotdotnet.com/ResolutionRPG
Arch4ngel Posted April 5, 2004 Author Posted April 5, 2004 A code is called unsafe when it don't use the garbage collector. This is the case for API function called from DLL. But if the code is well built... you can call it safe if you want :). The only danger with unsafe code is that it can cause memory leak. Unless that it's np. Quote "If someone say : "Die mortal !"... don't stay to see if he isn't." - Unknown "Learning to program is like going out with a new girl friend. There's always something that wasn't mentioned in the documentation..." - Me "A drunk girl is like an animal... it scream at everything like a cat and roll in the grass like a dog." - Me after seeing my girlfriend drunk and some of her drunk friend. C# TO VB TRANSLATOR
Administrators PlausiblyDamp Posted April 5, 2004 Administrators Posted April 5, 2004 Unsafe code does get garbage collected, you just have to follow a few rules before you are allowed to use memory in this way. Unsafe refers to the fact that you are calling code from outside the .Net managed environment and as such the .Net security policies cannot be applied and the resulting IL cannot be verified i.e. it may do unexpected (possibly illeagal operations) things. If the code attempts to do things the .Net application doesn't have permission to do then there is nothing to stop it executing. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Arch4ngel Posted April 5, 2004 Author Posted April 5, 2004 Oh. Thanx for more explication and details on what I though it were working. :D Quote "If someone say : "Die mortal !"... don't stay to see if he isn't." - Unknown "Learning to program is like going out with a new girl friend. There's always something that wasn't mentioned in the documentation..." - Me "A drunk girl is like an animal... it scream at everything like a cat and roll in the grass like a dog." - Me after seeing my girlfriend drunk and some of her drunk friend. C# TO VB TRANSLATOR
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.