StretchDIBits();有关图像扫描的帮助 [英] StretchDIBits() ; Help related to image scan

查看:88
本文介绍了StretchDIBits();有关图像扫描的帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello All,



一般想法: - 我正在开发应用程序win32 cleint服务器类型(就像桌面监控一样)。



在服务器端,我正在拍摄屏幕截图。 &安培;发送到客户端。



在服务器端我有功能代码如

------------ --------------------------------

|

|

|

Hello All,

General Idea:- I am developing application win32 cleint server type (It is like desktop monitoring ).

On server side I am takeing screen shot. & sending it to client side.

On server side I have function code like
--------------------------------------------
|
|
|

hdc1 = GetDC(NULL);
    hdc2 = CreateCompatibleDC(hdc1);
    GetWindowRect(GetDesktopWindow(), &rc);
    w = rc.right-rc.left;
    h = rc.bottom-rc.top;

    bmih.biSize = sizeof(BITMAPINFOHEADER);
    bmih.biWidth = w;
    bmih.biHeight = h;
    bmih.biPlanes = 1;
    bmih.biBitCount = 24;
    bmih.biCompression = BI_RGB;
    bmih.biSizeImage = ((((bmih.biWidth * bmih.biBitCount) + 31) & ~31) >> 3) * bmih.biHeight;
    bi.bmiHeader = bmih;

    aBmp = CreateDIBSection(hdc1, &bi ,DIB_RGB_COLORS, (void**)&dibvalues, NULL, NULL);
    OldObj = SelectObject(hdc2, aBmp);
    BitBlt(hdc2, 0, 0, w, h, hdc1, 0, 0, SRCCOPY);



////////// ////////////////////////////////////////////////// //







我上课类似




//////////////////////////////////////////////////////////////



I have class like

class DesktopScreen
{
public:
    BITMAPINFOHEADER bmih ;
    BITMAPINFO bi;
     unsigned char  dibvalues[lenght];
    };







------------------------------------------------- -----------------



使用上面的代码我正在填写这个类的对象&发送到另一边



二进制格式(字节)。



在客户端反序列化也是好的(我在调试时检查所有值)



现在WM_Paint:

hDC = BeginPaint(hWnd,& Ps) ;




------------------------------------------------------------------

using above code I am filling Object of this class & sending it to other side

in binary formate (byte).

On Client side deserializing is also OK (I check all value at time of debuging )

Now at time WM_Paint:
hDC = BeginPaint(hWnd, &Ps);

i=  StretchDIBits(hDC,
                         // destination rectangle
                         0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN),
                         // source rectangle
                         0, 0,desktopObj.bmih.biWidth , desktopObj.bmih.biHeight,
                         desktopObj.dibvalues,
                         &desktopObj.bi,
                         DIB_RGB_COLORS,
                         SRCCOPY);





///////////// /////////////////////////////////// //////////////////////////



StretchDIBits返回0。



应用程序运行正常,但图像没有显示。



如果我在服务器端调用StretchDIBits传递相同的信息那个功能。我正在展示。





你能告诉我应该是什么问题。



(很抱歉发布代码,但我认为有必要向我提问)



谢谢,

Ashish。



//////////////////////////////////////////////////////////////////////////

StretchDIBits is returning 0 .

Application run properlly but image is not displying.

also if i call StretchDIBits on server side passing same info to that function.I mages is displaying.


Can you please tell me what should be the problem.

( sorry for posting code ,but I think it is necessary to get my Question to you )

Thanks ,
Ashish.

推荐答案

我自己也没试过。



首先,确保在客户端代码中正确初始化BITMAPINFO和BITMAPINFOHEADER。 ZeroMemory()它们在你放置值之前要确定。



其次要确保你正确地重建了dibval​​ues中位图数据的字节顺序。 CMIIW,对于BI_RGB 24位,每个像素都存储为BGR格式而不是RGB。
Haven''t try it myself.

First, make sure that you intialized BITMAPINFO and BITMAPINFOHEADER properly in client side code. ZeroMemory() them to make sure before you put values.

Second make sure that you properly reconstruct byte order of bitmap data in dibvalues. CMIIW, for BI_RGB 24 bit, each pixel is stored as BGR format rather than RGB.


这篇关于StretchDIBits();有关图像扫描的帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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