fry@huma1.HARVARD.EDU (David Fry) (08/04/87)
>From: JIMH >Subject: changing pixel depth >Date: 25-JUL 01:47 Macintosh II >Does anyone know how the monitor cdev cause the desktop (or any >programs) to redraw themselve with the new screen depth? I want a fkey >to toggle between 1 and 8 bit mode. It pretty straightforward to set >the mode to whatever depth you need and when you r elaunch the finder >(return to finder you have new depth set. what is less straightforward >is to get the desktop to draw itself without a launch. best jim I've been using this method with success. It assumes a menu bar is present, but I guess you'd have to check that. menuBar = GetMenuBar(); ClearMenuBar(); bigPtr = &bigPort; OpenCPort(bigPtr); EraseRect(&bigPtr->portRect); /* this opens and erases a screen-sized port */ PenMode(patCopy); PaintRect(&bigPtr->portRect); /* this paints everything black */ CloseCPort(bigPtr); theRgn = GetGrayRgn(); /* this function is defined in the latest Lightspeed C release, but you can access the global variable GrayRgn if you don't have LSC */ PaintOne(NULL,theRgn); SetMenuBar(menuBar); DrawMenuBar(); DisposHandle(menuBar); temp = FrontWindow(); while ( temp != NULL ) { PaintOne((CWindowPeek)temp,((CWindowPeek)temp)->strucRgn); /* this fixes up all the windows */ temp = ((CWindowPeek)temp)->nextWindow; } /* we're done! */ David Fry fry@huma1.harvard.EDU Department of Mathematics fry@harvma1.bitnet Harvard University ...!harvard!huma1!fry Cambridge, MA 02138
oster@dewey.soe.berkeley.edu (David Phillip Oster) (08/04/87)
In article <2640@husc6.UUCP> fry@huma1.UUCP (David Fry) writes: >From: JIMH >Subject: changing pixel depth >Does anyone know how the monitor cdev cause the desktop (or any >programs) to redraw themselve with the new screen depth? I want a fkey >to toggle between 1 and 8 bit mode. It pretty straightforward to set >the mode to whatever depth you need and when you r elaunch the finder >(return to finder you have new depth set. what is less straightforward >is to get the desktop to draw itself without a launch. best jim The following works well: 1.) Get a rectangle as big as the entire desktop (all the multiple displays): bigRect = (**GrayRgn).rgnBBox; 2.) turn painting of new windows off, so we'll get a transparent window: saveWhite = paintWhite; paintWhite = 0; 3.) Create a new, big window, in front of everything tempWindow = NewWindow(... 4.) DisposeWindow(tempWindow) and restore paintWhite This makes the window manager send everybody an update event, and things are just cool. Now: I've got a problem of my own: I'd like to extend Stars so that it does the right thing on a color display. One of the things I want to do is do a smooth fade to black by playing with the color table, then at the end of Stars, restore the original color table. I've written code that uses SetEntries to smoothly decrease the brightness of all the colors until the whole screen is black. The problem is that some things call ReserveEntires and ProtectEntries, and my call to SetEntries won't change these slots in the color table. How do I find out which slots are protected so that I can temporarily un-protect them? How do I convince the system to let me re-protect them under their old owners? Is there an easier way to do this right? --- David Phillip Oster --My Good News: "I'm a perfectionist." Arpa: oster@dewey.soe.berkeley.edu --My Bad News: "I don't charge by the hour." Uucp: {seismo,decvax,...}!ucbvax!oster%dewey.soe.berkeley.edu
lsr@apple.UUCP (Larry Rosenstein) (08/05/87)
In article <2640@husc6.UUCP> fry@huma1.UUCP (David Fry) writes: >>From: JIMH >>Subject: changing pixel depth >>Date: 25-JUL 01:47 Macintosh II > >>Does anyone know how the monitor cdev cause the desktop (or any >>programs) to redraw themselve with the new screen depth? I want a fkey >>to toggle between 1 and 8 bit mode. It pretty straightforward to set >>the mode to whatever depth you need and when you r elaunch the finder >>(return to finder you have new depth set. what is less straightforward >>is to get the desktop to draw itself without a launch. best jim > >I've been using this method with success. It assumes a menu >bar is present, but I guess you'd have to check that. > >...(code omitted)... It seems to me that one could just call PaintBehind(WindowPeek(FrontWindow), theRgn) rather than looping and calling PaintOne. (PaintBehind does a similar loop already.) You should not use GrayRgn as theRgn because GrayRgn includes all the screens on the system. You generally want to update only the screen that changed. You can get the screen's size and location from the GDHandle of that graphics device. Simply use NewRgn & RectRgn to convert the rectangle into a region. (You can use the same rectangle to paint things black. It should not be necessary to erase the whole screen first, however.) I think that this should work, but I don't have a Mac II to check it out. -- Larry Rosenstein Object Specialist Apple Computer AppleLink: Rosenstein1 UUCP: {sun, voder, nsc, mtxinu, dual}!apple!lsr CSNET: lsr@Apple.com
lsr@apple.UUCP (Larry Rosenstein) (08/05/87)
In article <1430@apple.UUCP> lsr@apple.UUCP (Larry Rosenstein) writes: > >It seems to me that one could just call > > PaintBehind(WindowPeek(FrontWindow), theRgn) I forgot to mention that this works only if the ghost window "feature" is not being used. If the ghost window is being used, then the FrontWindow call might not return the frontmost window, if it happened to be the designated ghost window. -- Larry Rosenstein Object Specialist Apple Computer AppleLink: Rosenstein1 UUCP: {sun, voder, nsc, mtxinu, dual}!apple!lsr CSNET: lsr@Apple.com