From 62a9e0d0574ac99302821efcd0ecc9f226badd30 Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Sat, 25 Mar 2006 23:40:09 +0000 Subject: [PATCH] convert AVFrame via wxImage on non-windoze Originally committed to SVN as r243. --- core/video_provider_lavc.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/core/video_provider_lavc.cpp b/core/video_provider_lavc.cpp index 7fe23077a..2df218537 100644 --- a/core/video_provider_lavc.cpp +++ b/core/video_provider_lavc.cpp @@ -231,7 +231,11 @@ wxBitmap LAVCVideoProvider::AVFrameToWX(AVFrame *source) { // Get sizes int w = codecContext->width; int h = codecContext->height; +#ifdef __WINDOWS__ PixelFormat format = PIX_FMT_RGBA32; +#else + PixelFormat format = PIX_FMT_RGB24; +#endif unsigned int size1 = avpicture_get_size(codecContext->pix_fmt,display_w,display_h); unsigned int size2 = avpicture_get_size(format,display_w,display_h); @@ -275,7 +279,15 @@ wxBitmap LAVCVideoProvider::AVFrameToWX(AVFrame *source) { img_convert((AVPicture*) frameRGB, format, (AVPicture*) resized, codecContext->pix_fmt, w, h); // Convert to wxBitmap +#ifdef __WINDOWS__ wxBitmap bmp((const char*) frameRGB->data[0],w,h,32); +#else + wxImage img(w, h, false); + unsigned char *data = (unsigned char *)malloc(w * h * 3); + memcpy(data, frameRGB->data[0], w * h * 3); + img.SetData(data); + wxBitmap bmp(img); +#endif av_free(frameRGB); if (resized != source)