+ Post New Thread
Results 1 to 2 of 2
Coding Thread, C++ Resize hdc image in Coding and Web Development; Hi guys, I've got the following below to take a screenshot and (trying to) resize it to 800x600 which doesn't ...
  1. #1

    Join Date
    May 2008
    Location
    Cheshire
    Posts
    298
    Thank Post
    49
    Thanked 27 Times in 24 Posts
    Rep Power
    19

    C++ Resize hdc image

    Hi guys,

    I've got the following below to take a screenshot and (trying to) resize it to 800x600 which doesn't seem to work. hScreen2 comes up with a white image, hScreen comes up with the screenshot.

    Any ideas?

    Thanks,


    Code:
    const int nScreenWidth = GetSystemMetrics(SM_CXSCREEN);
    const int nScreenHeight = GetSystemMetrics(SM_CYSCREEN);
    RECT rc;
    PBITMAPINFO bmfh;
    HWND hwndDeskTop;
    hwndDeskTop=GetDesktopWindow();
    GetWindowRect(hwndDeskTop, &rc);
    HDC hdc = GetDC(hwndDeskTop);
    HDC hScreen,hScreen2;
    hScreen = CreateCompatibleDC(hdc);
    hScreen2 = CreateCompatibleDC(hdc);
    HBITMAP hCaptureBitmap = CreateCompatibleBitmap(hdc, nScreenWidth, nScreenHeight);
    SelectObject(hScreen, hCaptureBitmap);
    BitBlt(hScreen,0,0,nScreenWidth,nScreenHeight,hdc,0,0,SRCCOPY);
    SetStretchBltMode(hScreen, HALFTONE);
    if(!StretchBlt(hScreen2,800,600,rc.right,rc.bottom,hScreen,0,0,rc.right,rc.bottom,SRCCOPY))
        MessageBox(NULL,"test","", MB_OK);
    BitBlt(hScreen2,0,0,800,600,hdc,0,0,SRCCOPY);
    CreateImage(hScreen2, 800, 600);  // This function just draws the image onto the screen
    DeleteObject(hScreen);
    DeleteObject(hScreen2);
    DeleteObject(hCaptureBitmap);

  2. #2

    Join Date
    May 2008
    Location
    Cheshire
    Posts
    298
    Thank Post
    49
    Thanked 27 Times in 24 Posts
    Rep Power
    19
    It's ok I've found and fixed the solution!

SHARE:
+ Post New Thread

Similar Threads

  1. Resize an active XP partition
    By speckytecky in forum How do you do....it?
    Replies: 7
    Last Post: 16th August 2010, 11:21 AM
  2. Mass Image Resize
    By _Bat_ in forum Web Development
    Replies: 28
    Last Post: 19th February 2009, 02:14 PM
  3. resize module help..
    By RTi in forum EduGeek Joomla 1.5 Package
    Replies: 3
    Last Post: 29th January 2009, 05:29 PM
  4. Resize & Partition Vista HD
    By nawbus in forum Windows Vista
    Replies: 5
    Last Post: 12th December 2008, 09:19 AM
  5. New Forum Feature: Sliding image resize
    By ZeroHour in forum General EduGeek News/Announcements
    Replies: 14
    Last Post: 3rd April 2008, 12:01 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •