0x09, 0x04, 0x12, //%
};
-Image *
-ImageNew (int w, int h, int c)
+Image * ImageNew (int w, int h, int c)
{ // create a new blank image
Image *i;
if (!w || !h)
return i;
}
-void
-ImageFree (Image * i)
+void ImageFree (Image * i)
{ // free an image
if (i)
{
}
Private;
-static
-LZWFlush (Private * p)
+static LZWFlush (Private * p)
{ // flush this block
write (p->fh, p->block, *p->block + 1);
*p->block = 0;
}
-static
-LZWOut (Private * p, short v)
+static LZWOut (Private * p, short v)
{ // output a value
p->blockv |= (v << p->blockb);
p->blockb += p->lzwbits;
}
}
-static
-LZWClear (Private * p)
+static LZWClear (Private * p)
{
int c;
p->lzwbits = p->colbits + 1;
for (c = 0; c < p->cols; c++)
{
p->lzw[p->cols][c] = c; // links to literal entries
- memset (&p->lzw[c], -1, p->cols * 2); // links from literals, dead ends initially
+ // links from literals, dead ends initially
+ memset (&p->lzw[c], -1, p->cols * 2);
}
}
-static
-ImageStart (Private * p)
+static ImageStart (Private * p)
{
unsigned char b = p->colbits;
write (p->fh, &b, 1);
LZWOut (p, p->cols); // clear code
}
-static
-ImageEnd (Private * p)
+static ImageEnd (Private * p)
{
LZWOut (p, p->lzwcode); // last prefix
LZWOut (p, p->cols + 1); // end code
if (p->blockb)
- p->block[++*p->block] = p->blockv; // last partial byte
+ p->block[++*p->block] = p->blockv; // last partial byte
LZWFlush (p);
}
-static
-ImageOut (Private * p, unsigned char c)
+static ImageOut (Private * p, unsigned char c)
{
short next = p->lzw[p->lzwcode][c];
if (next == -1)
}
// write GIF image
-void
-ImageWriteGif (Image * i, int fh, int back, int trans, char *comment)
+void ImageWriteGif (Image * i, int fh, int back, int trans, char *comment)
{
struct strPrivate p;
p.fh = fh;
- for (p.colbits = 2, p.cols = 4; p.cols < i->C; p.cols *= 2, p.colbits++); // count colours, min 4
+ // count colours, min 4
+ for (p.colbits = 2, p.cols = 4; p.cols < i->C; p.cols *= 2, p.colbits++);
{ // headers
char buf[1500];
int n = 0;
write (fh, "\x3B", 1); // trailer
}
-void
-ImageText (Image * i, int x, int y, int col, char *text)
+void ImageText (Image * i, int x, int y, int col, char *text)
{ // writes 8x8 text
if (i && text)
while (*text)
}
}
-void
-ImageSmall (Image * i, int x, int y, int col, char *text)
+void ImageSmall (Image * i, int x, int y, int col, char *text)
{ // writes 4x6 digits
if (i && text)
while (*text)
}
}
-void
-ImageRect (Image * i, int x, int y, int w, int h, int c)
+void ImageRect (Image * i, int x, int y, int w, int h, int c)
{ // fill a box
if (i && w && h)
{
static unsigned int crc_table[256];
/* Make the table for a fast CRC. */
-void
-make_crc_table (void)
+void make_crc_table (void)
{
unsigned int c;
int n,
is the 1's complement of the final running CRC (see the
crc() routine below)). */
-unsigned int
-update_crc (unsigned int crc, unsigned char *buf, int len)
+unsigned int update_crc (unsigned int crc, unsigned char *buf, int len)
{
unsigned int c = crc;
int n;
}
/* Return the CRC of the bytes buf[0..len-1]. */
-unsigned int
-crc (unsigned char *buf, int len)
+unsigned int crc (unsigned char *buf, int len)
{
return update_crc (0xffffffffL, buf, len) ^ 0xffffffffL;
}
-unsigned int
-writecrc (int fh, char *ptr, int len, unsigned int c)
+unsigned int writecrc (int fh, char *ptr, int len, unsigned int c)
{
write (fh, ptr, len);
while (len--)
return c;
}
-void
-writechunk (int fh, char *typ, void *ptr, int len)
+void writechunk (int fh, char *typ, void *ptr, int len)
{
unsigned int v = htonl (len),
crc;
}
#ifndef USEZLIB
-unsigned int
-adlersum (unsigned char *p, int l, unsigned int adler)
+unsigned int adlersum (unsigned char *p, int l, unsigned int adler)
{
unsigned int s1 = (adler & 65535),
s2 = (adler >> 16);
#endif
// write PNG image
-void
-ImageWritePNG (Image * i, int fh, int back, int trans, char *comment)
+void ImageWritePNG (Image * i, int fh, int back, int trans, char *comment)
{
make_crc_table ();
write (fh, "\211PNG\r\n\032\n", 8); // PNG header
unsigned char alpha[256];
int n;
for (n = 0; n < i->C; n++)
- alpha[n] = 255 - (i->Colour[n] >> 24); // 4th palette byte treated as 0=opaque, 255-transparrent
+ // 4th palette byte treated as 0=opaque, 255-transparren
+ alpha[n] = 255 - (i->Colour[n] >> 24);
if (trans >= 0 && trans < i->C)
- alpha[trans] = 0; // manual set of specific transparrent colour
+ // manual set of specific transparrent colour
+ alpha[trans] = 0;
writechunk (fh, "tRNS", alpha, i->C);
}
#ifndef USEZLIB