Home > Back-end >  The VFW FrameCallback StretchDIBits display problems
The VFW FrameCallback StretchDIBits display problems

Time:10-20

Camera image shows on Panel1, wanted to intercept every frame display on Panel2, but

Image bit depth (BitmapInfo. BmiHeader. BiBitCount) to 16, show images of colorful, to 8 also showed that the distortion, but more when is 24, why does not display, please help solve, image 24 when how can display the

The code is as follows:


LRESULT PASCAL FrameCallbackProc (HWND CapWnd, LPVIDEOHDR lpVHDR)
{
Int nHeight=Capstatus. UiImageHeight;
Int nWidth=Capstatus. UiImageWidth;
BITMAPINFO BITMAPINFO;
ZeroMemory (& amp; BitmapInfo, sizeof (BitmapInfo));
BitmapInfo. BmiHeader. BiSize=sizeof (BitmapInfo bmiHeader);
BitmapInfo. BmiHeader. BiWidth=nWidth;//image width
BitmapInfo. BmiHeader. BiHeight=- nHeight;//image height
BitmapInfo. BmiHeader. BiPlanes=1;
BitmapInfo. BmiHeader. BiBitCount=16;//image depth

HDC HDC=GetDC (Form1 - & gt; Panel2 - & gt; Handle);
SetStretchBltMode (HDC, COLORONCOLOR);
StretchDIBits (
HDC,
0, 0, nWidth, nHeight,
0, 0, nWidth, nHeight,
LpVHDR - & gt; LpData,
& BitmapInfo,
0, SRCCOPY);
return NULL;
}

CodePudding user response:

The sentence:
SetStretchBltMode (HDC, COLORONCOLOR);
To:
SetStretchBltMode (HDC, HALFTONE); Try

CodePudding user response:

reference 1st floor tst1255 response:
this sentence:
SetStretchBltMode (HDC, COLORONCOLOR);
To:
SetStretchBltMode (HDC, HALFTONE); Try


Thank you for your reply, however, such modified or old

CodePudding user response:

Whether lpVHDR - & gt; Put the lpData is YUV format of the data

CodePudding user response:

This is bad to say, you can estimate for the image of the color figures,
K=lpVHDR - & gt; DwBytesUsed/Width/Height
If k is 1 is 8-bit color, should be a 8-bit grayscale!
2 is a 16-bit, said YUV or 16-bit color I'm not sure
Is 3 is a 24-bit color, this basically is RGB

Learn about the color figures,

This function if can obtain image formats, you try: capGetVideoFormat ()

CodePudding user response:

CapGetVideoFormat take 16. Not the YUV data

Because panel1 display is normal, is 32 bit.

CodePudding user response:

K=lpVHDR - & gt; DwBytesUsed/Width/Height
Calculate how much is?

CodePudding user response:

Your camera support capSetVideoFormat set your own format?

If it is a 16-bit, mostly YUV, YUV is need you to set up a buffer zone, convert RGB,

CodePudding user response:

Use capSetVideoFormat set to RGB24 YUYV or color so that color format to be more clear, if we can set to RGB24 after treatment, but a lot of USB camera does not support this format in order to improve the speed, mostly YUYV format,

CodePudding user response:

refer to 6th floor tst1255 response:
k=lpVHDR - & gt; DwBytesUsed/Width/Height
Calculate how much is?

2

CodePudding user response:

Probably YUYV format, the need to transform can with GDI show that

YUYV expressed in 4 bytes two pixels of YUV component, two of the said two pixel luminance Y component, UV component for sharing two pixels,
YUYV combined into two YUV color, and then into a two RGB, and then, according to
I got a conversion formula:
B=Y + 2.032 * U
R=Y + 1.140 * V
G=Y U - 0.589-0.3946 * * V

Conversion may affect the rate of display, need to optimize hair, such as look-up table,

CodePudding user response:

Can you specific points?
Still don't know how to change my is
this issue
  • Related