home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / os / mswindo / programm / misc / 4514 < prev    next >
Encoding:
Text File  |  1992-12-29  |  4.7 KB  |  104 lines

  1. Newsgroups: comp.os.ms-windows.programmer.misc
  2. Path: sparky!uunet!cs.utexas.edu!torn!nott!emr1!jagrant
  3. From: jagrant@emr1.emr.ca (John Grant)
  4. Subject: displaying gridded data files with dithered colours
  5. Message-ID: <1992Dec30.034618.6880@emr1.emr.ca>
  6. Keywords: dither, bitmap, dib, grid, image 
  7. Organization: Energy, Mines, and Resources, Ottawa
  8. Date: Wed, 30 Dec 1992 03:46:18 GMT
  9. Lines: 93
  10.  
  11. I want to read a rectangular file of float values (i.e. gridded data)
  12. and plot a colour image of it in Windows.  I'm trying to sort out
  13. all of the bitmap and dib functions and it's confusing.  This appears
  14. to be different than recent discussion of bitmaps because:
  15.   - these data values have real dimensions (metres) - they are
  16.     not just pixels in a picture
  17.   - the file is proprietary float values - not BMP, PIC, EPS etc
  18.   - nobody has talked about dithered colours and their use for
  19.     displaying bitmaps on 16-colour systems
  20.  
  21. I never bothered to tackle this problem under DOS because I
  22. could only get 16 colours on a VGA in 640X480 mode.  Now that
  23. I have Windows, I would like to take advantage of the device
  24. independence of the drivers & the availability of dithered colours.
  25. Most of the following questions relate to using a 16-colour VGA
  26. system as the base system and having Windows provide dithered
  27. colours...
  28.  
  29. Here are the issues:
  30.   1. I want to distribute the data set as float values, not as saved
  31.      bitmaps (independent or dependent) or other 'picture' formats.
  32.      So converting the file to a BMP first is not an option here.
  33.      I just want to read the 'float' file and display it.  The files
  34.      can be any size (100 X 100 or perhaps 1000 X 1000, i.e. 4 Mb!)
  35.  
  36.   2. Each data value represents a cell size of a specific value,
  37.      i.e. 250m X 250m.  I need to display all or a portion of
  38.      the file on the screen at a specific scale (to match the
  39.      other GIS data).  There are 2 cases, depending on scale:
  40.         - the data cell is represented by several device pixels
  41.           (i.e. 10 X 10 pixels)
  42.         - the data cell is represented by less than 1 pixel
  43.           (i.e. at a particular scale, each device pixel
  44.           may represent the average of several data values)
  45.         These requirements immediately bring to mind the idea of
  46.         using StretchBlt for zooming and panning on the picture.
  47.         In the first case, I could use Rectangle(), albeit slow,
  48.         but not in the second case.
  49.  
  50.   3. To test, I wrote a simple program to subdivide the window
  51.      into 256 X 256 rectangles and then I drew each one using
  52.      Rectangle() with a different colour.  I did get my dithered 
  53.      colours and it looked quite good, but it took slightly less 
  54.      than forever. I expect that 1000 X 1000 will take forever.  
  55.      The result is exactly what I want:
  56.         - logical co-ordinates
  57.         - dithered colours
  58.         - simple to program
  59.      except for speed.  Obviously I can do some decimation of the
  60.      data myself, but I would like Windows to take care of it for
  61.      me and I want to use logical co-ordinates, not device co-ordinates.
  62.  
  63. Questions:
  64. 1.  As I read in the file to display it, I can use various algorithms 
  65.     to convert the float values to:
  66.         - palette index values (i.e. 0-255)
  67.         - actual RGB colours (i.e. doing my own lookup instead
  68.           of using palettes)
  69.     Is there any reason to do it one way or another?
  70.  
  71. 2.  Will I still be able to get dithered colours (i.e. more
  72.     than 16) when dealing with:
  73.                 - bitmaps
  74.                 - DIBs
  75.                 - palettes
  76.  
  77. 3.  Here's my first idea:
  78.         - create an N X M memory compatible bitmap to match the file
  79.         - for each value, use SetPixel() to set the RGB colour
  80.         - when ready to display, just BitBlt it to the screen
  81.           and hopefully the individual pixels would 'expand' to
  82.           rectangles of dithered colours
  83.         
  84.         Apparently this won't work because Windows knows the HDC
  85.         is for a 16-colour VGA, so SetPixel() will just give the
  86.         closest 1 of 16 colours.  This appears to eliminate the use 
  87.         of bitmaps entirely and also StretchBlt.
  88.  
  89.         So, how do I get dithered colours (for 16-colour VGA)
  90.         *and* also use StretchBlt and the other *blt* functions?
  91.  
  92. 4. The docs (Petzold,SDK) say that DIBS are more complex to work 
  93.    with and are really only useful for creating files to be used
  94.    on other systems.  For just internal use etc, they say stick
  95.    with simple bitmaps.  This sounds like good advice, but will
  96.    that limit me later when I want to print the picture?  In
  97.    other words, are DIBs also mandatory for proper printing?
  98.  
  99. Any ideas?
  100. -- 
  101. John A. Grant                        jagrant@emr1.emr.ca
  102. Airborne Geophysics
  103. Geological Survey of Canada, Ottawa
  104.