Solved

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

Posted on 2003-12-06
7
227 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
  • 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: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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

Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.

820 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