Fast 2D image library/dll for VB.NET? - vb.net

after experimenting with VB.NET image and drawing classes, I am searching a new one that I could use.
The problem is that the actual classes are really slow and even a rate of 24 fps is too slow to refresh a moving 225x70 image and with double buffer. Using .FillRectangle with a brush is fast and could do the job, but the image is tiled behind the rectangle and does not move with the rectangle.
Do you have ideas of what I could do ? Please try to be clear in your answer if I need to install DLLs or things like that, as I am new to VB.net language.
*I already tried openTK, but it seems to be mostly 3D, I only need 2D. Should I use it anyway ? I can't find beginner tutorials for VB.NET.

I think XNA or GorgonLib would be the best options. OpenTK is good too, but I think it will be a little too complicated for just 2d drawing. There is also SDL.NET, but it hasn't been updated in a while and again, it's meant for 2d. The best 2d library I've used in terms of speed is allegro, but I'm not sure if there are any wrappers available for .NET.
Gorgon: http://code.google.com/p/gorgonlib/

Related

SharpDX How To Render a 3D Environment

I just started coding some basics in SharpDX (VB.net) and I already got it to Render a 2D triangle. And I know how to render other 2D stuff, but I want to create something in 3D where I'm able to rotate the camera around some cubes. I tried it, but failed at converting the 3D Space to screen coordinates. Now Here are my Questions:
How can I calculate a Matrix for Perspective projection?
How can I pass that Matrix to my Vertex Shader
How can I make the Camera rotate around the Objects when I drag the mouse over the screen?
Please explain these things to me and give some code examples. I'm just a Beginner in SharpDX and everything I found was just not understandable for me.
A few things you can do when you first start.
Firstly, there are some great examples you can leverage (Even in c# but you need VB) that you can use to learn from.
I suggest you look at this within the Sharpdx repository. Sharpdx direct 3d 11 samples
Within these examples (especially triangle example), it goes through the basics including setting up the device, the creation of simple resources to bind to your GPU and compiling the bytecode.
The samples though use the effects methodology, which is deprecated and as such once you become familiar with compiling code, I would advise moving away from this paradigm.
The more advanced examples will show you how to set up your matrices.
The last item you wanted to know about is mouse movement. I would advise just having a look at MSDN around mousemove events. You will need to bind one to your window/control and then read the deltas. Use those deltas to create your rotation/movement based upon this. Look into Vector3 (sharpdx), basically, you need to do this all in vector space and then create the various translation/rotation matrices from this.
Hope this is start.

I am trying to create a 2D tile map engine that works sort of like a tiled ScrollView

I already have a function that can return a tile for a given position. I am trying to make it so that when I scroll around it will load new tiles on the fly. I am having trouble figuring out how to attack the problem. I am sure that someone must have done this before and I would prefer to not reinvent the wheel on this.
Can anyone point me to a tutorial or some example code?
If not, can perhaps help me figure out how to do this?
I am using Kobold2D and the map is not going to be static, it will be generated on the fly, Minecraft style.
CATiledLayer is perfect for this. However, I do not know if this will play well with Cocos2d.

Create mock 3D "space" with forwards and backwards navigation

In iOS, I'd like to have a series of items in "space" similar to the way Time Machine works. The "space" would be navigated by a scroll bar like feature on the side of the page. So if the person scrolls up, it would essentially zoom in in the space and objects that were further away will be closer to the reference point. If one zooms out, then those objects will fade into the back and whatever is behind the frame of refrence will come into view. Kind of like this.
I'm open to a variety of solutions. I imagine there's a relatively easy solution within openGL, I just don't know where to begin.
Check out Nick Lockwood's iCarousel on github. It's a very good component. The example code he provides uses a custom carousel style very much like what you describe. You should get there with just a few tweaks.
As you said, in OpenGL(ES) is relatively easy to accomplish what you ask, however it may not be equally easy to explain it to someone that is not confident with OpenGL :)
First of all, I may suggest you to take a look at The Red Book, the reference guide to OpenGL, or at the OpenGL Wiki.
To begin, you may do some practice using GLUT; it will help you taking confidence with OpenGL, providing some high-level API that will let you skip the boring side of setting up an OpenGL context, letting you go directly to the drawing part.
OpenGL ES is a subset of OpenGL, so essentially has the same structure. Once you understood how to use OpenGL shouldn't be so difficult to use OpenGL ES. Of course Apple documentation is a very important resource.
Now that you know a lot of stuff about OpenGL you should be able to easily understand how your program should be structured.
You may, for example, keep your view point fixed and translate the world (or viceversa). There is not (of course) a universal solution, especially because the only thing that matters is the final result.
Another solution (maybe equally good, it depends on your needs), may be to simply scale up and down images (representing the objects of your world) to simulate the movement through the object itself.
For example you may use an array to store all of your images and use a slider to set (increase/decrease) the dimension of your image. Once the image becomes too large for the display you may gradually decrease alpha, so that the image behind will slowly appear. Take a look at UIImageView reference, it contains all the API's you need for it.
This may lead you to the loss of 3-dimensionality, but it's probably a simpler/faster solution than learn OpenGL.

