home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / sys / mac / programm / 20381 < prev    next >
Encoding:
Text File  |  1992-12-29  |  2.6 KB  |  97 lines

  1. Newsgroups: comp.sys.mac.programmer
  2. Path: sparky!uunet!munnari.oz.au!spool.mu.edu!agate!dog.ee.lbl.gov!hellgate.utah.edu!fcom.cc.utah.edu!news
  3. From: Dmitry Boldyrev <dmitry@chemistry.chem.utah.edu>
  4. Subject: Strange things with Color Quick Draw
  5. Message-ID: <1992Dec29.182112.26364@fcom.cc.utah.edu>
  6. Sender: news@fcom.cc.utah.edu
  7. Organization: University of Utah
  8. X-Useragent: Nuntius v1.0
  9. Date: Tue, 29 Dec 92 18:21:12 GMT
  10. Lines: 85
  11.  
  12.  
  13.  
  14. Hello Folks,
  15. I'm working on my project and I have some questions 
  16. which I can't solve..
  17. Here, let's take a look on my Code:
  18. unit GraphStructs;
  19. interface
  20.     const
  21.         pixelDepth = 8;
  22.     var
  23.         offPort: CGrafPort;
  24.  
  25.     procedure MakePort (theWindow: WindowPtr);
  26.  
  27.     procedure SetBack;
  28.  
  29.     procedure GetWind (var theWindow: WindowPtr);
  30.  
  31. implementation
  32.  
  33.     procedure MakePort (theWindow: WindowPtr);
  34.         var
  35.             windRect: Rect;
  36.             newSpace: QDPtr;
  37.             rwBytes: LongInt;
  38.     begin
  39.         windRect := theWindow^.portRect;
  40.         windRect.Bottom := WindRect.Bottom - WindRect.Top;
  41.         windRect.Top := 0;
  42.         windRect.Right := windRect.Right - windRect.Left;
  43.         windRect.Left := 0;
  44.  
  45.         OpenCPort(@offPort);
  46.         offPort.portRect := windRect;
  47.         offPort.portPixMap^^.Bounds := windRect;
  48.         SetRectRgn(offPort.visRgn, 0, 0, windRect.Right, windRect.Bottom);
  49.         SetRectRgn(offPort.clipRgn, 0, 0, windRect.Right, windRect.Bottom);
  50.  
  51.         rwBytes := ((8 * windRect.Right + 31) div 32) * 4;
  52.         newSpace := NewPtrClear(LongInt(rwBytes) * windRect.Bottom);
  53.  
  54.         offPort.portPixMap^^.rowBytes := rwBytes;
  55.         offPort.portPixMap^^.baseAddr := newSpace;
  56.         SetPort(@offPort);
  57.     end;
  58.     procedure SetBack;
  59.     begin
  60.         SetPort(@offPort);
  61.     end;
  62.     procedure GetWind (var theWindow: WindowPtr);
  63.     begin
  64.         CopyBits(GrafPort(offPort).portBits, theWindow^.portBits,
  65. GrafPort(offPort).portRect, theWindow^.portRect, srcCopy, nil);
  66.     end;
  67. end.
  68.  
  69. It's a simple animation routines.
  70. Simple Program:
  71. -------------
  72.     MainWindow := GetNewCWindow(200, nil, Pointer(-1));    {* Resource Window
  73. (Black Background) *}
  74.     ShowWindow(MainWindow);
  75.     SetPort(MainWindow);
  76.     InitCursor;
  77.     
  78.     MakePort(MainWindow);    {* Make off-screen port *}
  79.     repeat
  80.         SetBack;            {* Set to OffPort, just for drawing *}
  81.         DoDraw;                {* In this routine I'm using RGBForeColor and LineTo to draw
  82. picture *}
  83.         GetWind(MainWindow); {* It's copying contents from off-port into
  84. "MainWindow" *}
  85.         SetPort(MainWindow); 
  86.     until Button;
  87.     DisposeWindow(MainWindow);
  88. --------------
  89. When It's doing GetWind(MainWindow) or in other words Copying offPort to
  90. MainWindow,
  91. it's inverts my picture >.. Isn't strange ?
  92. I tried it in b/w QuickDraw and it works OK,
  93. but here, it's inverts all colors..
  94. THANKS!
  95. My E-Mail: dmitry@chemistry.chem.utah.edu
  96. ============ D M I T R Y ============
  97.