CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8

Thread: shrink bitmap

  1. #1
    Join Date
    Jan 2009
    Posts
    69

    shrink bitmap

    Hi,
    I have bitmap image that I load into picture control on my dialog box(using mfc). Problem is that bitmap image is way bigger then picture control and it gets cut off. This is my method that I load image into picture control.....

    loadImage(CString myString){ //myString is name of image in my directory


    HBITMAP phBitmap = (HBITMAP)LoadImage( NULL,myString,
    IMAGE_BITMAP, 0, 0,LR_CREATEDIBSECTION | LR_LOADFROMFILE);
    picture.SetBitmap(phBitmap);

    }

    Does anyone know how to shrink bitmap image and load that into picture control or to point me to some good tutorial. I found some tutorials already but they so confusing since they have so many lines of code for simple functionality that I need.

    Thanks guys

  2. #2
    Join Date
    Mar 2004
    Location
    KL, Malaysia
    Posts
    63

    Re: shrink bitmap

    You can use CDC:StretchBlt to shrink your bitmap into smaller destination rectangle.

  3. #3
    Join Date
    Jan 2009
    Posts
    69

    Re: shrink bitmap

    Hi,
    Thank you so much for reply. My picture control name is IDC_PICTURE_AREA.
    I just read about StrechBlt() in documentation. It is clear to me that 8 of the parameters are coordinates of source and coordinates of destination. I am kind of lost on how would I get
    Handle to the destination and to the source. Would the handle of my source be this....

    HBITMAP phBitmap = (HBITMAP)LoadImage( NULL,myString,
    IMAGE_BITMAP, 0, 0,LR_CREATEDIBSECTION | LR_LOADFROMFILE);

    Because phBitmap point to my image in memory. How would I get the handle to my picture control since picture control is my destination.

    Any help would be appreciated.

  4. #4
    Join Date
    May 2005
    Posts
    4,954

    Re: shrink bitmap

    If a post helped you dont forget to "Rate This Post"

    My Article: Capturing Windows Regardless of Their Z-Order

    Cheers

  5. #5
    Join Date
    Jan 2009
    Posts
    69

    Re: shrink bitmap

    Hi
    thanks for reply. Could you tell me how would i get handle for my picture control.

    Thanks

  6. #6
    Join Date
    Nov 2001
    Posts
    251

    Re: shrink bitmap

    Quote Originally Posted by ckweius View Post
    You can use CDC:StretchBlt to shrink your bitmap into smaller destination rectangle.
    Yes, you could use StretchBlt, but the quality is crap. But if you don't care about quality, then it's an easy choice.

  7. #7
    Join Date
    Mar 2004
    Location
    KL, Malaysia
    Posts
    63

    Re: shrink bitmap

    Quote Originally Posted by joker1969 View Post
    Hi,
    Thank you so much for reply. My picture control name is IDC_PICTURE_AREA.
    I just read about StrechBlt() in documentation. It is clear to me that 8 of the parameters are coordinates of source and coordinates of destination. I am kind of lost on how would I get
    Handle to the destination and to the source. Would the handle of my source be this....

    HBITMAP phBitmap = (HBITMAP)LoadImage( NULL,myString,
    IMAGE_BITMAP, 0, 0,LR_CREATEDIBSECTION | LR_LOADFROMFILE);

    Because phBitmap point to my image in memory. How would I get the handle to my picture control since picture control is my destination.

    Any help would be appreciated.
    Check out this example:
    BMPLoader.zip

  8. #8
    Join Date
    May 2005
    Posts
    4,954

    Re: shrink bitmap

    Quote Originally Posted by joker1969 View Post
    Hi
    thanks for reply. Could you tell me how would i get handle for my picture control.

    Thanks
    Look at ::GetDlgItem().

    Cheers
    If a post helped you dont forget to "Rate This Post"

    My Article: Capturing Windows Regardless of Their Z-Order

    Cheers

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