Mercurial > hg > dmlib
comparison tools/lib64fmts.c @ 1912:8d006508e6c1
Implement write support for ECI Graphic Editor 1.0 packed format.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 27 Jun 2018 13:13:57 +0300 |
parents | efe6e88a02f3 |
children | 788cfc7096f3 |
comparison
equal
deleted
inserted
replaced
1911:794cbb938a58 | 1912:8d006508e6c1 |
---|---|
966 if ((res = dmDecodeGenericRLEAlloc( | 966 if ((res = dmDecodeGenericRLEAlloc( |
967 &mem, dmGrowBufConstCopyOffs(&tmp, buf, 1), &cfg)) == DMERR_OK) | 967 &mem, dmGrowBufConstCopyOffs(&tmp, buf, 1), &cfg)) == DMERR_OK) |
968 res = dmC64DecodeGenericBMP(img, &mem, fmt); | 968 res = dmC64DecodeGenericBMP(img, &mem, fmt); |
969 | 969 |
970 dmGrowBufFree(&mem); | 970 dmGrowBufFree(&mem); |
971 return res; | |
972 } | |
973 | |
974 | |
975 static int fmtEncodeECIPacked(DMGrowBuf *buf, const DMC64Image *img, const DMC64ImageFormat *fmt) | |
976 { | |
977 int res; | |
978 DMGrowBuf tmp; | |
979 DMCompParams cfg; | |
980 | |
981 // Encode the data to temp buffer | |
982 if ((res = dmC64EncodeGenericBMP(TRUE, &tmp, img, fmt)) != DMERR_OK) | |
983 goto out; | |
984 | |
985 // Analyze and setup RLE | |
986 cfg.func = fmt->name; | |
987 cfg.type = DM_COMP_RLE_MARKER; | |
988 cfg.flags = DM_RLE_BYTE_RUNS | DM_RLE_ORDER_1; | |
989 cfg.rleMinCountB = 4; | |
990 cfg.rleMaxCountB = 255; | |
991 | |
992 dmGenericRLEAnalyze(&tmp, &cfg); | |
993 | |
994 // Add the header bits | |
995 if (!dmGrowBufPutU8(buf, cfg.rleMarkerB)) | |
996 { | |
997 res = DMERR_MALLOC; | |
998 goto out; | |
999 } | |
1000 | |
1001 // And now RLE compress the data to the existing buffer | |
1002 res = dmEncodeGenericRLE(buf, &tmp, &cfg); | |
1003 | |
1004 out: | |
1005 dmGrowBufFree(&tmp); | |
971 return res; | 1006 return res; |
972 } | 1007 } |
973 | 1008 |
974 | 1009 |
975 // | 1010 // |
1618 NULL, NULL, | 1653 NULL, NULL, |
1619 { }, &dmC64CommonFormats[7] | 1654 { }, &dmC64CommonFormats[7] |
1620 }, | 1655 }, |
1621 | 1656 |
1622 { | 1657 { |
1623 "ecp", "ECI Graphic Editor 1.0 (packed)", 0x4000, 0, DM_FMT_RD, | 1658 "ecp", "ECI Graphic Editor 1.0 (packed)", 0x4000, 0, DM_FMT_RDWR, |
1624 fmtProbeECIPacked, | 1659 fmtProbeECIPacked, |
1625 fmtDecodeECIPacked, NULL, | 1660 fmtDecodeECIPacked, fmtEncodeECIPacked, |
1626 { }, &dmC64CommonFormats[7] | 1661 { }, &dmC64CommonFormats[7] |
1627 }, | 1662 }, |
1628 | 1663 |
1629 { | 1664 { |
1630 "xx1", "Unknown $2000 format (unpacked)", 0x2000, 10242, DM_FMT_RDWR, | 1665 "xx1", "Unknown $2000 format (unpacked)", 0x2000, 10242, DM_FMT_RDWR, |