ftanaka@Apple.COM (Forrest Tanaka) (05/25/90)
In article <41276@apple.Apple.COM> ftanaka@Apple.COM (Forrest Tanaka) writes: > The old characteristic of not scaling pen sizes when a picture was scaled >was a bug in Quickdraw that's been fixed by 32-Bit Quickdraw. Since it's a >bug fix, we thought that everyone would like it and no one would want to go >back to the old way. So, there's no way right now to disable the fix aside >from not using 32-Bit Quickdraw. It turned out that a few people depended on >this bug, so there might be a way to disable pen size scaling in the future. >I kind of doubt it, but it's not up to me. Judging by the mail I've gotten, it looks like more people than I'd realized thought that this bug was pretty cool. So, I tried out something that I suspected might work for some people to fix the fix, and it does work. If y'all turn to page 197 of Inside Macintosh I, you'll see a discussion about Quickdraw bottlenecks. By making your own bottlenecks, you can customize almost everything that Quickdraw does. When you call LineTo, StdLine is called to do the drawing. By providing your own routine to replace StdLine, you can make almost anything you want happen when LineTo is called. The same applies to all the others you see on the next couple of pages. Your StdLine replacement can even call StdLine, and it can even do things after calling StdLine--a non-breakable form of tail-patching if you want to think of it that way. When you call DrawPicture, these bottlenecks are called to actually draw the contents of the Picture. So if the picture has a line in it, StdLine or your StdLine replacement will be called to draw the line. That's the key to fixing the fix. What you can do is to create your picture in the usual way. Then before you call DrawPicture, replace the StdLine, StdRect, StdRRect, StdOval, StdArc, StdPoly, and StdRgn bottlenecks with your own bottlenecks. Except the StdLine case, the typical bottleneck will look something like: if the verb is 'frame' then call PenSize(1,1) call the standard bottleneck That's it! It doesn't make sense for StdLine to take a verb, so you can just call PenSize(1,1) and then call the standard bottleneck in that case. What this is saying is that if the programmer or the picture calls Frame<X>, then set the pen size to 1 before calling the routine that actually draws the <X>. The downside of this for some of you is that if you export your picture to another program, the pen sizes will be scaled again because they won't know to put in their own bottlenecks to set the pen size to 1 before drawing the objects. But, there is sort of a way around this even if you know what scale you want the result to be. In more pseudo-code, the operation could look something like this: original picture = OpenPicture(small rectangle) Draw some framed things ClosePicture Replace bottlenecks with the 'PenSize(1,1)' bottlenecks scaled picture = OpenPicture (big rectangle) DrawPicture (original picture, big rectangle) ClosePicture Set the bottlenecks back to what they were Now, 'scaled picture' will contain a scaled version of 'original picture', but all the lines and frames will still have a pen size of 1 because you replaced the bottlenecks. Of course, if you scale 'scaled picture' larger, then the pen sizes will again be scaled unless you again replace the bottlenecks. I doubt that this is practical in every case, but it sounds like some of you can do something like this. Another option that I thought of as I was typing this is to patch PenSize. After giving it about three seconds of thought, I don't see what would be wrong with this. If any of you see a problem with this or the bottleneck method, or if you have a better way, please please please post it. -- Forrest Tanaka Macintosh Developer Technical Support Apple Computer, Inc. Internet: ftanaka@apple.com AppleLink: TANAKA Phone: (408) 974-9525