Solved

Display images

Posted on 1998-07-07
3
175 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

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

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

679 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