calculation of srcwidth and dstwidth for wrastop()

john.r.sladkey..jr sladkey at cbnewsb.cb.att.com
Sat Apr 20 06:36:31 AEST 1991


In article <1991Apr19.133128.22408 at uncecs.edu>
	tcamp at uncecs.edu (Ted A. Campbell) writes:

> I am writing an application utilizing tam() and wrastop()
> routines for graphics output...
>            ...The wrastop() routines allow this, but 
> the calculation of the srcwidth and dstwidth parameters
> remains a great mystery to me. Why, if the rectangle
> width is specified later, do these parameters need to
> be given.

I too struggled with this question.  Eventually, I figured out that
one need not always blit WHOLE bitmaps!  Full bitmaps have dimensions
which make sense.  The x dimension is rounded up to the next multiple
of 16 to get whole 68000 words, then multiplied by 2 to get the width in bytes.
This looks like:

/* hand optimization of this seemingly simple formula
	is left as an exercise for the reader (grin) */

width = (dx + 15)/16 * 2;

Now that RASTOP knows the full byte-wise row-size it can do the proper
row/column addressing to get at the individual bytes and bits.  (One of
my gripes with C lang is that ordinary (static) multi-dimensional arrays cannot
be passed to a function without a lot of hassle, this example is a
case in point.)  Now if you want to blit a small portion of this bitmap,
just limit the dx and dy to your desired size.  In any case, RASTOP
needs to know (and cannot figure out any other way) what the actual bitmap
dimensions are.

Rick Sladkey
mvjrs at mvgpk.att.com



More information about the Comp.sys.3b1 mailing list