Zoom in using picture control
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: Zoom in using picture control

  1. #1
    Join Date
    Aug 2013
    Posts
    2

    Zoom in using picture control

    I'm have a bitmap that's about 4000x2000. But I want to put it all into a picture
    control. I attempted to use stretchBlt() to shrink it. But it did not work. What am
    I doing wrong?

    Code:
    	
    HBITMAP originalImage = CreateDIBitmap(m_picture1.GetDC()->m_hDC, 
                                                           m_bmiHeader, 
    						       CBM_INIT, 
                                                           (unsigned short *)m_OriginalBits, 
                                                           m_bmiInfo, 
                                                           DIB_RGB_COLORS);
    
    // I want to use stretchBlt to put the bitmap (OriginalBits) into a smaller m_picture1, 
    // what should I from the target and source hDC?  I'm very confused.
    
    
    	bool rc = StretchBlt(GetDC()->m_hDC,
                               0,
    			   0,
    			   FRAMEWIDTH,
    			   FRAMEHEIGHT,
    			   GetDC()->m_hDC,
    			   0,
    			   0,
    			   m_bmiHeader->biWidth,
    			   m_bmiHeader->biHeight,
    			   SRCCOPY); */
    
    	m_picture1.SetBitmap(originalImage);

  2. #2
    VictorN's Avatar
    VictorN is online now Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,355

    Re: Zoom in using picture control

    Where do you call this code from?
    Victor Nijegorodov

  3. #3
    Join Date
    Aug 2013
    Posts
    2

    Re: Zoom in using picture control

    Quote Originally Posted by VictorN View Post
    Where do you call this code from?
    I have dialog and that dialog contains a picture control and a few buttons,
    did I do anything wrong with the source size in StretchBlt() or anything to that
    nature? I'm stumped.

    Code:
    BOOL CImgView::OnInitDialog()
    {
    	CDialogEx::OnInitDialog();
    
    	SetWindowPos(&wndBottom,
    				 0,
    				 0,
    				 FRAMEWIDTH + 140,
    				 FRAMEHEIGHT + 60,
    				 SWP_NOMOVE | SWP_NOZORDER);
    
    	m_bits = (unsigned char*)malloc(sizeof(FRAMEHEIGHT * FRAMEWIDTH * 3));
    
    	//Initialize the size of the image as the same as that of the frame
    	m_ImgWidth = FRAMEWIDTH;
    	m_ImgHeight = FRAMEHEIGHT;
    
    	m_picture1.ModifyStyle(0, SS_BITMAP | SS_CENTERIMAGE);
    	CRect rect1;
    	GetWindowRect(&rect1);
    
    	m_picture1.SetWindowPos(&wndBottom, 
    							120,
    							10,
    							FRAMEWIDTH,
    							FRAMEHEIGHT,
    							SWP_NOZORDER);
    
    	HBITMAP originalImage = CreateDIBitmap(m_picture1.GetDC()->m_hDC, 
                                                                    m_bmiHeader, 
    								CBM_INIT, 
    								(unsigned short *)m_OriginalBits, 
    								m_bmiInfo, 
    								DIB_RGB_COLORS);
    
    	bool rc = StretchBlt(GetDC()->m_hDC,
    		       0,
    			   0,
    			   FRAMEWIDTH,
    			   FRAMEHEIGHT,
    			   GetDC()->m_hDC,
    			   0,
    			   0,
    			   m_bmiHeader->biWidth,
    			   m_bmiHeader->biHeight,
    			   SRCCOPY); 
    
    	m_picture1.SetBitmap(originalImage);
    	
    	return TRUE;  
    }

  4. #4
    Join Date
    Jan 2009
    Posts
    40

    Re: Zoom in using picture control

    Why do you call SetBitmap after you draw the bitmap ? You can find something to help you on http://www.functionx.com/visualc/ ... there, you can see how to draw a bitmap ...

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center