?
Solved

Display images

Posted on 1998-07-07
3
Medium Priority
?
178 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
[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
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 200 total points
ID: 1167309
I would suggest you look into
http://www.codeguru.com/bitmap/bitmap_toc.shtml
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

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
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…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
Suggested Courses

800 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