Note that there are some explanatory texts on larger screens.

plurals
  1. POISampleGrabberCB::Sample not working
    primarykey
    data
    text
    <p>I am trying to convert every frame I get from my sample grabber into a bitmap however it does not seem to work.</p> <p>I am using the <code>SampleCB</code> as follows:</p> <pre><code>int ISampleGrabberCB.SampleCB(double SampleTime, IMediaSample sample) { try { int lengthOfFrame = sample.GetActualDataLength(); IntPtr buffer; if (sample.GetPointer(out buffer) == 0 &amp;&amp; lengthOfFrame &gt; 0) { Bitmap bitmapOfFrame = new Bitmap(width, height, capturePitch, PixelFormat.Format24bppRgb, buffer); Graphics g = Graphics.FromImage(bitmapOfFrame); Pen framePen = new Pen(Color.Black); g.DrawLine(framePen, 30, 30, 50, 50); g.Flush(); } CopyMemory(imageBuffer, buffer, lengthOfFrame); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } Marshal.ReleaseComObject(sample); return 0; } </code></pre> <p>I am drawing a small graphic on it as a tester and it does not seem to work. From what I believe this should be adding a small line to each frame therefore updating my preview with the line.</p> <p>I can give additional code if needed (e.g How i set up my graph and connect my ISampleGrabber)</p> <p>Edited with what i think Dee Mon means:</p> <pre><code>int ISampleGrabberCB.SampleCB(double SampleTime, IMediaSample sample) { try { int lengthOfFrame = sample.GetActualDataLength(); IntPtr buffer; BitmapData bitmapData = new BitmapData(); if (sample.GetPointer(out buffer) == 0 &amp;&amp; lengthOfFrame &gt; 0) { Bitmap bitmapOfFrame = new Bitmap(width, height, capturePitch, PixelFormat.Format24bppRgb, buffer); Graphics g = Graphics.FromImage(bitmapOfFrame); Pen framePen = new Pen(Color.Black); g.DrawLine(framePen, 30, 30, 50, 50); g.Flush(); Rectangle rect = new Rectangle(0, 0, bitmapOfFrame.Width, bitmapOfFrame.Height); bitmapData = bitmapOfFrame.LockBits(rect, ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb); IntPtr bitmapPointer = bitmapData.Scan0; CopyMemory(bitmapPointer, buffer, lengthOfFrame); BitmapOfFrame.UnlockData(bitmapData); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } Marshal.ReleaseComObject(sample); return 0; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload