home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.mac.programmer
- Path: sparky!uunet!munnari.oz.au!spool.mu.edu!agate!dog.ee.lbl.gov!hellgate.utah.edu!fcom.cc.utah.edu!news
- From: Dmitry Boldyrev <dmitry@chemistry.chem.utah.edu>
- Subject: Strange things with Color Quick Draw
- Message-ID: <1992Dec29.182112.26364@fcom.cc.utah.edu>
- Sender: news@fcom.cc.utah.edu
- Organization: University of Utah
- X-Useragent: Nuntius v1.0
- Date: Tue, 29 Dec 92 18:21:12 GMT
- Lines: 85
-
-
-
- Hello Folks,
- I'm working on my project and I have some questions
- which I can't solve..
- Here, let's take a look on my Code:
- unit GraphStructs;
- interface
- const
- pixelDepth = 8;
- var
- offPort: CGrafPort;
-
- procedure MakePort (theWindow: WindowPtr);
-
- procedure SetBack;
-
- procedure GetWind (var theWindow: WindowPtr);
-
- implementation
-
- procedure MakePort (theWindow: WindowPtr);
- var
- windRect: Rect;
- newSpace: QDPtr;
- rwBytes: LongInt;
- begin
- windRect := theWindow^.portRect;
- windRect.Bottom := WindRect.Bottom - WindRect.Top;
- windRect.Top := 0;
- windRect.Right := windRect.Right - windRect.Left;
- windRect.Left := 0;
-
- OpenCPort(@offPort);
- offPort.portRect := windRect;
- offPort.portPixMap^^.Bounds := windRect;
- SetRectRgn(offPort.visRgn, 0, 0, windRect.Right, windRect.Bottom);
- SetRectRgn(offPort.clipRgn, 0, 0, windRect.Right, windRect.Bottom);
-
- rwBytes := ((8 * windRect.Right + 31) div 32) * 4;
- newSpace := NewPtrClear(LongInt(rwBytes) * windRect.Bottom);
-
- offPort.portPixMap^^.rowBytes := rwBytes;
- offPort.portPixMap^^.baseAddr := newSpace;
- SetPort(@offPort);
- end;
- procedure SetBack;
- begin
- SetPort(@offPort);
- end;
- procedure GetWind (var theWindow: WindowPtr);
- begin
- CopyBits(GrafPort(offPort).portBits, theWindow^.portBits,
- GrafPort(offPort).portRect, theWindow^.portRect, srcCopy, nil);
- end;
- end.
-
- It's a simple animation routines.
- Simple Program:
- -------------
- MainWindow := GetNewCWindow(200, nil, Pointer(-1)); {* Resource Window
- (Black Background) *}
- ShowWindow(MainWindow);
- SetPort(MainWindow);
- InitCursor;
-
- MakePort(MainWindow); {* Make off-screen port *}
- repeat
- SetBack; {* Set to OffPort, just for drawing *}
- DoDraw; {* In this routine I'm using RGBForeColor and LineTo to draw
- picture *}
- GetWind(MainWindow); {* It's copying contents from off-port into
- "MainWindow" *}
- SetPort(MainWindow);
- until Button;
- DisposeWindow(MainWindow);
- --------------
- When It's doing GetWind(MainWindow) or in other words Copying offPort to
- MainWindow,
- it's inverts my picture >.. Isn't strange ?
- I tried it in b/w QuickDraw and it works OK,
- but here, it's inverts all colors..
- THANKS!
- My E-Mail: dmitry@chemistry.chem.utah.edu
- ============ D M I T R Y ============
-