简体   繁体   English

setDIbitstodevice Turbo C++

[英]setDIbitstodevice Turbo C++

The program I have uses setDIbitstodevice for the camera.我的程序使用setDIbitstodevice作为相机。
I see that the code is written as:我看到代码写成:

SetDIBitsToDevice( PaintBox->Canvas->Handle, 0, 0, 160, 120,
    0, 0, 0, 120,
    Image, 
    ( LPBITMAPINFO )&mapHead, DIB_RGB_COLORS );

And:和:

Image = new unsigned char [ 160 * 120 * 4 ]

I do not know what does it mean.我不知道这是什么意思。 I was told that if I change Image to other form of unsigned char , the picture display would change as well but I did that and I couldn't get anything.有人告诉我,如果我将Image更改为其他形式的unsigned char ,图片显示也会改变,但我这样做了,但我什么也得不到。

Please advice, thanks.请指教,谢谢。

unsigned char has size of a byte in turbo C++, so the 'Image = new... ' line is assigning some memory to Image, which is 160 pixels wide, by 120 pixels high, and 4 bytes deep. unsigned char 在 turbo C++ 中的大小为一个字节,因此“Image = new...”行将一些 memory 分配给 Image,该图像宽 160 像素,高 120 像素,深 4 字节。 The 4 bytes will be one byte each for red, green, blue and alpha channel (although these don't support an alpha channel so I don't think that's quite right - but it's allocating more memory than necessary, so it wont crash, but it's probably wasting memory).红色、绿色、蓝色和 alpha 通道的 4 个字节各为一个字节(尽管这些不支持 alpha 通道,所以我认为这不太正确 - 但它分配的 memory 比必要的多,所以它不会崩溃,但它可能会浪费内存)。

Now SetDIBitsToDevice takes the pixels in the Image and displays it to the paintbox (via the handle).现在 SetDIBitsToDevice 获取 Image 中的像素并将其显示到画框(通过句柄)。 Tee parameters are the size of the destination and so on (see http://msdn.microsoft.com/en-us/library/dd162974(VS.85).aspx ). Tee 参数是目标的大小等(参见http://msdn.microsoft.com/en-us/library/dd162974(VS.85).aspx )。 If you want to stretch the bitmap (ie change the displayed size) then have a look at StretchDIBits http://msdn.microsoft.com/en-us/library/dd145121(v=VS.85).aspx .如果您想拉伸 bitmap(即更改显示大小),请查看 StretchDIBits http://msdn.microsoft.com/en-us/library/dd145121(v=VS.85).aspx

hth hth

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM