rick@wam.UMD.EDU (09/26/89)
I hope someone can point me in the right direction. I'm looking for code (C, asm, or Pascal) that will convert a bitmap into a region (ie black pixels included in region or vice versa for white pixels). Public domain source would be nice but commercial source will also do. I need to use a bitmap to mask a region while drawing in much the same way that X uses bitmaps as clipping regions while drawing. Any help would be greatly appreciated. I think I may have seen some discussion on this topic a while back in this newsgroup. Thanx. rick@wam.umd.edu
thecloud@dhw68k.cts.com (Ken McLeod) (09/28/89)
In article <8909261258.AA01237@cscwam.UMD.EDU> rick@wam.UMD.EDU writes: >I hope someone can point me in the right direction. I'm looking for code >(C, asm, or Pascal) that will convert a bitmap into a region (ie black pixels >included in region or vice versa for white pixels). >Public domain source would be nice but commercial source will also do. MacTutor had an article on this about 3 or 4 months back (sorry, don't know the exact issue... I haven't tried to keep up :-( As I recall, the core routine was written in MPW assembly, with usage examples in Pascal. Another solution might be to run 32-Bit QuickDraw (assuming you have the appropriate hardware). The legendary DTS BitMapRgn routine ("Licensed to Fill") has been implemented in 32-Bit QD... at least, that's the impression given by the new MPW interfaces. And I quote: FUNCTION BitmapToRegion(region:RgnHandle; bMap:BitMap): OSErr; INLINE $A8D7; pascal OSErr BitmapToRegion(RgnHandle region, BitMap *bMap) = {0xA8D7}; (If this isn't the same routine, I'm sure someone will gently correct me :-) Hope this helps... -- ========== ....... ============================================= Ken McLeod :. .: UUCP: ...{spsd,zardoz,felix}!dhw68k!thecloud ========== :::.. ..::: INTERNET: thecloud@dhw68k.cts.com //// =============================================
jackiw@cs.swarthmore.edu (Nick Jackiw) (09/28/89)
In article <8909261258.AA01237@cscwam.UMD.EDU> rick@wam.UMD.EDU writes: > I hope someone can point me in the right direction. I'm looking for code > (C, asm, or Pascal) that will convert a bitmap into a region (ie black pixels > included in region or vice versa for white pixels). > Public domain source would be nice but commercial source will also do. Apple licenses a subroutine called _BitmapRgn, of the form: FUNCTION BitMapRgn(region:RgnHandle; bMap:BitMap):OSErr; "The region will be built so that all one bits in bMap are inside the region and all zero bits are outside of it." - Technote #193 The subroutine is available in the 32-bit Quickdraw init (I dunno the trap number, but the MacDTS would); or separately, from: Apple Software Licensing / Apple Computer, Inc. 20525 Mariani Ave MS 38-I / Cupertino, CA 95014 Also take a look at CalcMask and CopyMask, described in Inside Mac #IV. You may be able to accomplish your desired effect without ever needing to go to the region stage. -Nick > I need to use a bitmap to mask a region while > drawing in much the same way that X uses bitmaps as clipping regions while > drawing. Any help would be greatly appreciated. I think I may have seen some > discussion on this topic a while back in this newsgroup. Thanx. > > rick@wam.umd.edu -- _ _|\____ Nick Jackiw | Visual Geometry Project | Math Department / /_/ O> \ ------------+-------------------------+ Swarthmore College | O> | 215-328-8225| jackiw@cs.swarthmore.edu| Swarthmore PA 19081 \_Guernica_/ ------------+-------------------------+ USA