question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Save image from unmanage pointer

See original GitHub issue

I use ffmpeg.autogen for receiving a frame from a video and want to continue to keep this frame in the picture. But I only get a pointer to the frame, how can I save it using Magic.Net? Bitmap was overloading the receive pointer to raw.

Example with Bitmap:

ffmpeg.sws_scale(
                this.pSwsContext,
                (byte*[])this.pDecodedFrame->data,
                (int[])this.pDecodedFrame->linesize,
                0,
                this.Height,
                (byte*[])this.scaledData,
                (int[])this.scaledLinesize);


            var data = new byte_ptrArray8();
            data.UpdateFrom(this.scaledData);
            var linesize = new int_array8();
            linesize.UpdateFrom(this.scaledLinesize);

            var bitmapFrame = new Bitmap(this.Width, this.Height, linesize[0], PixelFormat.Format24bppRgb, (IntPtr)data[0]);

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
tttrrryyyyeercommented, Jun 22, 2019

@dlemstra Thank you, again!

1reaction
dlemstracommented, Jun 21, 2019

The storage type should be Char and the pixel mapping BGR.

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - Creating an image from an unmanaged buffer
I need to display an image in a WPF application written in C#. The image content is generated by an external unmanaged library, ......
Read more >
how can I save a raw image files from bytes and pointers?
How can I save a raw image files from bytes and pointers? ... int value = Marshal.ReadByte(pMem); int size = width*height*bpp/8; byte[] abr...
Read more >
How to save InPtr to a raw file? - C# / C Sharp
I wish to save this image data pointed by the IntPtr to a raw data file. The way I now to that is:...
Read more >
How to save InPtr to a raw file?
Hello gurus, I have a System.IntPtr pointing to the memory address of my image (not a ..NET image). I wish to save this...
Read more >
Get RAW Image from C++ Memory Pointer
1) Get the Image · 2) convert it to jpeg · 3) save it to hard disk
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found