Mercurial > hg > dmlib
comparison tools/libgfx.c @ 2457:16426e9dc238
Add few comments.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 15 Apr 2020 15:10:18 +0300 |
parents | 69a5af2eb1ea |
children | a11ef670bd99 |
comparison
equal
deleted
inserted
replaced
2456:f5f8001490ae | 2457:16426e9dc238 |
---|---|
344 int dmReadACTPalette(DMResource *fp, DMPalette **pdst) | 344 int dmReadACTPalette(DMResource *fp, DMPalette **pdst) |
345 { | 345 { |
346 int res; | 346 int res; |
347 Uint16 tmp1, tmp2; | 347 Uint16 tmp1, tmp2; |
348 | 348 |
349 // Allocate a palette with 256 entries | |
349 if ((res = dmPaletteAlloc(pdst, 256, -1)) != DMERR_OK) | 350 if ((res = dmPaletteAlloc(pdst, 256, -1)) != DMERR_OK) |
350 return res; | 351 return res; |
351 | 352 |
353 // Read data for 256 entries | |
352 if ((res = dmPaletteReadData(fp, *pdst, 256)) != DMERR_OK) | 354 if ((res = dmPaletteReadData(fp, *pdst, 256)) != DMERR_OK) |
353 goto error; | 355 goto error; |
354 | 356 |
357 // Read the footer | |
355 if (!dmf_read_be16(fp, &tmp1) || | 358 if (!dmf_read_be16(fp, &tmp1) || |
356 !dmf_read_be16(fp, &tmp2)) | 359 !dmf_read_be16(fp, &tmp2)) |
357 { | 360 { |
358 res = DMERR_FREAD; | 361 res = DMERR_FREAD; |
359 goto error; | 362 goto error; |
360 } | 363 } |
361 | 364 |
365 // Check for validity | |
362 if (tmp1 == 0 || tmp1 > 256) | 366 if (tmp1 == 0 || tmp1 > 256) |
363 { | 367 { |
364 res = DMERR_INVALID_DATA; | 368 res = DMERR_INVALID_DATA; |
365 goto error; | 369 goto error; |
366 } | 370 } |
367 | 371 |
372 // Resize the palette | |
368 if ((res = dmPaletteResize(pdst, tmp1)) != DMERR_OK) | 373 if ((res = dmPaletteResize(pdst, tmp1)) != DMERR_OK) |
369 goto error; | 374 goto error; |
370 | 375 |
371 (*pdst)->ctransp = tmp2 < 256 ? tmp2 : -1; | 376 (*pdst)->ctransp = tmp2 < 256 ? tmp2 : -1; |
372 | 377 |