Mercurial > hg > dmlib
annotate tools/lib64util.c @ 2247:bb7255792dd6
Constify.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sat, 15 Jun 2019 20:19:21 +0300 |
parents | 95f669692b01 |
children | 891acec47aa0 |
rev | line source |
---|---|
2204
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
1 /* |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
2 * Common utility functions for gfxconv and 64vw |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
3 * Programmed and designed by Matti 'ccr' Hamalainen |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
4 * (C) Copyright 2019 Tecnic Software productions (TNSP) |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
5 * |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
6 * Please read file 'COPYING' for information on license and distribution. |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
7 */ |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
8 #include "lib64util.h" |
2208
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
9 #include "dmfile.h" |
2204
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
10 |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
11 |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
12 char * dmC64GetImageTypeString(char *buf, const size_t len, const int type, const BOOL lng) |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
13 { |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
14 static const char *fmtModesShort[] = { "*", "HiR", "MC", "ECM" }; |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
15 static const char *fmtModesLong[] = { "*", "HiRes", "MultiColor", "Extended Color Mode" }; |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
16 const char *fmtStr; |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
17 size_t nfmt = type & D64_FMT_MODE_MASK; |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
18 |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
19 if (nfmt < sizeof(fmtModesShort) / sizeof(fmtModesShort[0])) |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
20 fmtStr = lng ? fmtModesLong[nfmt] : fmtModesShort[nfmt]; |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
21 else |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
22 fmtStr = lng ? "ERROR" : "ERR"; |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
23 |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
24 snprintf(buf, len, |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
25 "%s %s%s%s", |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
26 fmtStr, |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
27 (type & D64_FMT_ILACE) ? (lng ? "Interlaced " : "ILace ") : "", |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
28 (type & D64_FMT_FLI) ? "FLI " : "", |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
29 (type & D64_FMT_CHAR) ? "CHAR" : "" |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
30 ); |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
31 |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
32 return buf; |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
33 } |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
34 |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
35 |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
36 void dmC64ImageDump(FILE *fh, const DMC64Image *img, const DMC64ImageFormat *fmt, const char *indent) |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
37 { |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
38 char typeStr[64]; |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
39 |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
40 if (fmt != NULL) |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
41 { |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
42 fprintf(fh, |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
43 "%sFormat : %s [%s]\n", |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
44 indent, fmt->name, fmt->fext); |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
45 } |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
46 |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
47 if (img != NULL) |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
48 { |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
49 dmC64GetImageTypeString(typeStr, sizeof(typeStr), img->fmt->type, TRUE); |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
50 |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
51 fprintf(fh, |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
52 "%sType : %s\n" |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
53 "%sInternal blocks : %d\n", |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
54 indent, typeStr, |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
55 indent, img->nblocks); |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
56 |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
57 if (img->fmt->type & D64_FMT_ILACE) |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
58 { |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
59 char *tmps; |
2238
5db6e0b63b35
Change again how the interlace type information is stored. Now store it in
Matti Hamalainen <ccr@tnsp.org>
parents:
2210
diff
changeset
|
60 switch (img->extraInfo[D64_EI_ILACE_TYPE]) |
2204
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
61 { |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
62 case D64_ILACE_COLOR: tmps = "color"; break; |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
63 case D64_ILACE_RES: tmps = "resolution"; break; |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
64 default: tmps = "ERROR"; break; |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
65 } |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
66 fprintf(fh, |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
67 "%sInterlace type : %s\n", |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
68 indent, tmps); |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
69 } |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
70 |
2238
5db6e0b63b35
Change again how the interlace type information is stored. Now store it in
Matti Hamalainen <ccr@tnsp.org>
parents:
2210
diff
changeset
|
71 if (img->fmt->type & D64_FMT_FLI) |
5db6e0b63b35
Change again how the interlace type information is stored. Now store it in
Matti Hamalainen <ccr@tnsp.org>
parents:
2210
diff
changeset
|
72 { |
5db6e0b63b35
Change again how the interlace type information is stored. Now store it in
Matti Hamalainen <ccr@tnsp.org>
parents:
2210
diff
changeset
|
73 fprintf(fh, |
5db6e0b63b35
Change again how the interlace type information is stored. Now store it in
Matti Hamalainen <ccr@tnsp.org>
parents:
2210
diff
changeset
|
74 "%sFLI type : %d\n", |
5db6e0b63b35
Change again how the interlace type information is stored. Now store it in
Matti Hamalainen <ccr@tnsp.org>
parents:
2210
diff
changeset
|
75 indent, img->extraInfo[D64_EI_FLI_TYPE]); |
5db6e0b63b35
Change again how the interlace type information is stored. Now store it in
Matti Hamalainen <ccr@tnsp.org>
parents:
2210
diff
changeset
|
76 } |
5db6e0b63b35
Change again how the interlace type information is stored. Now store it in
Matti Hamalainen <ccr@tnsp.org>
parents:
2210
diff
changeset
|
77 |
2204
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
78 fprintf(fh, |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
79 "%sWidth x Height : %d x %d\n" |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
80 "%sCHwidth x CHheight : %d x %d\n" |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
81 "%sd020 / border : %d ($%02x)\n" |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
82 "%sd021 / background : %d ($%02x)\n", |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
83 indent, img->fmt->width, img->fmt->height, |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
84 indent, img->fmt->chWidth, img->fmt->chHeight, |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
85 indent, img->d020, img->d020, |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
86 indent, img->bgcolor, img->bgcolor); |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
87 } |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
88 else |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
89 if (fmt != NULL) |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
90 { |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
91 dmC64GetImageTypeString(typeStr, sizeof(typeStr), fmt->format->type, TRUE); |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
92 fprintf(fh, |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
93 "%sType : %s\n" |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
94 "%sWidth x Height : %d x %d\n" |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
95 "%sCHwidth x CHheight : %d x %d\n", |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
96 indent, typeStr, |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
97 indent, fmt->format->width, fmt->format->height, |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
98 indent, fmt->format->chWidth, fmt->format->chHeight); |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
99 } |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
100 } |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
101 |
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
102 |
2242
65a2c2e99c81
Move listing of C64 formats function to argShowC64Formats in lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2240
diff
changeset
|
103 void argShowC64Formats(FILE *fp, const BOOL rw) |
65a2c2e99c81
Move listing of C64 formats function to argShowC64Formats in lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2240
diff
changeset
|
104 { |
65a2c2e99c81
Move listing of C64 formats function to argShowC64Formats in lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2240
diff
changeset
|
105 fprintf(fp, |
65a2c2e99c81
Move listing of C64 formats function to argShowC64Formats in lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2240
diff
changeset
|
106 "Available C64 bitmap formats (-f <frmt>):\n" |
65a2c2e99c81
Move listing of C64 formats function to argShowC64Formats in lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2240
diff
changeset
|
107 " frmt %s| Type | Description\n" |
65a2c2e99c81
Move listing of C64 formats function to argShowC64Formats in lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2240
diff
changeset
|
108 "------%s+-----------------+-------------------------------------\n", |
65a2c2e99c81
Move listing of C64 formats function to argShowC64Formats in lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2240
diff
changeset
|
109 rw ? "| RW " : "", |
65a2c2e99c81
Move listing of C64 formats function to argShowC64Formats in lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2240
diff
changeset
|
110 rw ? "+----" : "" |
65a2c2e99c81
Move listing of C64 formats function to argShowC64Formats in lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2240
diff
changeset
|
111 ); |
65a2c2e99c81
Move listing of C64 formats function to argShowC64Formats in lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2240
diff
changeset
|
112 |
65a2c2e99c81
Move listing of C64 formats function to argShowC64Formats in lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2240
diff
changeset
|
113 for (int i = 0; i < ndmC64ImageFormats; i++) |
65a2c2e99c81
Move listing of C64 formats function to argShowC64Formats in lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2240
diff
changeset
|
114 { |
65a2c2e99c81
Move listing of C64 formats function to argShowC64Formats in lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2240
diff
changeset
|
115 const DMC64ImageFormat *fmt = dmC64ImageFormatsSorted[i]; |
65a2c2e99c81
Move listing of C64 formats function to argShowC64Formats in lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2240
diff
changeset
|
116 char buf[64]; |
65a2c2e99c81
Move listing of C64 formats function to argShowC64Formats in lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2240
diff
changeset
|
117 |
65a2c2e99c81
Move listing of C64 formats function to argShowC64Formats in lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2240
diff
changeset
|
118 fprintf(fp, "%-6s", |
65a2c2e99c81
Move listing of C64 formats function to argShowC64Formats in lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2240
diff
changeset
|
119 fmt->fext); |
65a2c2e99c81
Move listing of C64 formats function to argShowC64Formats in lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2240
diff
changeset
|
120 |
65a2c2e99c81
Move listing of C64 formats function to argShowC64Formats in lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2240
diff
changeset
|
121 if (rw) |
65a2c2e99c81
Move listing of C64 formats function to argShowC64Formats in lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2240
diff
changeset
|
122 { |
65a2c2e99c81
Move listing of C64 formats function to argShowC64Formats in lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2240
diff
changeset
|
123 fprintf(fp, "| %c%c ", |
65a2c2e99c81
Move listing of C64 formats function to argShowC64Formats in lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2240
diff
changeset
|
124 (fmt->flags & DM_FMT_RD) ? 'R' : ' ', |
65a2c2e99c81
Move listing of C64 formats function to argShowC64Formats in lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2240
diff
changeset
|
125 (fmt->flags & DM_FMT_WR) ? 'W' : ' ' |
65a2c2e99c81
Move listing of C64 formats function to argShowC64Formats in lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2240
diff
changeset
|
126 ); |
65a2c2e99c81
Move listing of C64 formats function to argShowC64Formats in lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2240
diff
changeset
|
127 } |
65a2c2e99c81
Move listing of C64 formats function to argShowC64Formats in lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2240
diff
changeset
|
128 |
65a2c2e99c81
Move listing of C64 formats function to argShowC64Formats in lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2240
diff
changeset
|
129 fprintf(fp, |
65a2c2e99c81
Move listing of C64 formats function to argShowC64Formats in lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2240
diff
changeset
|
130 "| %-15s | %s%s\n", |
65a2c2e99c81
Move listing of C64 formats function to argShowC64Formats in lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2240
diff
changeset
|
131 dmC64GetImageTypeString(buf, sizeof(buf), fmt->format->type, FALSE), |
65a2c2e99c81
Move listing of C64 formats function to argShowC64Formats in lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2240
diff
changeset
|
132 fmt->name, |
65a2c2e99c81
Move listing of C64 formats function to argShowC64Formats in lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2240
diff
changeset
|
133 fmt->flags & DM_FMT_BROKEN ? " [BROKEN]" : ""); |
65a2c2e99c81
Move listing of C64 formats function to argShowC64Formats in lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2240
diff
changeset
|
134 } |
65a2c2e99c81
Move listing of C64 formats function to argShowC64Formats in lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2240
diff
changeset
|
135 |
65a2c2e99c81
Move listing of C64 formats function to argShowC64Formats in lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2240
diff
changeset
|
136 fprintf(fp, "%d formats supported.\n", ndmC64ImageFormats); |
65a2c2e99c81
Move listing of C64 formats function to argShowC64Formats in lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2240
diff
changeset
|
137 } |
65a2c2e99c81
Move listing of C64 formats function to argShowC64Formats in lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2240
diff
changeset
|
138 |
65a2c2e99c81
Move listing of C64 formats function to argShowC64Formats in lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2240
diff
changeset
|
139 |
2244
b26e37e7cbe6
Move function to better place in the file.
Matti Hamalainen <ccr@tnsp.org>
parents:
2242
diff
changeset
|
140 void argShowC64PaletteHelp(FILE *fp) |
b26e37e7cbe6
Move function to better place in the file.
Matti Hamalainen <ccr@tnsp.org>
parents:
2242
diff
changeset
|
141 { |
2245
95f669692b01
Mention support for external palette files in palette help, and also
Matti Hamalainen <ccr@tnsp.org>
parents:
2244
diff
changeset
|
142 fprintf(fp, |
95f669692b01
Mention support for external palette files in palette help, and also
Matti Hamalainen <ccr@tnsp.org>
parents:
2244
diff
changeset
|
143 "\n" |
95f669692b01
Mention support for external palette files in palette help, and also
Matti Hamalainen <ccr@tnsp.org>
parents:
2244
diff
changeset
|
144 "Available C64 palettes (-p <name>):\n" |
95f669692b01
Mention support for external palette files in palette help, and also
Matti Hamalainen <ccr@tnsp.org>
parents:
2244
diff
changeset
|
145 "-----------------------------------\n"); |
95f669692b01
Mention support for external palette files in palette help, and also
Matti Hamalainen <ccr@tnsp.org>
parents:
2244
diff
changeset
|
146 |
2244
b26e37e7cbe6
Move function to better place in the file.
Matti Hamalainen <ccr@tnsp.org>
parents:
2242
diff
changeset
|
147 for (int n = 0; n < ndmC64DefaultPalettes; n++) |
b26e37e7cbe6
Move function to better place in the file.
Matti Hamalainen <ccr@tnsp.org>
parents:
2242
diff
changeset
|
148 { |
b26e37e7cbe6
Move function to better place in the file.
Matti Hamalainen <ccr@tnsp.org>
parents:
2242
diff
changeset
|
149 DMC64Palette *pal = &dmC64DefaultPalettes[n]; |
b26e37e7cbe6
Move function to better place in the file.
Matti Hamalainen <ccr@tnsp.org>
parents:
2242
diff
changeset
|
150 fprintf(fp, |
b26e37e7cbe6
Move function to better place in the file.
Matti Hamalainen <ccr@tnsp.org>
parents:
2242
diff
changeset
|
151 "%-10s | %s\n", |
b26e37e7cbe6
Move function to better place in the file.
Matti Hamalainen <ccr@tnsp.org>
parents:
2242
diff
changeset
|
152 pal->name, pal->desc); |
b26e37e7cbe6
Move function to better place in the file.
Matti Hamalainen <ccr@tnsp.org>
parents:
2242
diff
changeset
|
153 } |
2245
95f669692b01
Mention support for external palette files in palette help, and also
Matti Hamalainen <ccr@tnsp.org>
parents:
2244
diff
changeset
|
154 |
95f669692b01
Mention support for external palette files in palette help, and also
Matti Hamalainen <ccr@tnsp.org>
parents:
2244
diff
changeset
|
155 fprintf(fp, |
95f669692b01
Mention support for external palette files in palette help, and also
Matti Hamalainen <ccr@tnsp.org>
parents:
2244
diff
changeset
|
156 "\n" |
95f669692b01
Mention support for external palette files in palette help, and also
Matti Hamalainen <ccr@tnsp.org>
parents:
2244
diff
changeset
|
157 "Instead one of the internal palettes, you can\n" |
95f669692b01
Mention support for external palette files in palette help, and also
Matti Hamalainen <ccr@tnsp.org>
parents:
2244
diff
changeset
|
158 "also specify an external palette file.\n" |
95f669692b01
Mention support for external palette files in palette help, and also
Matti Hamalainen <ccr@tnsp.org>
parents:
2244
diff
changeset
|
159 "Supported palette file formats are:\n" |
95f669692b01
Mention support for external palette files in palette help, and also
Matti Hamalainen <ccr@tnsp.org>
parents:
2244
diff
changeset
|
160 "-----------------------------------\n" |
95f669692b01
Mention support for external palette files in palette help, and also
Matti Hamalainen <ccr@tnsp.org>
parents:
2244
diff
changeset
|
161 ); |
95f669692b01
Mention support for external palette files in palette help, and also
Matti Hamalainen <ccr@tnsp.org>
parents:
2244
diff
changeset
|
162 |
95f669692b01
Mention support for external palette files in palette help, and also
Matti Hamalainen <ccr@tnsp.org>
parents:
2244
diff
changeset
|
163 for (int n = 0; n < ndmPaletteFormatList; n++) |
95f669692b01
Mention support for external palette files in palette help, and also
Matti Hamalainen <ccr@tnsp.org>
parents:
2244
diff
changeset
|
164 { |
2247 | 165 const DMPaletteFormat *fmt = &dmPaletteFormatList[n]; |
2245
95f669692b01
Mention support for external palette files in palette help, and also
Matti Hamalainen <ccr@tnsp.org>
parents:
2244
diff
changeset
|
166 if (fmt->flags & DM_FMT_RD) |
95f669692b01
Mention support for external palette files in palette help, and also
Matti Hamalainen <ccr@tnsp.org>
parents:
2244
diff
changeset
|
167 { |
95f669692b01
Mention support for external palette files in palette help, and also
Matti Hamalainen <ccr@tnsp.org>
parents:
2244
diff
changeset
|
168 fprintf(fp, |
95f669692b01
Mention support for external palette files in palette help, and also
Matti Hamalainen <ccr@tnsp.org>
parents:
2244
diff
changeset
|
169 "%-6s | %s\n", |
95f669692b01
Mention support for external palette files in palette help, and also
Matti Hamalainen <ccr@tnsp.org>
parents:
2244
diff
changeset
|
170 fmt->fext, fmt->name); |
95f669692b01
Mention support for external palette files in palette help, and also
Matti Hamalainen <ccr@tnsp.org>
parents:
2244
diff
changeset
|
171 } |
95f669692b01
Mention support for external palette files in palette help, and also
Matti Hamalainen <ccr@tnsp.org>
parents:
2244
diff
changeset
|
172 } |
2244
b26e37e7cbe6
Move function to better place in the file.
Matti Hamalainen <ccr@tnsp.org>
parents:
2242
diff
changeset
|
173 fprintf(fp, "\n"); |
b26e37e7cbe6
Move function to better place in the file.
Matti Hamalainen <ccr@tnsp.org>
parents:
2242
diff
changeset
|
174 } |
b26e37e7cbe6
Move function to better place in the file.
Matti Hamalainen <ccr@tnsp.org>
parents:
2242
diff
changeset
|
175 |
b26e37e7cbe6
Move function to better place in the file.
Matti Hamalainen <ccr@tnsp.org>
parents:
2242
diff
changeset
|
176 |
2208
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
177 BOOL argHandleC64PaletteOption(char *optArg, DMC64Palette **ppal, char **palFile) |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
178 { |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
179 if (strcasecmp(optArg, "help") == 0 || |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
180 strcasecmp(optArg, "list") == 0) |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
181 { |
2240
e2c6af0c9431
Add FILE argument to argShowC64PaletteHelp().
Matti Hamalainen <ccr@tnsp.org>
parents:
2238
diff
changeset
|
182 argShowC64PaletteHelp(stdout); |
2208
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
183 return FALSE; |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
184 } |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
185 |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
186 for (int n = 0; n < ndmC64DefaultPalettes; n++) |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
187 { |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
188 DMC64Palette *pal = &dmC64DefaultPalettes[n]; |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
189 if (strcasecmp(pal->name, optArg) == 0) |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
190 { |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
191 *ppal = pal; |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
192 return TRUE; |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
193 } |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
194 } |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
195 |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
196 *palFile = optArg; |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
197 return TRUE; |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
198 } |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
199 |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
200 |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
201 int dmHandleExternalPalette(const char *filename, DMPalette **ppal) |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
202 { |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
203 DMResource *fp = NULL; |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
204 const DMImageFormat *ifmt = NULL; |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
205 const DMPaletteFormat *pfmt = NULL; |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
206 DMImage *inImage = NULL; |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
207 Uint8 *dataBuf = NULL; |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
208 size_t dataSize; |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
209 int index, res; |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
210 |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
211 dmMsg(1, "Probing file '%s' for palette data.\n", filename); |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
212 |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
213 if ((res = dmReadDataFile(NULL, filename, &dataBuf, &dataSize)) != DMERR_OK) |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
214 { |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
215 dmErrorMsg("No such palette '%s', and no such file found (%s).\n", |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
216 filename, dmErrorStr(res)); |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
217 goto done; |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
218 } |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
219 |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
220 if ((res = dmf_open_memio(NULL, filename, dataBuf, dataSize, &fp)) != DMERR_OK) |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
221 { |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
222 dmErrorMsg("Could not create MemIO handle for input.\n"); |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
223 goto done; |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
224 } |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
225 |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
226 if (dmImageProbeGeneric(dataBuf, dataSize, &ifmt, &index) > 0 && |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
227 ifmt->read != NULL) |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
228 { |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
229 dmMsg(1, "Probed image format %s (%s)\n", |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
230 ifmt->name, ifmt->fext); |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
231 |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
232 res = ifmt->read(fp, &inImage); |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
233 if (res != DMERR_OK) |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
234 { |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
235 dmErrorMsg("Could not read image file: %s\n", |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
236 dmErrorStr(res)); |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
237 goto done; |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
238 } |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
239 |
2210
fa5e74384d87
Check for non-existing palette when reading palette from image file.
Matti Hamalainen <ccr@tnsp.org>
parents:
2208
diff
changeset
|
240 if (inImage->pal != NULL) |
fa5e74384d87
Check for non-existing palette when reading palette from image file.
Matti Hamalainen <ccr@tnsp.org>
parents:
2208
diff
changeset
|
241 res = dmPaletteCopy(ppal, inImage->pal); |
fa5e74384d87
Check for non-existing palette when reading palette from image file.
Matti Hamalainen <ccr@tnsp.org>
parents:
2208
diff
changeset
|
242 else |
fa5e74384d87
Check for non-existing palette when reading palette from image file.
Matti Hamalainen <ccr@tnsp.org>
parents:
2208
diff
changeset
|
243 { |
fa5e74384d87
Check for non-existing palette when reading palette from image file.
Matti Hamalainen <ccr@tnsp.org>
parents:
2208
diff
changeset
|
244 dmErrorMsg("Image file does not have a palette.\n"); |
fa5e74384d87
Check for non-existing palette when reading palette from image file.
Matti Hamalainen <ccr@tnsp.org>
parents:
2208
diff
changeset
|
245 res = DMERR_NULLPTR; |
fa5e74384d87
Check for non-existing palette when reading palette from image file.
Matti Hamalainen <ccr@tnsp.org>
parents:
2208
diff
changeset
|
246 } |
2208
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
247 } |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
248 else |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
249 if (dmPaletteProbeGeneric(dataBuf, dataSize, &pfmt, &index) > 0 && |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
250 pfmt->read != NULL) |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
251 { |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
252 dmMsg(1, "Probed palette format %s (%s)\n", |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
253 pfmt->name, pfmt->fext); |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
254 |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
255 res = pfmt->read(fp, ppal); |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
256 } |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
257 else |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
258 { |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
259 res = DMERR_NOT_SUPPORTED; |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
260 dmErrorMsg("Not an internal palette or recognized palette file '%s'.\n", |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
261 filename); |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
262 } |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
263 |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
264 done: |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
265 dmf_close(fp); |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
266 dmImageFree(inImage); |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
267 dmFree(dataBuf); |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
268 |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
269 return res; |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
270 } |