Screen Capture, decrease bitmap file size

1

One of the functions of the project I'm working on captures the screen of the user, however the bitmap file is getting very large, from 6MB to 8MB, it is bad to be able to send via socket or in future to make a stream by frame, someone could help me in how can I downsize this file? I'll be posting the code I'm using to capture the screen, and then save it to a file ..

    void Remote_Manip::CaptureScreen(Socket_Setup &socket_setup)
{
    int nScreenWidth = GetSystemMetrics(SM_CXSCREEN);
    int nScreenHeight = GetSystemMetrics(SM_CYSCREEN);
    HWND hDesktopWnd = GetDesktopWindow();
    HDC hDesktopDC = GetDC(hDesktopWnd);
    HDC hCaptureDC = CreateCompatibleDC(hDesktopDC);
    HBITMAP hCaptureBitmap = CreateCompatibleBitmap(hDesktopDC,
        nScreenWidth, nScreenHeight);
    SelectObject(hCaptureDC, hCaptureBitmap);
    BitBlt(hCaptureDC, 0, 0, nScreenWidth, nScreenHeight,
        hDesktopDC, 0, 0, SRCCOPY | CAPTUREBLT);

    WCHAR path[MAX_PATH];
    if (SUCCEEDED(SHGetFolderPathW(NULL, CSIDL_PROFILE, NULL, 0, path)))
    {
        std::wstring directory_create = path;
        std::string DEFAULT_DIR;

        DEFAULT_DIR.append(directory_create.begin(), directory_create.end());
        DEFAULT_DIR.append("\Pictures");
        DEFAULT_DIR.append("\image.bmp");

        LPCSTR fname = DEFAULT_DIR.c_str();
        HPALETTE hpal = NULL;
        saveBitmap(fname, hCaptureBitmap, hpal);

        ReleaseDC(hDesktopWnd, hDesktopDC);
        DeleteDC(hCaptureDC);
        DeleteObject(hCaptureBitmap);

        // fução para enviar a imagem via socket.
        FILE_DOWNLOAD(DEFAULT_DIR.c_str(), socket_setup);
    }
}
    
asked by anonymous 10.02.2015 / 18:55

0 answers