Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9091845
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T22:42:23+00:00 2026-06-16T22:42:23+00:00

In order to render a DirectShow graph in my WPF application, I use a

  • 0

In order to render a DirectShow graph in my WPF application, I use a sample grabber to write a bitmap to memory, and read it elsewhere in code. This may seem as a wierd solution, but seems to be the only way to get a WPF brush out of it.

The following code gives me the information I need about the bitmap:

AMMediaType mt = grabber.GetConnectedMediaType();
VideoInfoHeader header = (VideoInfoHeader)Marshal.PtrToStructure(mt.formatPtr, typeof VideoInfoHeader);
header.BmiHeader // ...

Now, header.BmiHeader is of type BitmapInfoHeader and provides information such as the width and height of the bitmap. I need this information to write the bitmap to memory.

However, this code does not seem to work always. For example, when the sample grabber filter is connected to a MPEG-2 Program Stream pin, header will be null. Why does my code not work with certain media types, and what other ways are there to get it’s BitmapInfoHeader structure?

Please note that even though I am using the directshow.net library, answers in C++ are also welcome.

Edit: This is how my graph looks like:

*source* -> MPEG2-Demultiplexer -> SampleGrabber -> MS DTV-DVD Video Decoder -> Video Renderer

I’m not allowed to place the grabber between the decoder and renderer. About the demux’s video pin:

Major Type: Video

Sub Type: MPEG2_VIDEO
Format: MPEG2Video

After I have connected the sample grabber, it’s input pin also has the above media type. When I open this graph file in my application and use grabber.GetConnectedMediaType();, I also get the same media type. However, the formatPtr or (pbFormat in C++) of this media type is 0.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T22:42:25+00:00Added an answer on June 16, 2026 at 10:42 pm

    If you want a bitmap, you need to place the sample grabber somewhere where you receive uncompressed video. When the samplegrabber is behind the MPEG-2 Program Stream pin, you will receive a mpeg2 program stream. Of course it it possible to get a bitmap out of that, but then you need to demultiplex and decompress manually. Both are task which you want to perform in the directshow filter.

    But even if you receive uncompressed video, you might still get different formats. depending on the decoder you can receive RGB24, YUY2, YV12, … Check the MediaSubType for what you exactly receive. If you always want to receive RGB24, you can use the RGBFilters/TransNull24 filter which is included in the sdk. See also this answer.

    Edit: One additional note, if you not only want the resolution, but also the bitmap itself, you have to put the samplegrabber between the decoder and renderer. If the MS Decoder is not working, try ffdshow.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

in order to recover data from server I use XMLHttpRequest and my code is
I'm about to design a Zend web application which, in order to render its
I am looking for a solution\software that I can use in order to render
I'm building a website which will use files in order to render social graphs.
What is the best practice is in the case of altering the render order
In order to do object picking in OpenGL, do I really have to render
Im using a couple of JSON calls to render data, etc etc. In order
The FlipView's docs mention that it needs an absolute size in order to render,
I'm using FreeType2 in one of my projects. In order to render a letter,
I have two questions on the render order of the partial view If I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.