Displaying frames of pixel data

28 Views Asked by At

Let's assume I am creating an application that decodes some form of video. I've successfully created the frame, the controls, the event handlers for the controls, everything is there except for the actual rendering of the frame.

My decoding backend delivers a pointer to the frame's raw pixel data in memory -- uint32_t * width * height.

I have tried to figure out how I would go from here to displaying that frame in my app, but I can't really put the building blocks together. I've seen wxImage, wxBitmap, wxClientDC, wxGraphicsContext, and several other wx classes that might or might not need to be involved in this, and I am still fuzzy about whether I would need a specific wx control to eventually display the frame in / on, or if I would just somehow leave enough empty space on the wxWindow and render to that space itself.

I'm not asking for finished code, but rather the architectural idea in plain English. When I tried searching for documentation more specific to my problem, I ended up with either wxMediaCtrl or wxAnimationCtrl -- neither of which is what I want since I need my own specific controls -- or with drawing primitives on a bitmap (like rectangles, curves etc.) instead of blitting or displaying bitmaps.

What would be a sound way of rendering frames of raw pixel data in a wxWidgets application?

1

There are 1 best solutions below

0
VZ. On

There are 2 ways to do what you want achieving decent performance:

  1. Use OpenGL via wxGLCanvas. I won't go into details here as you can easily find examples of using OpenGL to show bitmaps.
  2. Use wxPixelData to get "raw" access to wxBitmap internal data, then draw this bitmap in your wxEVT_PAINT handler. See example of doing it in the image sample.

Using wxImage is simpler but adds another conversion making it much slower than the alternatives.