Thread: Bitmap saving problem

  1. #1
    Android geek@02's Avatar
    Join Date
    Mar 2004
    Location
    Kurunegala Colony, Sri Lanka, Sri Lanka
    Posts
    470

    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.
    GameJolt: https://gamejolt.com/@KasunL
    Game Development Youtube:
    https://is.gd/XyhYoP
    Amateur IT Blog: http://everything-geeky.blogspot.com/



    (and, sorry for my amateur 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 geek@02's Avatar
    Join Date
    Mar 2004
    Location
    Kurunegala Colony, Sri Lanka, Sri Lanka
    Posts
    470
    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);
    GameJolt: https://gamejolt.com/@KasunL
    Game Development Youtube:
    https://is.gd/XyhYoP
    Amateur IT Blog: http://everything-geeky.blogspot.com/



    (and, sorry for my amateur 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, 09:43 AM
  3. ResHacker error replacing bitmap file
    By 7stud in forum C++ Programming
    Replies: 1
    Last Post: 11-24-2004, 07: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, 09:54 PM