comparison tools/libgfx.c @ 2414:69a5af2eb1ea

Remove useless dmMemset().
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 13 Jan 2020 23:27:01 +0200
parents 85700c9b7dc8
children 16426e9dc238
comparison
equal deleted inserted replaced
2413:902cc22018a1 2414:69a5af2eb1ea
1175 res = dmError(DMERR_MALLOC, 1175 res = dmError(DMERR_MALLOC,
1176 "PNG: Could not allocate palette structure."); 1176 "PNG: Could not allocate palette structure.");
1177 goto error; 1177 goto error;
1178 } 1178 }
1179 1179
1180 dmMemset(palette, 0, PNG_MAX_PALETTE_LENGTH * sizeof(png_color)); 1180 memset(palette, 0, PNG_MAX_PALETTE_LENGTH * sizeof(png_color));
1181 1181
1182 for (int i = 0; i < img->pal->ncolors; i++) 1182 for (int i = 0; i < img->pal->ncolors; i++)
1183 { 1183 {
1184 palette[i].red = img->pal->colors[i].r; 1184 palette[i].red = img->pal->colors[i].r;
1185 palette[i].green = img->pal->colors[i].g; 1185 palette[i].green = img->pal->colors[i].g;
1563 pcx.buf = NULL; 1563 pcx.buf = NULL;
1564 pcx.header = &hdr; 1564 pcx.header = &hdr;
1565 pcx.fp = fp; 1565 pcx.fp = fp;
1566 1566
1567 // Create PCX header 1567 // Create PCX header
1568 dmMemset(&hdr, 0, sizeof(hdr)); 1568 memset(&hdr, 0, sizeof(hdr));
1569 if (spec.pixfmt == DM_PIXFMT_PALETTE || 1569 if (spec.pixfmt == DM_PIXFMT_PALETTE ||
1570 spec.pixfmt == DM_PIXFMT_GRAYSCALE) 1570 spec.pixfmt == DM_PIXFMT_GRAYSCALE)
1571 { 1571 {
1572 const int ncolors = img->pal->ncolors > PCX_PAL_COLORS ? PCX_PAL_COLORS : img->pal->ncolors; 1572 const int ncolors = img->pal->ncolors > PCX_PAL_COLORS ? PCX_PAL_COLORS : img->pal->ncolors;
1573 for (int i = 0; i < ncolors; i++) 1573 for (int i = 0; i < ncolors; i++)
1889 } 1889 }
1890 } 1890 }
1891 break; 1891 break;
1892 1892
1893 case 1: 1893 case 1:
1894 dmMemset(dp, 0, img->width); 1894 memset(dp, 0, img->width);
1895 1895
1896 for (int nplane = 0; nplane < hdr.nplanes; nplane++) 1896 for (int nplane = 0; nplane < hdr.nplanes; nplane++)
1897 { 1897 {
1898 Uint8 *sptr = pcx.buf + (hdr.bpl * nplane); 1898 Uint8 *sptr = pcx.buf + (hdr.bpl * nplane);
1899 1899
2233 2233
2234 // Decode the chunk 2234 // Decode the chunk
2235 if (iff->idsig == IFF_ID_ACBM) 2235 if (iff->idsig == IFF_ID_ACBM)
2236 { 2236 {
2237 // Initialize destination image data 2237 // Initialize destination image data
2238 dmMemset(img->data, 0, img->size); 2238 memset(img->data, 0, img->size);
2239 2239
2240 for (int plane = 0; plane < nplanes; plane++) 2240 for (int plane = 0; plane < nplanes; plane++)
2241 { 2241 {
2242 // Decompress or read data 2242 // Decompress or read data
2243 if (!dmIFFReadOneRow(fp, iff, buf, bufLen)) 2243 if (!dmIFFReadOneRow(fp, iff, buf, bufLen))
2265 Uint8 *dp = img->data + (yc * img->pitch); 2265 Uint8 *dp = img->data + (yc * img->pitch);
2266 2266
2267 if (iff->idsig == IFF_ID_ILBM) 2267 if (iff->idsig == IFF_ID_ILBM)
2268 { 2268 {
2269 // Clear planar decoding buffer 2269 // Clear planar decoding buffer
2270 dmMemset(dp, 0, img->pitch); 2270 memset(dp, 0, img->pitch);
2271 2271
2272 for (int plane = 0; plane < nplanes; plane++) 2272 for (int plane = 0; plane < nplanes; plane++)
2273 { 2273 {
2274 // Decompress or read data 2274 // Decompress or read data
2275 if (!dmIFFReadOneRow(fp, iff, buf, bufLen)) 2275 if (!dmIFFReadOneRow(fp, iff, buf, bufLen))
2330 DMIFFChunk chunk; 2330 DMIFFChunk chunk;
2331 DMIFF iff; 2331 DMIFF iff;
2332 BOOL parsed = FALSE; 2332 BOOL parsed = FALSE;
2333 int res = DMERR_OK; 2333 int res = DMERR_OK;
2334 2334
2335 dmMemset(&iff, 0, sizeof(iff)); 2335 memset(&iff, 0, sizeof(iff));
2336 2336
2337 // Read IFF FORM header 2337 // Read IFF FORM header
2338 if ((res = dmReadIFFChunkHdr(fp, &chunk)) != DMERR_OK) 2338 if ((res = dmReadIFFChunkHdr(fp, &chunk)) != DMERR_OK)
2339 return res; 2339 return res;
2340 2340
2910 if (iff.idsig == IFF_ID_ACBM) 2910 if (iff.idsig == IFF_ID_ACBM)
2911 { 2911 {
2912 for (int plane = 0; plane < iff.bmhd.nplanes; plane++) 2912 for (int plane = 0; plane < iff.bmhd.nplanes; plane++)
2913 { 2913 {
2914 // Encode bitplane 2914 // Encode bitplane
2915 dmMemset(buf, 0, bufLen); 2915 memset(buf, 0, bufLen);
2916 2916
2917 for (int yc = 0; yc < img->height * spec->scaleY; yc++) 2917 for (int yc = 0; yc < img->height * spec->scaleY; yc++)
2918 { 2918 {
2919 Uint8 *sp = img->data + (yc * img->pitch); 2919 Uint8 *sp = img->data + (yc * img->pitch);
2920 Uint8 *dp = buf + (yc * img->width * spec->scaleX) / 8; 2920 Uint8 *dp = buf + (yc * img->width * spec->scaleX) / 8;
2941 if (iff.idsig == IFF_ID_ILBM) 2941 if (iff.idsig == IFF_ID_ILBM)
2942 { 2942 {
2943 for (int plane = 0; plane < spec->nplanes; plane++) 2943 for (int plane = 0; plane < spec->nplanes; plane++)
2944 { 2944 {
2945 // Encode bitplane 2945 // Encode bitplane
2946 dmMemset(buf, 0, bufLen); 2946 memset(buf, 0, bufLen);
2947 2947
2948 for (int xc = 0; xc < img->width * spec->scaleX; xc++) 2948 for (int xc = 0; xc < img->width * spec->scaleX; xc++)
2949 buf[xc / 8] |= ((sp[xc / spec->scaleX] >> plane) & 1) << (7 - (xc & 7)); 2949 buf[xc / 8] |= ((sp[xc / spec->scaleX] >> plane) & 1) << (7 - (xc & 7));
2950 2950
2951 // Compress / write data 2951 // Compress / write data
2959 } 2959 }
2960 2960
2961 // Write mask data, if any 2961 // Write mask data, if any
2962 if (iff.bmhd.masking == IFF_MASK_HAS_MASK) 2962 if (iff.bmhd.masking == IFF_MASK_HAS_MASK)
2963 { 2963 {
2964 dmMemset(buf, 0, bufLen); 2964 memset(buf, 0, bufLen);
2965 2965
2966 for (int xc = 0; xc < img->width * spec->scaleX; xc++) 2966 for (int xc = 0; xc < img->width * spec->scaleX; xc++)
2967 buf[xc / 8] |= (sp[xc / spec->scaleX] == img->pal->ctransp) << (7 - (xc & 7)); 2967 buf[xc / 8] |= (sp[xc / spec->scaleX] == img->pal->ctransp) << (7 - (xc & 7));
2968 2968
2969 if (!dmIFFWriteOneRow(fp, &iff, buf, bufLen)) 2969 if (!dmIFFWriteOneRow(fp, &iff, buf, bufLen))