Directdraw:旋转视频流 [英] Directdraw: Rotate video stream

查看:197
本文介绍了Directdraw:旋转视频流的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题

http://stackoverflow.com/questions/2318390/windows-mobile-directdraw-rotate-video-stream

视频预览是工作,我现在需要的是一种方法来旋转图像。我认为处理这个的唯一方法是写一个基于 CTransformFilter 的自定义过滤器,它会为你旋转相机图像。如果你能帮助我解决这个问题,例如。

The video preview is working, all I need now is a way to rotate the image. I think the only way to handle this is to write a custom filter based on CTransformFilter that will rotate the camera image for you. If you can help me to solve this problem, e.g. by helping me to develop this filter with my limited DirectDraw knowledge, the bounty is yours.

背景/上一个问题

我目前正在开发移动设备(HTC HD2,Windows Mobile 6)的应用程序。程序需要做的事情之一是使用内置相机拍摄照片。以前,我使用Windows Mobile 6 SDK提供的 CameraCaptureDialog 执行此操作,但我们的客户需要一个更加用户友好的解决方案。

I'm currently developing an application for a mobile device (HTC HD2, Windows Mobile 6). One of things the program needs to do is to take pictures using the built-in camera. Previously I did this with the CameraCaptureDialog offered by the Windows Mobile 6 SDK, but our customer wants a more user-friendly solution.

这个想法是在控件中预览摄像机的视频流,并在单击控件时使用摄像机的照片功能拍摄高分辨率图片(> = 2百万像素)。我们做了一些关于这个主题的研究,发现最好的方式来完成这似乎是使用Direct Draw。

The idea is to preview the camera's video stream in a control and take a high resolution picture (>= 2 megapixels) using the camera's photo function, when the control is clicked. We did some research on the topic and found out the best way to accomplish this seems to be using Direct Draw.

缺点是我从来没有真正使用任何本机Windows API和我的C ++是相当糟糕。除此之外,我读的地方,HTC手机的Direct Draw支持是特殊的,你必须使用无证的本地HTC库调用,以拍摄高质量的图片。

The downsides are that I never really used any native windows API and that my C++ is rather bad. In addition to this I read somewhere that the Direct Draw support of HTC phones is particularity bad and you will have to use undocumented native HTC libraries calls to take high quality pictures.

好消息是,公司提供给我们开发符合上述规格的控制。他们估计需要大约10天时间,这将导致讨论,如果我们可以在合理的时间内开发这个控制自己。

The good news is that a company offered us to develop a control that meets the specifications stated above. They estimated it would take them about 10 days, which lead to the discussion if we could develop this control ourself within a reasonable amount of time.

现在是我的研究工作哪个选择更好。不用说,研究整个架构并开发的时间太少了一个演示,其中涉及以下问题:

It's now my job to research which alternative is better. Needless to say it's far too less time to study the whole architecture and develop a demo, which lead me to the following questions:

问题不再相关!


  • 您有任何人有类似项目的经验吗?您的建议是什么?

  • 是否有一个很好的Direct Draw源代码示例处理视频预览和图片捕获?

推荐答案

好吧,如果你看看EZRGB24示例,你会得到一个简单的视频变换过滤器的基础。

Well if you look at the EZRGB24 sample you get the basics of a simple video transform filter.

有两件事你需要做的样本,让它做你想做的。

There are 2 things you need to do to the sample to get it to do what you want.

1)您需要将x,y复制到y,x。

2)您需要告诉媒体示例,示例现在是高度x宽度,而不是宽度x高度。

1) You need to copy x,y to y,x.
2) You need to tell the media sample that the sample is now Height x Width instead of Width x Height.

请记住,最终的图片将具有完全相同的像素数。

Bear in mind that the final image will have exactly the same number of pixels.

要解决1比较简单。您可以通过x +(y * Width)计算像素的位置。所以你通过每个x和y计算位置,然后写入y +(x *高度)。这将转置图像。当然没有step2这将看起来完全错误。

To solve 1 is relatively simple. You can calculate the position of a pixel by doing "x + (y * Width)". So you step through each x and y calculate the position that way and then write it to "y + (x * Height)". This will transpose the image. Of course without step2 this will look completely wrong.

要解决2,你需要得到输入样本的AM_MEDIA_TYPE。然后,您需要找出formatType是什么(可能是FormatType_VideoInfo或FormatType_VideoInfo2)。因此,您可以将AM_MEDIA_TYPE的pbFormat成员转换为VIDEOINFOHEADER或VIDEOINFOHEADER2(取决于FormatType)。您现在需要将VIDEOINFOHEADER [2] :: bmiHeader.biWidth和biHeight设置为输入媒体采样的biHeight和biWidth(分别)。其他一切都应该与输入AM_MEDIA_TYPE相同。

To solve 2 you need to get the AM_MEDIA_TYPE of the input sample. You then need to find out what the formatType is (Probably FormatType_VideoInfo or FormatType_VideoInfo2). You can thus cast the pbFormat member of AM_MEDIA_TYPE to either a VIDEOINFOHEADER or a VIDEOINFOHEADER2 (Depending on the FormatType). You need to now set VIDEOINFOHEADER[2]::bmiHeader.biWidth and biHeight to the biHeight and biWidth (respectively) of the input media sample. Everything else should be the same as the input AM_MEDIA_TYPE.

我希望有点帮助。

这篇关于Directdraw:旋转视频流的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