Bitmap saving problem

This is a discussion on Bitmap saving problem within the Windows Programming forums, part of the Platform Specific Boards category; Hi all! i'm trying to load an image into a dialog window, shrink it, then save that shrinked image back ...

  1. #1
    Android
    Join Date
    Mar 2004
    Location
    Kurunegala Colony, Sri Lanka, Sri Lanka
    Posts
    363

    Bitmap saving problem

    Hi all!

    i'm trying to load an image into a dialog window, shrink it, then save that shrinked image back to the disk. i shrink it like this:

    Code:
    StretchBlt(g_hMemDC, 0, 0, SCREENWIDTH, SCREENHEIGHT,hdcDesk,0,0,SCREENWIDTH*2,SCREENHEIGHT*2,SRCCOPY);
    Problem is that the dlg area which dosen't occupy the shrinked image becomes black, and when i save the image the black part is also saved as the bmp. Howto save only the shrinked image, without the black area?

    Thanx for any help.
    Some useless programs i've wrote : slprogrammersheaven
    Youtube: http://www.youtube.com/user/geekyzine
    My amature IT Blog: http://everything-geeky.blogspot.com/
    My Flash games: http://flashweed.blogspot.com/

    (and, sorry for my amature english)

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    I guess you need to resize (create another one?) your g_hMemDC?

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    Create another bitmap in memory with CreateBitmap() or whatever it is, with the new shrunk dimensions, fill it with your HDC, then save it to disk.

  4. #4
    Android
    Join Date
    Mar 2004
    Location
    Kurunegala Colony, Sri Lanka, Sri Lanka
    Posts
    363
    thx that worked.

    Code:
    ::StretchBlt(g_hMemDC, 0, 0, SCREENWIDTH, SCREENHEIGHT,hdcDesk,0,0,SCREENWIDTH*2,SCREENHEIGHT*2,SRCCOPY);
    	HBITMAP hbmpshrnk = CreateCompatibleBitmap(g_hMemDC, SCREENWIDTH/2, SCREENHEIGHT/2);
    ...
    	PBITMAPINFO bmpinfo = CreateBitmapInfoStruct(hwndgl, hbmpshrnk);
    	CreateBMPFile(hwndgl,"desktoptemp.bmp",bmpinfo,g_hDeskBmp,g_hMemDC);
    Some useless programs i've wrote : slprogrammersheaven
    Youtube: http://www.youtube.com/user/geekyzine
    My amature IT Blog: http://everything-geeky.blogspot.com/
    My Flash games: http://flashweed.blogspot.com/

    (and, sorry for my amature english)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Saving the static control's HDC into bitmap
    By Joelito in forum Windows Programming
    Replies: 2
    Last Post: 09-13-2007, 09:22 PM
  2. Loading a bitmap (Without using glaux)
    By Shamino in forum Game Programming
    Replies: 7
    Last Post: 03-16-2006, 08:43 AM
  3. ResHacker error replacing bitmap file
    By 7stud in forum C++ Programming
    Replies: 1
    Last Post: 11-24-2004, 06:54 AM
  4. OpenGL -- Bitmaps
    By HQSneaker in forum Game Programming
    Replies: 14
    Last Post: 09-06-2004, 04:04 PM
  5. Problem With My Bitmap
    By Sebastiani in forum Windows Programming
    Replies: 9
    Last Post: 10-29-2001, 08:54 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21