|
-
March 1st, 2009, 07:48 PM
#1
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
-
March 1st, 2009, 08:23 PM
#2
Re: shrink bitmap
You can use CDC:StretchBlt to shrink your bitmap into smaller destination rectangle.
-
March 1st, 2009, 08:34 PM
#3
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.
-
March 2nd, 2009, 10:51 AM
#4
-
March 2nd, 2009, 12:31 PM
#5
Re: shrink bitmap
Hi
thanks for reply. Could you tell me how would i get handle for my picture control.
Thanks
-
March 2nd, 2009, 05:01 PM
#6
Re: shrink bitmap
 Originally Posted by ckweius
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.
-
March 3rd, 2009, 08:09 PM
#7
Re: shrink bitmap
 Originally Posted by joker1969
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
-
March 4th, 2009, 06:08 AM
#8
Re: shrink bitmap
 Originally Posted by joker1969
Hi
thanks for reply. Could you tell me how would i get handle for my picture control.
Thanks
Look at ::GetDlgItem().
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|