Solved

Display images

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
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 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 be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

759 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

25 Experts available now in Live!

Get 1:1 Help Now