同时对截下的图像实现缩放处理。

解决方案 »

  1.   

    我刚好在做
    源代码如下  hRet := DirectDrawCreateEx( nil, m_pDirectDraw, IID_IDirectDraw7, nil );
      if hRet <> DD_OK then
      begin
        MessageBox(self.Handle,'创建DirectDraw对象失败','警告',MB_OK);
        Application.Terminate;
      end;  hRet := m_pDirectDraw.SetCooperativeLevel(GetDesktopWindow(), DDSCL_EXCLUSIVE or DDSCL_FULLSCREEN);
      if (hRet <> DD_OK) then
      begin
        MessageBox(self.Handle,'设置占用方式失败','警告',MB_OK);
        Application.Terminate;
      end;  ddsd.dwSize := sizeof(ddsd);
      ddsd.dwFlags := DDSD_CAPS or DDSD_BACKBUFFERCOUNT;
      ddsd.ddsCaps.dwCaps := DDSCAPS_PRIMARYSURFACE or DDSCAPS_FLIP or DDSCAPS_COMPLEX;
      ddsd.dwBackBufferCount := 1;
      hRet := m_pDirectDraw.CreateSurface( ddsd, m_pDDSPrimary, nil );
      if (hRet <> DD_OK) then
      begin
        MessageBox(self.Handle,'创建主页面失败','警告',MB_OK);
        if(m_pDirectDraw <> nil ) then
           m_pDirectDraw:=nil;
        Application.Terminate;
      end;
      ddsd2.dwSize := sizeof(ddsd2);
      ddsd2.dwFlags := DDSD_WIDTH or DDSD_HEIGHT or DDSD_CAPS;
      ddsd2.dwWidth := GetSystemMetrics(SM_CXSCREEN);
      ddsd2.dwHeight := GetSystemMetrics(SM_CYSCREEN);
      ddsd2.ddsCaps.dwCaps :=DDSCAPS_SYSTEMMEMORY or DDSCAPS_OFFSCREENPLAIN;
      hRet := m_pDirectDraw.CreateSurface(ddsd2,m_pDDSBack,nil);
      if (hRet <> DD_OK) then
        begin
          MessageBox(self.Handle,PChar(DDErrorString(hRet)),'创建缓冲页面失败',MB_OK);
          exit;
        end;  lpSrcRect := Rect(0,0,GetSystemMetrics(SM_CXSCREEN),GetSystemMetrics(SM_CYSCREEN));
       lpRect := Rect(0,0,160,120);
        hRet := m_pDDSBack.Blt(@lpRect,m_pDDSPrimary,@lpSrcRect,DDBLTFAST_DONOTWAIT,nil);   hret:=m_pDDSBack.GetDC(bdc);
        b:=TBitMap.Create;
        b.Width := 160;
        b.Height := 120;
        bitblt(b.Canvas.Handle,0,0,160,120,bdc,0,0,SRCCOPY);
        m_pDDSBack.ReleaseDC(bdc);