?
Solved

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

Posted on 2003-12-06
7
Medium Priority
?
251 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 152 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 148 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

719 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