Retired Document
Important: This sample code may not represent best practices for current development. The project may use deprecated symbols and illustrate technologies and techniques that are no longer recommended.
Source/Blitter.c
//¥ ------------------------------------------------------------------------------------------ ¥ |
//¥ |
//¥ Copyright © 1996 Apple Computer, Inc., All Rights Reserved |
//¥ |
//¥ |
//¥ You may incorporate this sample code into your applications without |
//¥ restriction, though the sample code has been provided "AS IS" and the |
//¥ responsibility for its operation is 100% yours. However, what you are |
//¥ not permitted to do is to redistribute the source as "DSC Sample Code" |
//¥ after having made changes. If you're going to re-distribute the source, |
//¥ we require that you make it clear in the source that the code was |
//¥ descended from Apple Sample Code, but that you've made changes. |
//¥ |
//¥ Authors: |
//¥ Chris De Salvo |
//¥ |
//¥ ------------------------------------------------------------------------------------------ ¥ |
//¥ ------------------------------ Includes |
#include <QDOffscreen.h> |
#include <Types.h> |
#include "Blitter.h" |
//¥ ------------------------------ Private Definitions |
//¥ ------------------------------ Private Types |
//¥ ------------------------------ Private Variables |
//¥ ------------------------------ Private Functions |
//¥ ------------------------------ Public Variables |
//¥ -------------------- TransBitBlit |
void |
TransBitBlit(UInt8 *image, CGrafPtr dest, UInt32 width, UInt32 height, UInt32 fullWidth, SInt32 x, SInt32 y) |
{ |
UInt32 srcRowBytes, destRowBytes; |
UInt8 *srcBits, *destBits; |
UInt32 h, v; |
srcRowBytes = fullWidth; |
//¥ Find the base address and rowbytes of the destination buffer |
destRowBytes = (**(*dest).portPixMap).rowBytes & 0x7FFF; |
destBits = (unsigned char *) GetPixBaseAddr(GetGWorldPixMap(dest)); |
//¥ Jump down to the target pixel in the destination |
destBits += y * destRowBytes; |
destBits += x; |
srcBits = image; |
for (v = 0; v < height; v++) |
{ |
for (h = 0; h < width; h++) |
{ |
//¥ Our transparent color is palette index zero |
if (*srcBits) |
*destBits = *srcBits; |
destBits++; |
srcBits++; |
} |
srcBits += srcRowBytes - width; |
destBits += destRowBytes - width; |
} |
} |
Copyright © 2003 Apple Computer, Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2003-10-14