Solved

How to insert bmp or jpeg as bakground in SDI which has the ability of stretching

Posted on 2003-12-06
7
237 Views
Last Modified: 2013-11-20
Can somebody upload an example source code with the ability of above using visual C++?
can explain how to do so? Hope u can help me as i need it urgently. thank u

huey
 
0
Comment
Question by:hueychian83
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
7 Comments
 
LVL 48

Accepted Solution

by:
AlexFM earned 38 total points
ID: 9891159
0
 

Expert Comment

by:andyinlondon
ID: 9892750
I hope this will work for you.

1. In your doc.h file:
   #include "atlimage.h"
   CImage m_bmp;
2. In your doc constructor:
    m_bmp.Load("C:\\My Pictures\\Somewhere\\Nice Picture.JPG");
3. In your view.cpp:

void CMyView::OnDraw(CDC* pDC)
{ // get a pointer to the document
  CMyDoc* pDoc = GetDocument();
  ASSERT_VALID(pDoc);

  CRect rClientRect;
  GetClientRect(&rClientRect);
  CRect rBmpRect(0, 0, pDoc->m_bmp.GetWidth() - 1, pDoc->m_bmp.GetHeight() - 1);

  pDoc->m_bmp.StretchBlt(*pDC, rClientRect, rBmpRect, SRCCOPY);
}
0
 

Expert Comment

by:andyinlondon
ID: 9892784
Further to my earlier solution, add the following line to your OnDraw method, before the call to StretchBlt to get the colours looking nice.
    pDC->SetStretchBltMode(HALFTONE);
0
 

Assisted Solution

by:MAYURNATH
MAYURNATH earned 37 total points
ID: 9990096

Override WM_ERASEBKGROUND message
CView::OnEraseBKGround(CDC* pDC )
{
GetClientRect()
              // here draw the bitmap or jpeg strecthing it to the rect. This is standard what i suppose
Loading Bitmap
select to memory dc
strecth blt to the original pDC dc,
release memory dc
return true;
}


// i think code was also given in above

thanx
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Tab names are off by one 5 54
substring method in java 1 142
conditional code and condition difference 9 87
firstChar challenge 13 149
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question