Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!purdue!bu-cs!dartvax!eleazar.dartmouth.edu!earleh From: earleh@eleazar.dartmouth.edu (Earle R. Horton) Newsgroups: comp.sys.mac.programmer Subject: Re: Aligining bitmaps? Message-ID: <15288@dartvax.Dartmouth.EDU> Date: 28 Aug 89 22:20:37 GMT References: <3791@ncsuvx.ncsu.edu> Sender: news@dartvax.Dartmouth.EDU Reply-To: earleh@eleazar.dartmouth.edu (Earle R. Horton) Organization: Thayer School of Engineering Lines: 41 In article <3791@ncsuvx.ncsu.edu> jnh@ecemwl.UUCP (Joseph N. Hall) writes: >What is the most straightforward procedure for ensuring that a window's >portBits begin on a word boundary? What I would like to do is check after >the user creates or resizes a graphics window and shift the window horizontally >(if necessary) so that it will be aligned for later updates from an offscreen >bitmap. I don't know what you mean by straightforward, but ANDing the horizontal coordinate with NOT-0x0F before calling MoveWindow() should work fine. Resize and create should not be a problem, but moving the window is conceptually difficult for the average user since you will 15 times out of 16 place it on a different location than that to which it has been dragged if you use the regular DragWindow() routine. They might not notice, but if they do they might perceive it as a bug. Consider dragging the window by some other method that shows the discrete end positions you will allow. short x; x = whatever; x &= ~15; /* Align x on word boundary not greater than x. */ >Also, how much speed difference is there between an aligned and unaligned >one-to-one CopyBits? I assume that performance is no better for an >odd-byte-aligned bitmap than it is for a totally unaligned bitmap, right? In four-bit mode, aligned BitMaps makes for noticeably faster CopyBits(). Most of my experience is in using four-bit mode for animation, but I think it is definitely worth the trouble to align source and destination BitMaps when attempting any kind of animation and the screen depth is greater than one. Byte alignment seems to be all that's necessary. Where did you get your information that word alignment is needed? >I'm only messing with b/w bitmaps now, but I'd appreciate hearing the answer >for both classic and color QuickDraw ... I don't notice any difference between aligned or non-aligned BitMaps with a black and white screen. On the other hand, these are subjective results since I haven't done formal timing. Earle R. Horton