Replace invalid characters with HTML entities
— with — ’ with ’ + with + × with x ç with ç “ with “ ” with ” ‘ with ‘ • with • – with - µ with µ † with † Fix C++ θ with θ Yen symbol instead of times Fix broken apos Bullet again E-circumflex
This commit is contained in:
parent
9e52de9586
commit
500e7f5654
353 changed files with 5091 additions and 5091 deletions
28
49-03.html
28
49-03.html
|
|
@ -36,7 +36,7 @@
|
|||
</TABLE>
|
||||
</CENTER>
|
||||
<P><BR></P>
|
||||
<P>It would be handy to have a function that, given a base image and mask, generates the four image and mask alignments and fills in the <B>MaskedImage</B> structure. Listing 49.3, together with the include file in Listing 49.4 and the system memory-to-display memory block-copy routine in Listing 48.4 (in the previous chapter) does just that. It would be faster if Listing 49.3 were in assembly language, but there’s no reason to think that generating aligned images needs to be particularly fast; in such cases, I prefer to use C, for reasons of coding speed, fewer bugs, and maintainability.</P>
|
||||
<P>It would be handy to have a function that, given a base image and mask, generates the four image and mask alignments and fills in the <B>MaskedImage</B> structure. Listing 49.3, together with the include file in Listing 49.4 and the system memory-to-display memory block-copy routine in Listing 48.4 (in the previous chapter) does just that. It would be faster if Listing 49.3 were in assembly language, but there’s no reason to think that generating aligned images needs to be particularly fast; in such cases, I prefer to use C, for reasons of coding speed, fewer bugs, and maintainability.</P>
|
||||
<P><B>LISTING 49.3 L49-3.C</B></P>
|
||||
<!-- CODE //-->
|
||||
<PRE>
|
||||
|
|
@ -49,11 +49,11 @@ off corresponding image pixel (causing it not to be drawn), and each non-0-byte
|
|||
allowing corresponding image pixel to be drawn. Returns 0 if failure, or # of
|
||||
display memory addresses (4-pixel sets) used if success. For simplicity,
|
||||
allocated memory is not deallocated in case of failure. Compiled with
|
||||
Borland C++ in C compilation mode. */
|
||||
Borland C++ in C compilation mode. */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include “maskim.h”
|
||||
#include “maskim.h”
|
||||
|
||||
extern void CopySystemToScreenX(int, int, int, int, int, int, char *,
|
||||
unsigned int, int, int);
|
||||
|
|
@ -67,13 +67,13 @@ unsigned int CreateAlignedMaskedImage(MaskedImage * ImageToSet,
|
|||
AlignedMaskedImage *WorkingAMImage;
|
||||
char *NewMaskPtr, *OldMaskPtr;
|
||||
/* Generate each of the four alignments in turn. */
|
||||
for (Align = 0; Align < 4; Align++) {
|
||||
for (Align = 0; Align < 4; Align++) {
|
||||
/* Allocate space for the AlignedMaskedImage struct for this alignment. */
|
||||
if ((WorkingAMImage = ImageToSet->Alignments[Align] =
|
||||
malloc(sizeof(AlignedMaskedImage))) == NULL)
|
||||
return 0;
|
||||
WorkingAMImage->ImageWidth =
|
||||
(ImageWidth + Align + 3) / 4; /* width in 4-pixel sets */
|
||||
(ImageWidth + Align + 3) / 4; /* width in 4-pixel sets */
|
||||
WorkingAMImage->ImagePtr = DispMemOffset; /* image dest */
|
||||
/* Download this alignment of the image. */
|
||||
CopySystemToScreenX(0, 0, ImageWidth, ImageHeight, Align, 0,
|
||||
|
|
@ -87,22 +87,22 @@ unsigned int CreateAlignedMaskedImage(MaskedImage * ImageToSet,
|
|||
the mask, one scan line at a time. */
|
||||
OldMaskPtr = Mask;
|
||||
NewMaskPtr = WorkingAMImage->MaskPtr;
|
||||
for (ScanLine = 0; ScanLine < ImageHeight; ScanLine++) {
|
||||
for (ScanLine = 0; ScanLine < ImageHeight; ScanLine++) {
|
||||
BitNum = Align;
|
||||
MaskTemp = 0;
|
||||
TempImageWidth = ImageWidth;
|
||||
do {
|
||||
/* Set the mask bit for next pixel according to its alignment. */
|
||||
MaskTemp |= (*OldMaskPtr++ != 0) << BitNum;
|
||||
if (++BitNum > 3) {
|
||||
*NewMaskPtr++ = MaskTemp;
|
||||
MaskTemp |= (*OldMaskPtr++ != 0) << BitNum;
|
||||
if (++BitNum > 3) {
|
||||
*NewMaskPtr++ = MaskTemp;
|
||||
MaskTemp = BitNum = 0;
|
||||
}
|
||||
} while (--TempImageWidth);
|
||||
/* Set any partial final mask on this scan line. */
|
||||
if (BitNum != 0) *NewMaskPtr++ = MaskTemp;
|
||||
if (BitNum != 0) *NewMaskPtr++ = MaskTemp;
|
||||
}
|
||||
DispMemOffset += Size; /* mark off the space we just used */
|
||||
DispMemOffset += Size; /* mark off the space we just used */
|
||||
}
|
||||
return DispMemOffset - DispMemStart;
|
||||
}
|
||||
|
|
@ -131,10 +131,10 @@ typedef struct {
|
|||
</PRE>
|
||||
<!-- END CODE //-->
|
||||
<H4 ALIGN="LEFT"><A NAME="Heading5"></A><FONT COLOR="#000077">Notes on Masked Copying</FONT></H4>
|
||||
<P>Listings 49.1 and 49.2, like all Mode X code I’ve presented, perform no clipping, because clipping code would complicate the listings too much. While clipping can be implemented directly in the low-level Mode X routines (at the beginning of Listing 49.1, for instance), another, potentially simpler approach would be to perform clipping at a higher level, modifying the coordinates and dimensions passed to low-level routines such as Listings 49.1 and 49.2 as necessary to accomplish the desired clipping. It is for precisely this reason that the low-level Mode X routines support programmable start coordinates in the source images, rather than assuming (0,0); likewise for the distinction between the width of the image and the width of the area of the image to draw.
|
||||
<P>Listings 49.1 and 49.2, like all Mode X code I’ve presented, perform no clipping, because clipping code would complicate the listings too much. While clipping can be implemented directly in the low-level Mode X routines (at the beginning of Listing 49.1, for instance), another, potentially simpler approach would be to perform clipping at a higher level, modifying the coordinates and dimensions passed to low-level routines such as Listings 49.1 and 49.2 as necessary to accomplish the desired clipping. It is for precisely this reason that the low-level Mode X routines support programmable start coordinates in the source images, rather than assuming (0,0); likewise for the distinction between the width of the image and the width of the area of the image to draw.
|
||||
</P>
|
||||
<P>Also, it would be more efficient to make up structures that describe the source and destination bitmaps, with dimensions and coordinates built in, and simply pass pointers to these structures to the low level, rather than passing many separate parameters, as is now the case. I’ve used separate parameters for simplicity and flexibility.</P>
|
||||
<TABLE WIDTH="100%"><TD WIDTH="5%" VALIGN="TOP"><IMG SRC="images/i.jpg"><TD WIDTH="95%"><SMALL><I>Be aware that as nifty as Mode X hardware-assisted masked copying is, whether or not it’s actually faster than software-only masked or transparent copying depends upon the processor and the video adapter. The advantage of Mode X masked copying is the 32-bit parallelism; the disadvantages are the need to read display memory and the need to perform an <B>OUT</B> for every four pixels. (<B>OUT</B> is a slow 486/Pentium instruction, and most VGAs respond to <B>OUT</B>s much more slowly than to display memory writes.)</I></SMALL>
|
||||
<P>Also, it would be more efficient to make up structures that describe the source and destination bitmaps, with dimensions and coordinates built in, and simply pass pointers to these structures to the low level, rather than passing many separate parameters, as is now the case. I’ve used separate parameters for simplicity and flexibility.</P>
|
||||
<TABLE WIDTH="100%"><TD WIDTH="5%" VALIGN="TOP"><IMG SRC="images/i.jpg"><TD WIDTH="95%"><SMALL><I>Be aware that as nifty as Mode X hardware-assisted masked copying is, whether or not it’s actually faster than software-only masked or transparent copying depends upon the processor and the video adapter. The advantage of Mode X masked copying is the 32-bit parallelism; the disadvantages are the need to read display memory and the need to perform an <B>OUT</B> for every four pixels. (<B>OUT</B> is a slow 486/Pentium instruction, and most VGAs respond to <B>OUT</B>s much more slowly than to display memory writes.)</I></SMALL>
|
||||
</TABLE>
|
||||
<P><BR></P>
|
||||
<CENTER>
|
||||
|
|
|
|||
Loading…
Reference in a new issue