save HBITMAP to file

2009 June 23

was stuck today at one point trying to save a HBITMAP to file. even the code at msdn was working weirdly with image saving as if arithmetic - left shifted by some 10 pixels.

tried to obtain bits in HBITMAP using GetDIBits but with not much luck.

ended up doing it pretty neat and simple.

HBITMAP hBmp;
Gdiplus::Bitmap gBmp(hBmp, NULL);
gBmp->Save(..) gdiplus save function directly. you can save in jpg, bmp, png anything.

working code later.. n joy,

2 Responses leave one →
  1. 2009 June 24
    Mary permalink

    Pretty good post. I just came by your site and wanted to say
    that I’ve really liked browsing your posts. Anyway
    I’ll be subscribing to your feed and I hope you write again soon!

  2. 2009 June 24
    Lotus permalink

    lol.. your comment is quite embarrassing as the post on which you put comment is incomplete. i usually write 2-3 lines to serve as draft so that I can write more on it whenever i get time.
    anyway, thanks for the perfectly sugar-coated words. i will be using some of them next time someone force me to read his blog.

Leave a Reply

Note: You can use basic XHTML in your comments. Your email address will never be published.

Subscribe to this comment feed via RSS