home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / os / mswindo / programm / misc / 1813 < prev    next >
Encoding:
Text File  |  1992-09-13  |  2.3 KB  |  61 lines

  1. Newsgroups: comp.os.ms-windows.programmer.misc
  2. Path: sparky!uunet!cs.utexas.edu!wotan.compaq.com!twisto.eng.hou.compaq.com!sword.eng.hou.compaq.com!mccreary
  3. From: mccreary@sword.eng.hou.compaq.com (Ed McCreary)
  4. Subject: StretchDIBits and one other question...
  5. Message-ID: <1992Sep13.231220.686@twisto.eng.hou.compaq.com>
  6. Sender: news@twisto.eng.hou.compaq.com (Netnews Account)
  7. Organization: Compaq Computer Corp.
  8. Date: Sun, 13 Sep 1992 23:12:20 GMT
  9. Lines: 50
  10.  
  11. I'm having an odd problem with StretchDIBits (and SetDIBitsToDevice also.)
  12.  
  13. I'm using it do display grey scale images but for some reason it
  14. doesn't seem to work with certain dimensions.  Here's a code fragment:
  15.  
  16.  lpbmi = (LPBITMAPINFO)GlobalLock(hbmi);
  17.  lpImageBits = (char huge *)GlobalLock(hImageBits);
  18.  
  19.  
  20.  i=StretchDIBits(hdc, 0, 0,
  21.         nZoomFactor*nImageWidth,
  22.                 nZoomFactor*nImageHeight,
  23.         0, 0, nImageWidth, nImageHeight,
  24.         lpImageBits, lpbmi,
  25.         DIB_RGB_COLORS, SRCCOPY);
  26.  
  27. nZoomFactor is an integer used to perform a quick and dirty zoom on
  28. the image.  The rest should be self explanatory.  Now it works fine with
  29. images with dimensions of 200x200 and 800x800, but when I try 130x130
  30. or 255x210 it fails.  It returns 0 meaning 0 lines displayed.
  31.  
  32. I've checked all of the variables right before the function is called,
  33. and they all are correct, yet it still fails!!  I'd appreciate any
  34. hints.
  35.  
  36. The second question is with how to store the image data in memory.
  37. Currently I'm using a (char huge *) pointing to a global memory.
  38. This is for an image processing package to it's nice to have the
  39. data readily available for processing and display.  
  40.  
  41. This works fine and I can access the data sequentially, say
  42.     
  43.     char huge *ptr;
  44.     ptr = (char huge *)GlobalLock(hImageBits);
  45.     for(i=0;i<40000;i++)
  46.       ptr++;   // for a 200x200 image.
  47.  
  48. this works fine.  The problem occurs when I try to access a byte
  49. in the middle.  ptr+=20000 directly instead of moving through all of
  50. the data.  Is this a problem with the way I'm trying to access
  51. the memory or do I need to rethink the way I store it.
  52.  
  53. Any hints would greatly appreciated.
  54.  
  55.  
  56. --
  57. McCreary@sword.eng.hou.compaq.com     Computers are like Old Testament gods;
  58. Me? Speak for Compaq?  Yeah, right.   lots of rules and no mercy.
  59.                                                              Joseph Campbell
  60.  
  61.