473,320 Members | 1,914 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Display images - C#

Please HELP

1. How can I display an array of images from diffrent types(jpeg,
bmp..)(In C#)
Can I also display video files?(In C#)
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 15 '05 #1
3 10852
"Dafna m" <mo***@012.net.il> wrote in message
news:eX***************@tk2msftngp13.phx.gbl...
Please HELP

1. How can I display an array of images from diffrent types(jpeg,
bmp..)(In C#)
Can I also display video files?(In C#)


There are many ways to do this. See PictureBox, and the classes Image and
Bitmap. Note that Bitmap can load from files from many, many types.

This link should give you more than enough info for what you want for
pictures.
http://www.codeproject.com/cs/media/

I'd first look at the article "How to load/display images"
http://www.codeproject.com/cs/media/quickview.asp

As for videos, you have three choices (probably more than this)
1) Managed DirectX 9 and the AudioVideoPlayback class
- Uses all C# code
- Documentation is not very good
- Lots of annoying bugs in the library.
- Requires DirectX 9 is installed on clients.

Here's DirectX9 SDK link:
http://www.microsoft.com/downloads/d...displaylang=en

I found I had to use a LOT of workarounds to get the AudioVideoPlayback to
"play" nicely - but that was only when I started messing with the volume
level of the sound. If you don't mess with volume, it's not too hard to get
this working.

2) DirectX DirectShow and interop
- Uses Interop to get to non-native code (more complicated code)
- Much better documentation
- More stable libraries (less bugs)
- Requires only DirectX 8 or so

There are two articles on the above codeproject link on using this.

3) Use Windows Media Player ActiveX control
I've only used this slightly, didn't have much success myself.

http://msdn.microsoft.com/library/de...9seriessdk.asp
I'll be happy to answer any more detailed (or more specific) questions that
you have.

--
Mike Mayer
http://www.mag37.com/csharp/
mi**@mag37.com

Nov 15 '05 #2
For video:

Solution #1 is optimal. It is no different from using the Interop library
for DirectShow, the only big difference is that the DX team custom coded a
type library wrapper rather than have one that is auto-generated. This
means they do a lot of the marshalling of various types for you to make your
life easier, and supposedly make the libraries run faster. In most cases,
Managed DirectX is 97% the speed of DirectX accessed through C#. There are
some issues if you are constantly loading resources or changing vertex
buffers since all of this stuff has to be marshalled, but that can be
optimized out in most cases (basically, this can be optimized out for most
cases where you would use C# instead of C++).

Solution #2 is a bit more kludgy than solution #1. You have to learn what
kinds of types are expected in many cases, especially where IntPtr's are
being used and you have to pass things using memory. It is pretty solid
(though so is solution #1, I'm not sure which problems Mike is having) and
you shouldn't have too many problems once you get the initial playback
working.

Solution #3 is probably the easiest. You can use a type library wrapper
around the various components that ships with Media Player and have it play
all of your video back for you. If done correctly you can host a media
player control right inside of your Windows Forms application and fully
customize the playback UI if you desire. I'd say #3 is going to give you
the broadest support for Video, while #1 and #2 are going to offer you more
customization (placing filters in the DirectShow stream for example that
modify the output).

If video is really turning into a big problem for people in the Managed
world speak up. I'd be happy to sit down and write up a couple of tutorials
surrounding the kinds of things I've done with video. I'm guessing most
people haven't put a large amount of time into examining video since the
time to place it in an application versus the pay-off isn't spectacular.

--
Justin Rogers
DigiTec Web Consultants, LLC.
"Michael Mayer" <mi**@mag37.com> wrote in message
news:eI*************@TK2MSFTNGP11.phx.gbl...
"Dafna m" <mo***@012.net.il> wrote in message
news:eX***************@tk2msftngp13.phx.gbl...
Please HELP

1. How can I display an array of images from diffrent types(jpeg,
bmp..)(In C#)
Can I also display video files?(In C#)
There are many ways to do this. See PictureBox, and the classes Image and
Bitmap. Note that Bitmap can load from files from many, many types.

This link should give you more than enough info for what you want for
pictures.
http://www.codeproject.com/cs/media/

I'd first look at the article "How to load/display images"
http://www.codeproject.com/cs/media/quickview.asp

As for videos, you have three choices (probably more than this)
1) Managed DirectX 9 and the AudioVideoPlayback class
- Uses all C# code
- Documentation is not very good
- Lots of annoying bugs in the library.
- Requires DirectX 9 is installed on clients.

Here's DirectX9 SDK link:

http://www.microsoft.com/downloads/d...displaylang=en
I found I had to use a LOT of workarounds to get the AudioVideoPlayback to
"play" nicely - but that was only when I started messing with the volume
level of the sound. If you don't mess with volume, it's not too hard to get this working.

2) DirectX DirectShow and interop
- Uses Interop to get to non-native code (more complicated code)
- Much better documentation
- More stable libraries (less bugs)
- Requires only DirectX 8 or so

There are two articles on the above codeproject link on using this.

3) Use Windows Media Player ActiveX control
I've only used this slightly, didn't have much success myself.

http://msdn.microsoft.com/library/de...9seriessdk.asp

I'll be happy to answer any more detailed (or more specific) questions that you have.

--
Mike Mayer
http://www.mag37.com/csharp/
mi**@mag37.com

Nov 15 '05 #3
"Justin Rogers" <Ju****@games4dotnet.com> wrote in message
news:%2***************@TK2MSFTNGP09.phx.gbl...
<snip>
If video is really turning into a big problem for people in the Managed
world speak up. I'd be happy to sit down and write up a couple of tutorials surrounding the kinds of things I've done with video. I'm guessing most
people haven't put a large amount of time into examining video since the
time to place it in an application versus the pay-off isn't spectacular.

--
Justin Rogers
DigiTec Web Consultants, LLC.


I'd be curious to see what you've done. I wrote a screensaver to show both
my jpg's and avi's from my camera (can be found here:
http://www.mag37.com/projects/screensaver/ - plug, it also does all kinds
of other things including rotating and skipping files)

I spent a lot of time trying to get the Video class to play nicely with
GDI+. That is, after playing a video, I needed to Dispose the video object
so that I could use the screen for Graphics.DrawImage calls.

My first problem was how to call Dispose for a video class. Ideally, I
would do it as a result of the Ending event. However, if I actually put a
call to Dispose in the Ending event handler function, then I'd get terrible
exceptions when my method returned (and the "calling" video class that
called my event was suddenly disposed). So instead I set a timer in the
Ending event, and had that timer dispose the Video class.

Later, when I wanted to mute the audio of the video class, I ran into more
problems. It turns out you can't even look at the Audio property of a Video
class without screwing it up. I got workarounds to get the Ending event to
fire again. But video.Dispose() still doesn't work if you do
video.Audio.anything.

I finally went to two separate forms - one for Graphics.DrawImage and one
for Video playing, with the two forms being made visible or not as needed.
I still have sporadic errors popping up when I close my application, if I
have avi video files play.

I'd like a more elegant solution - thought maybe DirectShow might work
better, but haven't gotten around to it yet.

I'd be happy to work with you on tutorials and post and/or give you some of
my code and workarounds - especially for dealing with Audio in a Video
class. Although a lot of my code is specific to trying to handle both video
and images.

--
Mike Mayer
http://www.mag37.com/csharp/
mi**@mag37.com

Nov 15 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Tyrone Slothrop | last post by:
I am coding a site which involves uploading images. All of the PHP and display is OK but the client wants to be able to display the image thumbnail on the upload page and show the full image on...
4
by: Kevin Myers | last post by:
Hello, Please forgive my reposting of this note with hopefully a more relevant subject line. On an Access 2000 form under Windows 2000 I would like to use a Kodak Image Edit Control to...
2
by: John Do | last post by:
Hi, I want to store the path and the name of the images in a sql 2000 database and all the images in a folder named images. And then I want to display all the images in a datagrid. Does any one...
5
by: Peter Lapic | last post by:
I have to create a image web service that when it receives an imageid parameter it will return a gif image from a file that has been stored on the server. The client will be an asp.net web page...
4
by: drew197 | last post by:
I am a newbie. I am editing someone elses code to make it compatible with Firefox and Safari. In IE, when you click on the proper link, a block of text is shown in a nice paragraph form. But, in...
0
by: adubra | last post by:
Hi there, I am using a device context (DC) and a buffer to successfully draw to screen. However, when I update the DC at very high frame rate and drag the frame containing the image very quickly...
2
by: Randy | last post by:
Hi, I have a small table - 2 columns, 5 rows. Col 1 is the key column and has integer values of 1 through 5. Column 2 is a varbinary(MAX) column and has jpg images loaded in it. What I want...
11
by: Jankie | last post by:
I need to dispaly a user's multiple images in one entry.Right now,say if a user uploads 3 images,three entries for the same id display to match 3 images. I only want 1 entry to display all of a...
2
by: wreed06 | last post by:
Hello, I have 2 problems. In my webpage, I have a dropdown list with a button that takes the user to a popup window specific to the option. I am using Firefox 2.0.0.13. I have successfully...
6
by: Geoff Cox | last post by:
Hello, I am using the following css ..hiddenDiv2 { display: none; } ..visibleDiv2{ display: inline;
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.