Solved

Display images

Posted on 1998-07-07
3
173 Views
Last Modified: 2010-04-01
I have searched for some time to find a way to display Bitmap image files which are determined at run time and/or hardcoded file names, but all of the examples and discussions are Around-A-Bout or just plain evasive.

I did get close recently, but the image still did not become visible. I used the following code:

void CMainFrame::OnKraphicsSee()
{
CPaintDC  dc(this); //Display a default image
      //************* Load Bmp file
strcpy (filename, "D:\\Graphics\\Images\\GailGrp1.bmp");

  ptrdib = new CDib (filename); // load the file into a dib
  if (!ptrdib || !ptrdib->IsValid ())
  MessageBox("Invalid Bitmap File - Try Again", "Bitmap
  set up the dib size in a rectangle File Error", MB_OK);
  else {
   dibrect.left = dibrect.top = 0;
   dibrect.right = ptrdib->GetDibWidth();
   dibrect.bottom = ptrdib->GetDibHeight();
  }
  //***** Now that the file is loaded convert it and display
  if (ptrdib && ptrdib->IsValid ()) { // successful load?
      // finish conversion
    if (effecttype!=CM_NORMAL) ConvertToMemoryDC ();
             // still a success, finish up
          if (ptrdib->IsValid ()) {
                        // clear scroll position
                  current_vpel = 0;
                  current_hpel = 0;
                   // by adjusting the new scroller range
                  AdjustScroller ();
                   // insert filename into window title
                  UpdateCaption ();
              // force the image to be displayed
                        Invalidate();
                  MessageBox("Where is the Bitmap ?", "Bitmap Should be displayed", MB_OK);
  }
 }
      //************* End See if we can display a default image

 
   //************** End See
}

In a perfect world for me I would be able to create a dialog box and place controls on it to navigate through accessiable directories. I would be able to place the full path and image names into a listbox or just select the image names in a listbox and the image would be displayed.

I would like to place a Frame or Image control on my dialogbox and change the name of the image to be viewed as I wish.

Please help.......................
0
Comment
Question by:kraphics
3 Comments
 

Author Comment

by:kraphics
ID: 1167307
Edited text of question
0
 
LVL 2

Expert Comment

by:lucidity
ID: 1167308
where are you planning to display this image?

I can give code to display a background in a dialog and add bitmaps to buttons that will give a spiffy looking interface.

(DIBs not BMPs, but since its hardcoded it doesn't matter)
0
 
LVL 23

Accepted Solution

by:
chensu earned 100 total points
ID: 1167309
I would suggest you look into
http://www.codeguru.com/bitmap/bitmap_toc.shtml
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

813 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now