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.
DrawTextDecompress.c
/* |
File: DrawTextDecompress.c |
Contains: |
Written by: Mark Krueger |
Copyright: Copyright © 1992-1999 by Apple Computer, Inc., All Rights Reserved. |
You may incorporate this Apple sample source code into your program(s) without |
restriction. This Apple sample source code has been provided "AS IS" and the |
responsibility for its operation is yours. You are not permitted to redistribute |
this Apple sample source code as "Apple sample source 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 source |
code, but that you've made changes. |
Change History (most recent first): |
7/29/1999 Karl Groethe Updated for Metrowerks Codewarror Pro 2.1 |
*/ |
#include <QuickDraw.h> |
#include "ImageCompression.h" |
#include "DrawTextCodec.h" |
long Decompress(unsigned char *baseAddr,short rowBytes,short bwidth,short bheight,char *dataPtr); |
/* |
decompress bheight strips ( of bwidth blocks ) of data. Each block is represented |
by one character of the font from compressed data. Font is assumed to be the same |
as that used in compression - ( font type style and size could be included in a header |
before the actual compressed data if we wanted to be truly flexible, but for a half-hour |
demo hack we dont wanna be) |
destination must be 1-bit/pixel. |
should be called in 32-bit mode. |
*/ |
long |
Decompress(unsigned char *baseAddr,short rowBytes,short bwidth,short bheight,char *dataPtr) |
{ |
char *startDataPtr; |
unsigned char *rp,*bp; |
short i,x,y; |
startDataPtr = dataPtr; /* remember where we started from */ |
TextSize(FONT_SIZE); |
TextFont(FONT_ID); |
for ( y=0; y < bheight; y++ ) { |
rp = baseAddr; |
for (x=0; x < bwidth; x++) { |
bp = rp; |
for ( i=0; i < FONT_HEIGHT; i++ ) { |
*bp = 0; |
bp += rowBytes; |
} |
MoveTo(x*FONT_WIDTH,BASE_LINE + y*FONT_HEIGHT); |
DrawChar(*dataPtr++); |
rp++; |
if ( x < bwidth ) { |
bp = rp; |
for ( i=0; i < FONT_HEIGHT; i++ ) { |
*bp = 0; |
bp += rowBytes; |
} |
} |
} |
baseAddr += rowBytes * FONT_HEIGHT; |
} |
return (dataPtr - startDataPtr); |
} |
Copyright © 2003 Apple Computer, Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2003-01-14