RyokuHasu Posted April 19, 2012 Author Share Posted April 19, 2012 So I've been working with the GDI+ for VB.NET (a built-in version of EO's graphic dependencies). and I finnaly got it to do dynamic cropping and masking color as well as RENDERING instead of loading!!!!! I did this in class while the rest were going over what a sub and a function is. LOLThe thing is that there is a Pixel Format called "DontCare" and I thought that was kinda funny lolAnyway here is a basic example of rendering with VB.netI know it might look a bit inefficient but it's just to show the basics of the graphic rendering of VB.net for any willing to go in that direction.Also, the bmp files are loaded from the same folder in this example.```Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click 'Create a new Bitmap image and load the first image to it (a background) Dim myBitmap As New Bitmap(System.AppDomain.CurrentDomain.BaseDirectory() + "2.bmp") 'Create an image object at the location you want it to render Dim g As Graphics = picDraw.CreateGraphics 'Draw the loaded image to the object g.DrawImage(myBitmap, 1, 1) 'load the second image to the bitmap image (an EO Character sprite) myBitmap = New Bitmap(System.AppDomain.CurrentDomain.BaseDirectory() + "1.bmp") 'Get the masking color from the top left pixel myBitmap.MakeTransparent(myBitmap.GetPixel(1, 1)) 'Declare a rectangle of what you want to crop out of the image (dynamically) Dim crop As New Rectangle(1, 1, (myBitmap.Width / 4), (myBitmap.Height / 4)) 'load a cropped copy of the bitmap to the bitmap itself myBitmap = myBitmap.Clone(crop, Imaging.PixelFormat.DontCare) 'Draw the image on top of the current image g.DrawImage(myBitmap, 1, 1) 'Load the character sprite again for another crop myBitmap = New Bitmap(System.AppDomain.CurrentDomain.BaseDirectory() + "1.bmp") 'Get the mask myBitmap.MakeTransparent(myBitmap.GetPixel(1, 1)) 'set a rectangle for the crop of the Left Facing, step1 frame(again dynamically) crop = New Rectangle((myBitmap.Width / 4), (myBitmap.Height / 4), (myBitmap.Width / 4), (myBitmap.Height / 4)) 'set the image as the cropped clone myBitmap = myBitmap.Clone(crop, Imaging.PixelFormat.DontCare) 'Draw the image ontop of the existing, beside the first crop of the character g.DrawImage(myBitmap, (myBitmap.Width / 4), 1) End Sub``` Link to comment Share on other sites More sharing options...
evilbunnie Posted April 19, 2012 Share Posted April 19, 2012 >2012>Using GDI Link to comment Share on other sites More sharing options...
RyokuHasu Posted April 19, 2012 Author Share Posted April 19, 2012 @Captain:> >2012> >Using GDIGot a better example of a built-in & easy to use example you would care to share? Cause it took me a while to fine this stuff, I would be happy to learn a better way. Link to comment Share on other sites More sharing options...
jcsnider Posted April 19, 2012 Share Posted April 19, 2012 Look into integrating Directx9 with Vb.Net it is a lot better then GDI+. Link to comment Share on other sites More sharing options...
RyokuHasu Posted April 19, 2012 Author Share Posted April 19, 2012 Ok, i'll check up on that. thank you for some CONSTRUCTIVE feedback. Link to comment Share on other sites More sharing options...
evilbunnie Posted April 19, 2012 Share Posted April 19, 2012 @Ryoku:> Ok, i'll check up on that. thank you for some CONSTRUCTIVE feedback.Just for godsake.Don't go the XNA route. Link to comment Share on other sites More sharing options...
RyokuHasu Posted April 19, 2012 Author Share Posted April 19, 2012 its ok I found some epic 2d DX9 vb.net examples, il going to try and understand them XD Link to comment Share on other sites More sharing options...
jcsnider Posted April 20, 2012 Share Posted April 20, 2012 Good luck and make sure you consider the POT rules for textures. Link to comment Share on other sites More sharing options...
crzyone9584 Posted April 21, 2012 Share Posted April 21, 2012 @Captain:> Just for godsake.> Don't go the XNA route.Whats wrong with xna? Would DX8/9 be better? Link to comment Share on other sites More sharing options...
evilbunnie Posted April 21, 2012 Share Posted April 21, 2012 @crzy:> Whats wrong with xna? Would DX8/9 be better?Of course.XNA is a DX9 wrapper, therefore it just makes DX9 simpler adding overhead.Use DX9. Link to comment Share on other sites More sharing options...
crzyone9584 Posted April 21, 2012 Share Posted April 21, 2012 So DX9 and C# is better than XNA C#?Sorry for highjacking the thread. Link to comment Share on other sites More sharing options...
evilbunnie Posted April 21, 2012 Share Posted April 21, 2012 @crzy:> So DX9 and C# is better than XNA C#?> > Sorry for highjacking the thread.Honestly, ditch C# and just go full C++ + OpenGL. Link to comment Share on other sites More sharing options...
crzyone9584 Posted April 21, 2012 Share Posted April 21, 2012 I want to get a playable demo out for my game. Once thats out I plan on switching over. My members of my site have been waiting for almost 2 years now. Anywho yall can have your thread back now. I have learned enough. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now