Solved

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

Posted on 2003-12-06
7
217 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

786 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