comparison tools/lib64gfx.c @ 1931:410679d2fe8a

"Enable" the image->c64 bitmap conversion path in gfxconv. It does not work without the necessary bits elsewhere, though. Also add DMC64ImageConvSpec structure for delivering conversion parameters, though it is not yet used either.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 28 Jun 2018 17:26:30 +0300
parents 1b55bcf548de
children c5a46cb4cce5
comparison
equal deleted inserted replaced
1930:c048da352279 1931:410679d2fe8a
1228 } 1228 }
1229 1229
1230 1230
1231 // Convert a generic "C64" format bitmap in DMC64Image struct to 1231 // Convert a generic "C64" format bitmap in DMC64Image struct to
1232 // a indexed/paletted bitmap image. 1232 // a indexed/paletted bitmap image.
1233 int dmC64ConvertGenericBMP2Image(DMImage *dst, const DMC64Image *src, const DMC64ImageFormat *fmt) 1233 int dmC64ConvertGenericBMP2Image(DMImage *dst, const DMC64Image *src,
1234 const DMC64ImageFormat *fmt, const DMC64ImageConvSpec *spec)
1234 { 1235 {
1235 DMC64GetPixelFunc getPixel; 1236 DMC64GetPixelFunc getPixel;
1236 1237
1237 // Sanity check arguments 1238 // Sanity check arguments
1238 if (dst == NULL || src == NULL) 1239 if (dst == NULL || src == NULL || fmt == NULL || spec == NULL)
1239 return DMERR_NULLPTR; 1240 return DMERR_NULLPTR;
1240 1241
1241 if (dst->width < src->width || dst->height < src->height) 1242 if (dst->width < src->width || dst->height < src->height)
1242 { 1243 {
1243 return dmError(DMERR_INVALID_DATA, 1244 return dmError(DMERR_INVALID_DATA,
1356 1357
1357 return DMERR_OK; 1358 return DMERR_OK;
1358 } 1359 }
1359 1360
1360 1361
1361 int dmC64ConvertBMP2Image(DMImage **pdst, const DMC64Image *src, const DMC64ImageFormat *fmt) 1362 int dmC64ConvertBMP2Image(DMImage **pdst, const DMC64Image *src,
1363 const DMC64ImageFormat *fmt, const DMC64ImageConvSpec *spec)
1362 { 1364 {
1363 int res; 1365 int res;
1364 DMImage *dst; 1366 DMImage *dst;
1365 1367
1366 if (pdst == NULL || src == NULL) 1368 if (pdst == NULL || src == NULL || fmt == NULL || spec == NULL)
1367 return DMERR_NULLPTR; 1369 return DMERR_NULLPTR;
1368 1370
1369 // Allocate image structure 1371 // Allocate image structure
1370 if ((*pdst = dst = dmImageAlloc(src->width, src->height, DM_COLFMT_PALETTE, -1)) == NULL) 1372 if ((*pdst = dst = dmImageAlloc(src->width, src->height, DM_COLFMT_PALETTE, -1)) == NULL)
1371 return DMERR_MALLOC; 1373 return DMERR_MALLOC;
1375 dst->constpal = TRUE; 1377 dst->constpal = TRUE;
1376 dst->pal = dmDefaultC64Palette; 1378 dst->pal = dmDefaultC64Palette;
1377 1379
1378 // Convert 1380 // Convert
1379 if (fmt->format->convertFrom != NULL) 1381 if (fmt->format->convertFrom != NULL)
1380 res = fmt->format->convertFrom(dst, src, fmt); 1382 res = fmt->format->convertFrom(dst, src, fmt, spec);
1381 else 1383 else
1382 res = dmC64ConvertGenericBMP2Image(dst, src, fmt); 1384 res = dmC64ConvertGenericBMP2Image(dst, src, fmt, spec);
1383 1385
1384 return res; 1386 return res;
1385 } 1387 }
1386 1388
1387 1389
1431 return dmC64DecodeGenericBMP(*img, &tmp, *fmt); 1433 return dmC64DecodeGenericBMP(*img, &tmp, *fmt);
1432 } 1434 }
1433 1435
1434 1436
1435 // Convert a generic bitmap image to DMC64Image 1437 // Convert a generic bitmap image to DMC64Image
1436 int dmC64ConvertGenericImage2BMP(DMC64Image *dst, const DMImage *src, const DMC64ImageFormat *fmt) 1438 int dmC64ConvertGenericImage2BMP(DMC64Image *dst, const DMImage *src,
1437 { 1439 const DMC64ImageFormat *fmt, const DMC64ImageConvSpec *spec)
1438 if (dst == NULL || src == NULL || fmt == NULL) 1440 {
1441 if (dst == NULL || src == NULL || fmt == NULL || spec == NULL)
1439 return DMERR_NULLPTR; 1442 return DMERR_NULLPTR;
1440 1443
1441 return DMERR_OK; 1444 return DMERR_OK;
1442 } 1445 }
1443 1446
1444 1447
1445 int dmC64ConvertImage2BMP(DMC64Image **pdst, const DMImage *src, const DMC64ImageFormat *fmt) 1448 int dmC64ConvertImage2BMP(DMC64Image **pdst, const DMImage *src,
1449 const DMC64ImageFormat *fmt, const DMC64ImageConvSpec *spec)
1446 { 1450 {
1447 int res; 1451 int res;
1448 DMC64Image *dst; 1452 DMC64Image *dst;
1449 1453
1450 if (pdst == NULL || src == NULL) 1454 if (pdst == NULL || src == NULL)
1454 if ((*pdst = dst = dmC64ImageAlloc(fmt)) == NULL) 1458 if ((*pdst = dst = dmC64ImageAlloc(fmt)) == NULL)
1455 return DMERR_MALLOC; 1459 return DMERR_MALLOC;
1456 1460
1457 // Convert 1461 // Convert
1458 if (fmt->format->convertTo != NULL) 1462 if (fmt->format->convertTo != NULL)
1459 res = fmt->format->convertTo(dst, src, fmt); 1463 res = fmt->format->convertTo(dst, src, fmt, spec);
1460 else 1464 else
1461 res = dmC64ConvertGenericImage2BMP(dst, src, fmt); 1465 res = dmC64ConvertGenericImage2BMP(dst, src, fmt, spec);
1462 1466
1463 return res; 1467 return res;
1464 } 1468 }
1465 1469
1466 1470