home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C ++ / Applications / Venus 3.5 / view_2d.cc < prev    next >
Encoding:
C/C++ Source or Header  |  1997-04-10  |  1.0 KB  |  37 lines  |  [TEXT/ALFA]

  1. /*
  2.  ***********************************************************************
  3.  *
  4.  *
  5.  *                               Grayscale Image
  6.  *                     Display an image on Macintosh
  7.  *
  8.  * This is an implementation of a class ImageView that displays (converts,
  9.  * actually) an image into an Offscreen buffer
  10.  *
  11.  *
  12.  ***********************************************************************
  13.  */
  14.  
  15. #include "ImageViews.h"
  16.  
  17.  
  18.  
  19.                                 // Creating a window that would have our picture
  20.                                 // displayed. This function also creates an
  21.                                 // offscreen grafworld and draws the picture in it
  22. ImageView::ImageView(const ElevationMap& elev_image)
  23.     : OffScreenBuffer((ScreenRect)elev_image,elev_image.q_clut())
  24. {
  25.   PixMapHandle pixmap = get_pixmap();
  26.   assert( LockPixels(pixmap) );
  27.  
  28.   char * pixp = GetPixBaseAddr(pixmap);
  29.   Image_istream im_istr(elev_image);
  30.   const int pixmap_row_padding = bytes_per_row() - width();
  31.   for(register int i=0; i<height(); i++, pixp += pixmap_row_padding)
  32.      for(register int j=0; j<width(); j++)
  33.       *pixp++ = im_istr.get();
  34.   assert( im_istr.eof() );
  35.   UnlockPixels(pixmap);
  36. }
  37.