Objective C: How to use CGLayerCreate and CGContextDrawLayerAtPoint?

I am studying Core Graphics to make dynamic textures for my project.
A friend told me that i should use CGLayerCreate and CGContextDrawLayerAtPoint
to improve the texture of the brush app that i am building but i haven't found any book or tutorial that includes CGLayerCreate and CGContextDrawAtPoint.
can you guys tell what's the use of this two and how will able to code them?
also if you know any core graphics book that includes those please tell me, it'll surely help me.
thanks!
The Quartz 2D Programming Guide has a chapter that discusses CGLayer objects.
Your friend might be thinking of this use of layers, quoting that chapter:
Repeated drawing. For example, you might want to create a pattern that
consists of the same item drawn over and over. Draw the item to a
layer and then repeatedly draw the layer, as shown in Figure 12-1. Any
Quartz object that you draw repeatedly—including CGPath, CGShading,
and CGPDFPage objects—benefits from improved performance if you draw
it to a CGLayer. Note that a layer is not just for onscreen drawing;
you can use it for graphics contexts that aren’t screen-oriented, such
as a PDF graphics context.
There's also a very very simple example in the Quartz2DBasics sample app.

Manipulating / Resizing / Scaling an image in vb.net

Imagine I have a rectangle say 400px x 300px. Then let’s say I want to load an image in that. All of this is very easy using Sytem.Drawing.DrawImage.
Rectangle http://img576.imageshack.us/img576/2363/rectangle.gif
But then I want to leave the left hand side as 300px but change the right hand side to 250 px. I can draw the box using 4 DrawLines but I don’t know how to squash the image into the new shape. I want the right hand side of the shape to be 250, the left size 300 and the top and bottom 400px.
Resized http://img85.imageshack.us/img85/3479/rectangle2.gif
I can’t use DrawImage as it expects the left and right sizes to be the same. Is there a way to manipulate the image into the new shape?
I've looked at other questions, but they only apply where the left and right hand side is equal.
Any thoughts on how to squash an image into a shape which did not have parallel sides?
(If it helps, I'm happy to sacrifice image quality to fit the right shape.)
Disclaimer: I work for Atalasoft.
Our DotImage product has a command called QuadrilateralWarpCommand that can do this. It's in DotImage Photo.
What you want to do is non-trivial (but also very powerful).
#Heinzi is correct, the general class is called warp transformations. What you're trying to do is specifically a perspective transformation. At a high level, it involves running the individual coordinates through a transformation matrix to get their new positions, and then doing interpolation between pixel values based on the old and new locations.
This article talks about some transformations, one of them being a sheer, so it might be helpful overall. I'm not sure, I haven't read it closely. In general, you want to google for something approximately like "c# image transformation" or "c# image perspective transform".
Depending on what you're planning on using it for, buying a library might be the best way to go about it, although there is a lot to learn about image manipulation by doing it yourself.
I did not find a solution to your problem, but I have some information which might help you along:
What you want is called a warp transformation.
As far as I know, the .net framework natively supports this kind of transformation only for a GraphicsPath, namely, the GraphicsPath.Warp method. Unfortunately, I don't think that this will help you, unless you are willing to redraw your image using a .net GraphicsPath object.
If you need the transformation directly in the UI layer, your UI library might help: Silverlight, for example, includes the PlaneProjection class, which can be used for such effects; in WPF, the 3D engine might be useful for this (requiring more programming effort, through).