# define GetBitmapHeight(B) ((B)->Height)
#endif
+#if defined(HAVE_INLINE)
+INLINE const Palette* GetBitmapPalette (const Bitmap* B)
+/* Get the palette of a bitmap */
+{
+ return B->Pal;
+}
+#else
+# define GetBitmapPalette(B) ((B)->Pal)
+#endif
+
unsigned GetBitmapColors (const Bitmap* B);
/* Get the number of colors in an image. The function will return the number
* of palette entries for indexed bitmaps and 2^24 for non indexed bitmaps.
+static void OptDumpPalette (const char* Opt attribute ((unused)),
+ const char* Arg attribute ((unused)))
+/* Dump the palette of the current work bitmap */
+{
+ /* We must have a bitmap ... */
+ if (C == 0) {
+ Error ("No bitmap");
+ }
+
+ /* ... which must be indexed */
+ if (!BitmapIsIndexed (C)) {
+ Error ("Current bitmap is not indexed");
+ }
+
+ /* Dump the palette */
+ DumpPalette (stdout, GetBitmapPalette (C));
+}
+
+
+
static void OptHelp (const char* Opt attribute ((unused)),
const char* Arg attribute ((unused)))
/* Print usage information and exit */
/* Program long options */
static const LongOpt OptTab[] = {
{ "--convert-to", 1, OptConvertTo },
+ { "--dump-palette", 0, OptDumpPalette },
{ "--help", 0, OptHelp },
{ "--list-conversions", 0, OptListConversions },
{ "--pop", 0, OptPop },
}
/* Cleanup data */
+ SetWorkBitmap (C);
FreeBitmap (B);
- FreeBitmap (C);
FreeStrBuf (D);
/* Success */
+void DumpPalette (FILE* F, const Palette* P)
+/* Dump the palette in readable form to the given file */
+{
+ unsigned I;
+
+ fputs ("Entry R G B A Combined\n", F);
+ fputs ("----------------------------------------------\n", F);
+ for (I = 0; I < P->Count; ++I) {
+
+ /* Get the color entry */
+ const Color* C = P->Entries + I;
+
+ /* Output it */
+ fprintf (F,
+ " %3u %3u %3u %3u %3u #%08lX\n",
+ I,
+ C->R, C->G, C->B, C->A,
+ (((unsigned long) C->A) << 24) |
+ (((unsigned long) C->B) << 16) |
+ (((unsigned long) C->G) << 8) |
+ (((unsigned long) C->R) << 0));
+ }
+}
+
+
+
+#include <stdio.h>
+
/* sp65 */
#include "color.h"
void FreePalette (Palette* P);
/* Free a dynamically allocated palette */
+void DumpPalette (FILE* F, const Palette* P);
+/* Dump the palette in readable form to the given file */
+
/* End of palette.h */