[comp.sys.mac.programmer] Bitmap to region conversion

cs224052@brap0aa3 (Scott Draves) (03/24/88)

I need to convert a bitmap into a region, where the region should
contain exactly those bits that are black in the bitmap.  This
is so that I can draw icons with a mask, but I can't use CopyMask,
because I want it to print as well.  CopyBits is a more
standard routine anyway (CopyMask wasn't documented until IM IV).
Any ideas?  If if I have to mess with the Region datastructure itself,

then what is it?  Where is it documented?
Giga Thanks,
Scott Draves

PS: Reply to wsd@cs.brown.edu
****

lsr@Apple.COM (Larry Rosenstein) (04/06/88)

In article <24175@brunix.UUCP> cs224052@brap0aa3.UUCP (Scott Draves) writes:
>
>I need to convert a bitmap into a region, where the region should
>contain exactly those bits that are black in the bitmap.  This

Tech Note #193 (which just came out) talks about a new Quickdraw call
BitMapRgn, which does exactly this.  The Tech Note says that this is going
to be incorporated into a future version of the system, but that you can
also contact the Software Licensing department to get an MPW object file
that you can link with your program:
	Software Licensing
	Apple Computer Inc
	20525 Mariani M/S 28-B
	Cupertino, CA 95014
(AppleLink: SW.License)


-- 
		 Larry Rosenstein,  Object Specialist
 Apple Computer, Inc.  20525 Mariani Ave, MS 27-AJ  Cupertino, CA 95014
	    AppleLink:Rosenstein1    domain:lsr@Apple.COM
		UUCP:{sun,voder,nsc,decwrl}!apple!lsr

alibaba@ucscb.UCSC.EDU (Alexander M. Rosenberg) (04/06/88)

Since you know what tech notes are out, could you perhaps list the titles
of them? APDA still has not sent anybody I have talked to the January or
later Tech Notes. I heard of a total rewrite, but obviously this is not
what is causing the delay. Could you favor us with what's new topic-wise,
since we (at least me) haven't gotten any in a while????

-------------------------------------------------------------------------------
-  Alexander M. Rosenberg  - INTERNET: alibaba@ucscb.ucsc.edu   - Yoyodyne    -
-  Crown College, UCSC     - UUCP:...!ucbvax!ucscc!ucscb!alibaba- Propulsion  -
-  Santa Cruz, CA 95064    - BITNET:alibaba%ucscb@ucscc.BITNET  - Systems     -
-  (408) 426-8869	   - Disclaimer: Nobody is my employer  - :-)         -
-			   - so nobody cares what I say.	-	      -

russotto@wam.UMD.EDU (04/19/89)

I've heard that there is a routine available for converting
bitmaps to regions (for use in DragGrayRgn for example)
Can anyone tell me where to get it, and hopefully, how
fast it is for an average 32x32 bitmap.
(I looked in the Inside Mac's and it doesn't seem to be
a standard ROM call.  The tech notes index mentions it,
but I don't have the tech note it refers to)



-- 
	Matthew T. Russotto
	russotto@wam.umd.edu
DISCLAIMER:  Not only does the University not share my opinions,
	     they don't want me sharing my opinions.

jmunkki@kampi.hut.fi (Juri Munkki) (04/21/89)

In article <21369@santra.UUCP> jmunkki@kampi.hut.fi (Juri Munkki) writes:
>In article <8904181853.AA00466@vs08csc.UMD.EDU> russotto@wam.UMD.EDU writes:
>>I've heard that there is a routine available for converting
>>bitmaps to regions (for use in DragGrayRgn for example)
>
>I decided that we needed a better answer. It took me two hours to write
>a program that does the conversion on an aribitrary bitmap. I wrote it
>in LSC and it is totally unoptimized (with calls like BitTst), but it
>seems to work. It is under 200 lines in size (it also contains a test
>program & code that draws a picture into a bitmap).

I have already gotten a few requests for it, so I'm making available by
anonymous ftp from vega.hut.fi (128.214.3.82). There are two files:

	pub/mac/finnish/bitrgn.c		Source code	(Think C)
	pub/mac/finnish/bitrgn.rsrc.bin		Test resources	(ResEdit)

Please note that the resource file in in MacBinary format. You have to
set the binary mode to transfer it correctly.

Unless someone objects, I will post it here when a few people have confirmed
that it really works and that they find it useful. If you do not have ftp
access, wait for the posting or tell me (mail) that you would like to see
it posted. Since the region data structure is not public, I would like someone
from Apple to read it before everybody starts using it.

The source code doesn't really document the region data structure well enough
for anyone to understand it. I might write a description, if I find the time.

_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
|     Juri Munkki jmunkki@hut.fi  jmunkki@fingate.bitnet        I Want   Ne   |
|     Helsinki University of Technology Computing Centre        My Own   XT   |
^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^

darin@Apple.COM (Darin Adler) (04/22/89)

In article <21369@santra.UUCP> jmunkki@kampi.hut.fi (Juri Munkki) writes:
> In article <8904181853.AA00466@vs08csc.UMD.EDU> russotto@wam.UMD.EDU writes:
> >I've heard that there is a routine available for converting
> >bitmaps to regions (for use in DragGrayRgn for example)
> 
> This seems to be one of the most commonly asked questions in
> comp.sys.mac.programmer.  The standard answer is that code that does
> this is available from the Apple software licensing department (or
> something like that). I wonder if anyone of those who asked ever
> contacted Apple.

There *is* a call, BitMapRgn, available in glue form from the Apple software
licensing department. It will also be in a future system software release.
It is very fast, based on an algorithm by Andy Hertzfeld that he used to
generate regions to drag from icon masks in Servant. (Incidentally, this is
the only code in current Apple system software that came from Servant.)
-- 
Darin Adler, System Software Scapegoat, Apple Computer
	Internet: darin@Apple.com
	UUCP: {nsc,sun}!apple!darin

shebanow@apple.com (Andrew Shebanow) (04/25/89)

I might add that the BitMapRgn call is already available as part of the 
recently announced 32Bit Quickdraw package, although it hasn't been 
documented yet (we're working on it, really...).



Andrew Shebanow
MacDTS
- All Opinions Are Mine, and Mine Alone -