CodePudding user response:
I also asked the similar before, there is no solution,See this post:
http://bbs.csdn.net/topics/390078978
CodePudding user response:
Unanswered, not WinCE under GetBitmapBits is no, you look at other people is how to realize the similar function get data, and then in the same way under Windows screenshots, after the most is the problem and BMP palette,CodePudding user response:
SupermanKing have any experience in this field, for the point code?CodePudding user response:
//GDI with DX screenshots API operations
LPDIRECTDRAW lpDD=NULL;
LPDIRECTDRAWSURFACE lpDDSPrime=NULL;
LPDIRECTDRAWSURFACE lpDDSBack=NULL;
LPDIRECTDRAWSURFACE lpDDSGdi=NULL;
LPDIRECTDRAWSURFACE lpSurf=NULL;
DDSURFACEDESC DDSdesc;
BOOL m_b24=TRUE;
//rfbServerInitMsg m_scrinfo;
The RECT m_bmrect;
Struct _BMInfo {
BITMAPINFO bmi;
BOOL truecolour;
The RGBQUAD cmap [256];
} m_bminfo;//is used to store the structure of the bitmap information
Int DX_Init () {//DirectX initialization, returns the current surface to obtain a bitmap screen storage size
Retrieves the hr;
//initialize directX
Hr=DirectDrawCreate (0, & amp; LpDD, 0);
If (FAILED (hr)) return FALSE.
Hr=lpDD - & gt; SetCooperativeLevel (NULL, DDSCL_NORMAL);
If (FAILED (hr)) return FALSE.
ZeroMemory (& amp; DDSdesc, sizeof (DDSdesc));
DDSdesc. DwSize=sizeof (DDSdesc);
DDSdesc. DwFlags=DDSD_CAPS;
DDSdesc. DdsCaps. DwCaps=DDSCAPS_PRIMARYSURFACE;
Hr=lpDD - & gt; CreateSurface (& amp; DDSdesc, & amp; LpDDSPrime, 0);
If (FAILED (hr)) return FALSE.
Hr=lpDD - & gt; GetGDISurface (& amp; LpDDSGdi);
If (FAILED (hr)) return FALSE.
ZeroMemory (& amp; DDSdesc, sizeof (DDSdesc));
DDSdesc. DwSize=sizeof (DDSdesc);
DDSdesc. DwFlags=DDSD_ALL;
Hr=lpDDSPrime - & gt; GetSurfaceDesc (& amp; DDSdesc);
If (FAILED (hr)) return FALSE.
//initialize the bitmap information
If ((DDSdesc dwFlags & amp; DDSD_WIDTH) & amp; & (DDSdesc dwFlags & amp; DDSD_HEIGHT)) {
M_bmrect. Left=m_bmrect. Top=0;
M_bmrect. Right=DDSdesc. DwWidth;
M_bmrect. Bottom=DDSdesc. DwHeight;
} the else return FALSE.
M_bminfo. Bmi. BmiHeader. BiCompression=BI_RGB;//BI_BITFIELDS;
M_bminfo. Bmi. BmiHeader. BiBitCount=DDSdesc. DdpfPixelFormat. DwRGBBitCount;
//m_bminfo truecolour=DDSdesc. DdpfPixelFormat. DwFlags & amp; DDPF_RGB;
If (m_bminfo. Bmi. BmiHeader. BiBitCount & gt; 8)
M_bminfo. Truecolour=TRUE;
The else
M_bminfo. Truecolour=FALSE;
ZeroMemory (& amp; DDSdesc, sizeof (DDSdesc));
DDSdesc. DwSize=sizeof (DDSdesc);
DDSdesc. DwFlags=DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
DDSdesc. DdsCaps. DwCaps=DDSCAPS_OFFSCREENPLAIN;
DDSdesc. DwHeight=m_bmrect. Bottom - m_bmrect. Top;
- m_bmrect DDSdesc. DwWidth=m_bmrect. Right. Left.
Hr=lpDD - & gt; CreateSurface (& amp; DDSdesc, & amp; LpDDSBack, 0);
If (FAILED (hr)) return FALSE.
//hr=lpDDSPrime - & gt; QueryInterface (IID_IDirectDrawSurface3, (LPVOID *) & amp; LpSurf);
//if (FAILED (hr)) return FALSE.
The switch (m_bminfo. Bmi. BmiHeader. BiBitCount) {
A case of 32:
Case 24:
//Update the bitmapinfo header
M_b24=TRUE;
M_bminfo. Bmi. BmiHeader. BiSize=sizeof (BITMAPINFOHEADER);
M_bminfo. Bmi. BmiHeader. BiWidth=1024;
M_bminfo. Bmi. BmiHeader. BiHeight=768;
M_bminfo. Bmi. BmiHeader. BiPlanes=1;
.//m_bminfo. Bmi. BmiHeader biBitCount=24;
M_bminfo. Bmi. BmiHeader. BiCompression=BI_RGB;
M_bminfo. Bmi. BmiHeader. BiSizeImage=abs ((m_bminfo. Bmi. BmiHeader. BiWidth * m_bminfo in bmi. The bmiHeader. BiHeight * m_bminfo in bmi. The bmiHeader. BiBitCount)/8);
M_bminfo. Bmi. BmiHeader. BiXPelsPerMeter=(1024 * 1000)/1024;
M_bminfo. Bmi. BmiHeader. BiYPelsPerMeter=(768 * 1000)/768;
M_bminfo. Bmi. BmiHeader. BiClrUsed=0;
M_bminfo. Bmi. BmiHeader. BiClrImportant=0;
break;
}
Return m_bminfo. Bmi. BmiHeader. BiSizeImage;
}
BOOL CaptureScreen (the RECT & amp; The rect, BYTE * scrBuff, UINT scrBuffSize) {//capture screen, the rect: area, scrBuff: the output buffer, scrBuffSize: buffer size
Retrieves the hr=0;
Hr=lpDDSBack - & gt; BltFast (the rect. Left, the rect. Top lpDDSPrime, & amp; The rect, DDBLTFAST_NOCOLORKEY | DDBLTFAST_WAIT);
If (FAILED (hr)) return FALSE.
DDSURFACEDESC surfdesc;
ZeroMemory (& amp; Surfdesc, sizeof (surfdesc));
Surfdesc. DwSize=sizeof (surfdesc);
Hr=lpDDSBack - & gt; The Lock (& amp; The rect, & amp; Surfdesc, DDLOCK_READONLY | DDLOCK_WAIT | DDLOCK_SURFACEMEMORYPTR/* | DDLOCK_NOSYSLOCK */, NULL);
//hr=lpDDSPrime - & gt; The Lock (& amp; The rect, & amp; Surfdesc, DDLOCK_READONLY | DDLOCK_WAIT | DDLOCK_SURFACEMEMORYPTR/* | DDLOCK_NOSYSLOCK */, NULL);
If (FAILED (hr)) return FALSE.
//copy the data into our buffer
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull