comparison tools/libgfx.c @ 1614:b2fe49401465

Cleanup.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 15 May 2018 12:35:55 +0300
parents 70b04c16aa40
children 2f8f2f7a42c8
comparison
equal deleted inserted replaced
1613:70b04c16aa40 1614:b2fe49401465
1601 } 1601 }
1602 1602
1603 1603
1604 void dmDecodeBitPlane(Uint8 *dp, Uint8 *src, const int width, const int nplane) 1604 void dmDecodeBitPlane(Uint8 *dp, Uint8 *src, const int width, const int nplane)
1605 { 1605 {
1606 int xc; 1606 for (int xc = 0; xc < width; xc++)
1607 for (xc = 0; xc < width; xc++)
1608 { 1607 {
1609 const Uint8 data = (src[xc / 8] >> (7 - (xc & 7))) & 1; 1608 const Uint8 data = (src[xc / 8] >> (7 - (xc & 7))) & 1;
1610 dp[xc] |= (data << nplane); 1609 dp[xc] |= (data << nplane);
1611 } 1610 }
1612 } 1611 }
1638 dmMsg(2, "ILBM: plane row size %d bytes.\n", bufLen); 1637 dmMsg(2, "ILBM: plane row size %d bytes.\n", bufLen);
1639 1638
1640 // Decode the chunk 1639 // Decode the chunk
1641 for (yc = 0; yc < img->height; yc++) 1640 for (yc = 0; yc < img->height; yc++)
1642 { 1641 {
1643 int plane;
1644 const int nplanes = iff->bmhd.nplanes; 1642 const int nplanes = iff->bmhd.nplanes;
1645 Uint8 *dp = img->data + (yc * img->pitch); 1643 Uint8 *dp = img->data + (yc * img->pitch);
1646 1644
1647 dmMemset(dp, 0, img->pitch); 1645 dmMemset(dp, 0, img->pitch);
1648 1646
1649 for (plane = 0; plane < nplanes; plane++) 1647 for (int plane = 0; plane < nplanes; plane++)
1650 { 1648 {
1651 // Decompress or read data 1649 // Decompress or read data
1652 if (!dmIFFReadOneRow(fp, iff, buf, bufLen)) 1650 if (!dmIFFReadOneRow(fp, iff, buf, bufLen))
1653 { 1651 {
1654 res = dmError(DMERR_FREAD, 1652 res = dmError(DMERR_FREAD,
1664 } 1662 }
1665 1663
1666 // Read mask data 1664 // Read mask data
1667 if (iff->bmhd.masking == IFF_MASK_HAS_MASK) 1665 if (iff->bmhd.masking == IFF_MASK_HAS_MASK)
1668 { 1666 {
1669 int xc;
1670
1671 // Decompress or read data 1667 // Decompress or read data
1672 if (!dmIFFReadOneRow(fp, iff, buf, bufLen)) 1668 if (!dmIFFReadOneRow(fp, iff, buf, bufLen))
1673 { 1669 {
1674 res = dmError(DMERR_FREAD, 1670 res = dmError(DMERR_FREAD,
1675 "ILBM: Error in reading mask plane.\n"); 1671 "ILBM: Error in reading mask plane.\n");
1676 goto error; 1672 goto error;
1677 } 1673 }
1678 1674
1679 // Decode mask 1675 // Decode mask
1680 for (xc = 0; xc < img->width; xc++) 1676 for (int xc = 0; xc < img->width; xc++)
1681 { 1677 {
1682 const Uint8 data = (buf[xc / 8] >> (7 - (xc & 7))) & 1; 1678 const Uint8 data = (buf[xc / 8] >> (7 - (xc & 7))) & 1;
1683 1679
1684 // Black out any pixels with mask bit 0 1680 // Black out any pixels with mask bit 0
1685 if (!data) 1681 if (!data)