CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    May 2010
    Posts
    83

    gdi+ image resizing

    hi,

    i have spent a couple of fruitless hours on this, maybe someone can help...

    My main aim is to create screenshot of my screen, re-size it & save it to a file.


    Dumping a screenshot into HBITMAP & saving that to disk works fine, however, changing the resolution wont work.

    I can change the resolution of a image using the DrawImage() method of a Graphics object, but i can only Draw in an Image* object...not in a HBITMAP.

    I fail at creating an empty Image* object.



    HDC tmp= GetDC(0);
    Graphics grr(tmp);
    Image mim;//error
    grr.DrawImage(&mim, 100, 100;
    mim.Save(L"C:\\asdfasdf.jpg",0,0);


    this code should take a screenshot, select ti into a Graphics object, and draw it into the image "mim" with an resolution of 100x100, but fails already at creating an empty image.


    so how can i create an empty image?

  2. #2
    Join Date
    Feb 2011
    Posts
    32

    Re: gdi+ image resizing

    Because mim does not contain anything! That means your tmp fails to get a snapshot, which also means your provided snippet is incorrect. Supply us a more correct sample that actually works. And instead of creating an empty image then draw the scaled picture on it, I suggest you scale the taken snapshot into a placeholder of any size you want.

  3. #3
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,234

    Re: gdi+ image resizing

    Quote Originally Posted by felix1432 View Post
    Image mim;//error
    Gdiplus::Image class has not a default (with no parameters) constructor.
    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: https://codexpertro.wordpress.com/

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured