浏览代码

Hopefully fixed videos on non-32bpp displays.

Michał W. Urbańczyk 15 年之前
父节点
当前提交
527a0ef4d6
共有 1 个文件被更改,包括 10 次插入1 次删除
  1. 10 1
      hch/CVideoHandler.cpp

+ 10 - 1
hch/CVideoHandler.cpp

@@ -732,9 +732,18 @@ bool CVideoPlayer::open(std::string fname, bool loop, bool useOverlay)
 							 codecContext->pix_fmt, codecContext->width, codecContext->height, 
 							 PIX_FMT_YUV420P, SWS_BICUBIC, NULL, NULL, NULL);
 	} else {
+		PixelFormat screenFormat = PIX_FMT_NONE;
+		switch(screen->format->BytesPerPixel)
+		{
+		case 2: screenFormat = PIX_FMT_RGB565; break;
+		case 3: screenFormat = PIX_FMT_RGB24; break;
+		case 4: screenFormat = PIX_FMT_RGB32; break;
+		default: return false;
+		}
+
 		sws = sws_getContext(codecContext->width, codecContext->height, 
 							 codecContext->pix_fmt, codecContext->width, codecContext->height, 
-							 PIX_FMT_RGB32, SWS_BICUBIC, NULL, NULL, NULL);
+							 screenFormat, SWS_BICUBIC, NULL, NULL, NULL);
 	}
 
 	if (sws == NULL)