Skip to main content
GameDev.net gamedev.net
🔒 Locked

Display jpeg on a form with SharpDX

Started by David Lake May 15, 2016 at 3:19 PM 10 replies 3.1k views
Original Post
David Lake
David Lake

Hi all, would anybody kindly show me how to use SharpDX to display a jpeg on a form with the least amount of code please?

Its for my time lapse player program and I'm trying to improve performance over GDI+, I'm very good with C# and less so with C++ but DX is so confuzling.

David Lake
David Lake

If you know why I'm not getting any replies please tell me.

jpetrie
jpetrie

It could be because it sounds like you're just asking people to write code for you. What have you tried already? Can you draw a blank quad already? Can you draw a blank triangle? Anything? There are plenty of tutorials and indeed probably even some samples that come with SharpDX on setting up basic rendering and trying a colored triangle, which you can adapt to drawing a texture triangle and thus a quad eventually.

David Lake
David Lake

I googled the hell out of this one but all I can find is incomplete and irrelevant bits and bobs that confuse the hell out of me.

jpetrie
jpetrie

...such as?

The (potential) reason you're getting no responses is because you're basically saying "Hey, help me do something." The barrier to entry into your actual problem context is thus, quite high. If you lower the barrier to entry, by providing more information, more specifics about what you've tried, what you've got working, anything like that, you increase the chance that you'll get useful replies. It shows that you are respecting the time of (potential) respondents and in turn they'll be more likely to respect you and provide some assistance.

This sample should display a simple, colored triangle. Can you get this to work? Can you replicate this in your own code? Can you then take that triangle and add a second triangle elsewhere? And then can you arrange them to form a square?

David Lake
David Lake

Since nobody wants to offer some free help I will offer a £10 reward to whoever can help because I'm really stuck on this 1.

jpetrie
jpetrie
But how do I use it, what else is needed like device context etc

That example appears to be using the SharpDX "Toolkit" library, which provides some high level, XNA-inspired functionality. You should just need to create a subclass of the Game class to get basic functionality up and running, although this does not look promising (specifically the warning about it being non-functional).

why is the method an override

Because it's a virtual method from the base game class. Marking the method "override" is required in C# to override that virtual method; this ensures your version of the method is run when needed.

how do I load an image on every frame and dispose it on the next?

You probably don't want to do this as it will be slow. Load as many frames as you can up front, once, and simply switch the displayed image every frame. Unless those frames are dynamically generated and always unique, you don't want to throw them away until you'll never use them again (probably).

David Lake
David Lake

Preloading the images and storing them in memory as bitmaps wont be practical not only because there will be too many but also due to the way I want to be able to play back the time lapse.

What do I need to start drawing with D2D to a RenderControl, what do I need to instance?

David Lake
David Lake

I'm trying my best please help!

David Lake
David Lake

WHY DOES THIS ALWAYS HAPPEN TO ME?!

jpetrie
jpetrie

You need to demonstrate some patience, I think. This forum doesn't move that fast. It's not a real-time chat.

I can't help you with D2D, I don't think it's the path you should take. I think you should, as I've said before, start with that mini triangle example and try to get that running in your context.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.