summaryrefslogtreecommitdiff
path: root/app/tools
diff options
context:
space:
mode:
Diffstat (limited to 'app/tools')
-rw-r--r--app/tools/CMakeLists.txt2
-rw-r--r--app/tools/listxtp.c7
-rwxr-xr-xapp/tools/mkimage124
-rwxr-xr-xapp/tools/mkimage346
-rw-r--r--app/tools/pngtoxpm/pngtoxpm.c128
5 files changed, 111 insertions, 96 deletions
diff --git a/app/tools/CMakeLists.txt b/app/tools/CMakeLists.txt
index 433d464..5d287a5 100644
--- a/app/tools/CMakeLists.txt
+++ b/app/tools/CMakeLists.txt
@@ -7,4 +7,6 @@ if (WIN32)
endif ()
add_subdirectory(halibut)
+if ( WIN32 )
add_subdirectory(pngtoxpm)
+endif()
diff --git a/app/tools/listxtp.c b/app/tools/listxtp.c
index 93fd2e9..4f497d6 100644
--- a/app/tools/listxtp.c
+++ b/app/tools/listxtp.c
@@ -64,6 +64,7 @@ int
main( int argc, char **argv )
{
char buffer[ 512 ];
+ char buffer1[ 512 ];
int found;
DIR *d;
struct dirent *ent;
@@ -151,9 +152,9 @@ main( int argc, char **argv )
char *bp;
buffer[ strlen( buffer ) - 1 ] = '\0';
bp = buffer;
- sprintf( buffer, "%s (%s)", bp + strlen( CONTENTSCOMMAND ) + 1, ent->d_name );
- results[ cnt ] = malloc( strlen( buffer ) + 1 );
- strcpy( results[ cnt ], buffer );
+ sprintf( buffer1, "%s (%s)", bp + strlen( CONTENTSCOMMAND ) + 1, ent->d_name );
+ results[ cnt ] = malloc( strlen( buffer1 ) + 1 );
+ strcpy( results[ cnt ], buffer1 );
cnt++;
if( cnt == MAX_FILES ) {
fprintf( stderr, "Error: too many files\n" );
diff --git a/app/tools/mkimage1 b/app/tools/mkimage1
new file mode 100755
index 0000000..fef13f6
--- /dev/null
+++ b/app/tools/mkimage1
@@ -0,0 +1,24 @@
+#!/bin/bash
+if [ $# -lt 2 ] ; then
+ echo mkimage1 OUTDIR PNG ...
+ echo Converts .pmg files to .image1
+ echo Run from SRCDIR/app/bitmaps
+ echo
+ echo '$ cd $SRCDIR/app/bin/bitmaps'
+ echo '$ ../../tools/mkimage1 $BLDDIR/app/bin/bitamps *.png'
+ exit 1
+fi
+
+OUTDIR=$1
+if [ ! -d ${OUTDIR} ] ; then
+ echo ${OUTDIR} - not a directory
+ exit 1
+fi
+
+shift
+for PNGFILE in "$@" ; do
+ NAME=`basename "$PNGFILE" | sed 's/.png//'`;
+ gdk-pixbuf-csource --stream --name "${NAME}_image1" ${PNGFILE} \
+ | sed -e 's/guint8/char/g' \
+ > ${OUTDIR}/${NAME}.image1
+done
diff --git a/app/tools/mkimage3 b/app/tools/mkimage3
new file mode 100755
index 0000000..e9c9f1d
--- /dev/null
+++ b/app/tools/mkimage3
@@ -0,0 +1,46 @@
+#!/usr/bin/bash
+if [ $# -lt 2 ] ; then
+ echo %0 'OUTDIR PNG ...'
+ echo 'Converts *{16,24,32}.png (pick one) files to .image3'
+ echo 'Run from BLDDIR/app/bin/bitmaps/png'
+ echo
+ echo '$ cd $BLDDIR/app/bin/bitmaps/png'
+ echo '$ $SRCDIR/app/tools/mkimage3 .. *16.png'
+ exit 1
+fi
+
+OUTDIR=$1
+if [ ! -d ${OUTDIR} ] ; then
+ echo ${OUTDIR} - not a directory
+ exit 1
+fi
+
+shift
+for XPMFILE in "$@" ; do
+ INBASE=`echo ${XPMFILE} \
+ | sed -e 's/\.png//' -e 's/16$//' -e 's/24$//' -e 's/32$//'`
+
+ if [ ! -f ${INBASE}16.png ] ; then
+ echo ${INBASE}16.png: not found
+ exit 1
+ fi
+ if [ ! -f ${INBASE}24.png ] ; then
+ echo ${INBASE}24.png: not found
+ exit 1
+ fi
+ if [ ! -f ${INBASE}32.png ] ; then
+ echo ${INBASE}32.png: not found
+ exit 1
+ fi
+
+ NAME=`basename ${INBASE} | sed -e 's/-/_/g'`
+ OUTFILE="${OUTDIR}"/"`basename ${INBASE}`"".image3"
+ > ${OUTFILE}
+(
+ gdk-pixbuf-csource --stream --name ${NAME}16_image3 ${INBASE}16.png; \
+ gdk-pixbuf-csource --stream --name ${NAME}24_image3 ${INBASE}24.png; \
+ gdk-pixbuf-csource --stream --name ${NAME}32_image3 ${INBASE}32.png; \
+ echo "static const char * ${NAME}_image3[3] = { ${NAME}16_image3, ${NAME}24_image3, ${NAME}32_image3 };" ) \
+ | sed -e 's/guint8/char/g' >> ${OUTFILE}
+
+done
diff --git a/app/tools/pngtoxpm/pngtoxpm.c b/app/tools/pngtoxpm/pngtoxpm.c
index cebc829..16bb736 100644
--- a/app/tools/pngtoxpm/pngtoxpm.c
+++ b/app/tools/pngtoxpm/pngtoxpm.c
@@ -38,7 +38,7 @@ FIBITMAP* image;
char palette[76] =
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz~!@#$^&=+-<>/";
-char xpm3Buff[10000];
+char xpmBuff[10000];
/**********************************************************************
C Implementation of Wu's Color Quantizer (v. 2)
@@ -483,7 +483,7 @@ strscat(char* dest, const char* src, size_t count)
return -E2BIG;
}
-int genXpm(int icon, char* name, int width, int height)
+int genXpm(char* name, int width, int height)
{
char xpmName[100]; // XPM object name
char tmpBuff[100]; // sprintf
@@ -500,68 +500,55 @@ int genXpm(int icon, char* name, int width, int height)
}
}
- strscat(xpm3Buff, "static char *", sizeof(xpm3Buff));
- strscat(xpm3Buff, xpmName, sizeof(xpm3Buff));
- strscat(xpm3Buff, "_x", sizeof(xpm3Buff));
- sprintf(tmpBuff, "%d", height); strscat(xpm3Buff, tmpBuff, sizeof(xpm3Buff));
- strscat(xpm3Buff, "[] = {"ENDLN, sizeof(xpm3Buff));
- strscat(xpm3Buff, "\t\"", sizeof(xpm3Buff));
+ strscat(xpmBuff, "static char *", sizeof(xpmBuff));
+ strscat(xpmBuff, xpmName, sizeof(xpmBuff));
+
+ strscat(xpmBuff, "[] = {"ENDLN, sizeof(xpmBuff));
+ strscat(xpmBuff, "\t\"", sizeof(xpmBuff));
sprintf(tmpBuff, "%d %d %d %d", width, height, (K + 1), 1);
- strscat(xpm3Buff, tmpBuff, sizeof(xpm3Buff));
- strscat(xpm3Buff, "\","ENDLN"\t\" \tc\tNone\","ENDLN, sizeof(xpm3Buff));
+ strscat(xpmBuff, tmpBuff, sizeof(xpmBuff));
+ strscat(xpmBuff, "\","ENDLN"\t\" \tc\tNone\","ENDLN, sizeof(xpmBuff));
for (i = 0; i < K; i++) {
- strscat(xpm3Buff, "\t\"", sizeof(xpm3Buff));
+ strscat(xpmBuff, "\t\"", sizeof(xpmBuff));
sprintf(tmpBuff, "%c\tc\t#%02x%02x%02x", pChar(i), lut_r[i], lut_g[i],
- lut_b[i]); strscat(xpm3Buff, tmpBuff, sizeof(xpm3Buff));
- strscat(xpm3Buff, "\","ENDLN, sizeof(xpm3Buff));
+ lut_b[i]); strscat(xpmBuff, tmpBuff, sizeof(xpmBuff));
+ strscat(xpmBuff, "\","ENDLN, sizeof(xpmBuff));
}
// Write the pixels
i = 0;
for (y = height - 1; y >= 0; y--) {
- strscat(xpm3Buff, "\t\"", sizeof(xpm3Buff));
+ strscat(xpmBuff, "\t\"", sizeof(xpmBuff));
for (x = 0; x < width; x++) {
FreeImage_GetPixelColor(image, x, y, &color);
if (color.rgbReserved >= ALPHATHRESH) {
j = Qadd[i];
c[0] = pChar(j);
- strscat(xpm3Buff, c, sizeof(xpm3Buff));
+ strscat(xpmBuff, c, sizeof(xpmBuff));
i++;
} else {
- strscat(xpm3Buff, " ", sizeof(xpm3Buff));
+ strscat(xpmBuff, " ", sizeof(xpmBuff));
}
}
if (y > 0) {
- strscat(xpm3Buff, "\","ENDLN, sizeof(xpm3Buff));
+ strscat(xpmBuff, "\","ENDLN, sizeof(xpmBuff));
} else {
- strscat(xpm3Buff, "\"};"ENDLN, sizeof(xpm3Buff));
+ strscat(xpmBuff, "\"};"ENDLN, sizeof(xpmBuff));
}
}
- if (icon == 32) {
- strscat(xpm3Buff, ENDLN"static char **", sizeof(xpm3Buff));
- strscat(xpm3Buff, xpmName, sizeof(xpm3Buff));
- strscat(xpm3Buff, "_xpm3[3] = { ", sizeof(xpm3Buff));
- strscat(xpm3Buff, xpmName, sizeof(xpm3Buff));
- strscat(xpm3Buff, "_x16, ", sizeof(xpm3Buff));
- strscat(xpm3Buff, xpmName, sizeof(xpm3Buff));
- strscat(xpm3Buff, "_x24, ", sizeof(xpm3Buff));
- strscat(xpm3Buff, xpmName, sizeof(xpm3Buff));
- strscat(xpm3Buff, "_x32 };"ENDLN, sizeof(xpm3Buff));
- }
return 0;
}
-int process(char* path, char* name, int icon)
+int process(char* sPngFileName, char* sName )
{
int i;
int w, h;
int x, y;
short a;
float frac;
- short bg;
- char filename[1000];
+ short bg; //char filename[1000];
RGBQUAD color;
@@ -574,7 +561,7 @@ int process(char* path, char* name, int icon)
/* printf( "FreeImage version %s\n\n",FreeImage_GetVersion( ) ); */
// Try override first
- sprintf(filename, "%spng/%s%d.png", path, name, icon);
+ //sprintf(filename, "%spng/%s%d.png", path, name, icon);
//#if defined(WIN32) || defined(_WIN32)
// if ( _access(filename, 04) != 0) {
//#else
@@ -583,12 +570,12 @@ int process(char* path, char* name, int icon)
// sprintf( filename,"%s/png/%s%d.png",path,name,icon );
// }
#ifdef DEBUGPRINT
- fprintf(stdout, "PNG: %s\n", filename);
+ fprintf(stdout, "PNG: %s\n", sPngFileName);
#endif
- image = FreeImage_Load(FIF_PNG, filename, PNG_DEFAULT);
+ image = FreeImage_Load(FIF_PNG, sPngFileName, PNG_DEFAULT);
if (image == NULL) {
- fprintf(stderr, "%s not found.\n", filename);
+ fprintf(stderr, "%s not found.\n", sPngFileName);
exit(1);
}
@@ -637,7 +624,7 @@ int process(char* path, char* name, int icon)
free(Ig); free(Ib); free(Ir); /* */
- genXpm(icon, name, w, h);
+ genXpm(sName, w, h);
// Delete
FreeImage_Unload(image);
@@ -647,74 +634,29 @@ int process(char* path, char* name, int icon)
int main(int argc, char* argv[])
{
- char buffer[1000];
- char path[1000];
- char name[100];
- char* temp;
- char* ext;
- int i = 0, j = 0;
- int icon;
#ifdef DEBUGPRINT
fprintf(stderr, "Begin pngtoxpm\n");
#endif
- if (argc < 2) {
- printf("PngToXpm ver 0.2\nUsage: pngtoxpm filename\nfilename is the path to the resultant XPM3\n");
+ if (argc < 4) {
+ printf("PngToXpm ver 0.2\nUsage: pngtoxpm name pngfile xpmfile\nConverts the PNG file to a XPM file\n");
return 0;
}
- // Get the file base name from path/name.ext
- strncpy(buffer, argv[1], sizeof(buffer) - 1);
-
- strncpy(path, argv[1], sizeof(path) - 1);
-#ifdef DEBUGPRINT
- fprintf(stderr, "Filename: %s\n", path);
-#endif
-
- temp = strrchr(path, '/');
- if (temp != NULL) {
- temp++;
- *temp = '\0';
- } else {
- path[0] = '\0';
- }
-
-#ifdef DEBUGPRINT
- fprintf(stderr, "Path: %s\n", path);
-#endif
-
- (temp = strrchr(buffer, '/')) ? ++temp : (temp = buffer);
-
- ext = strrchr(temp, '.');
- if (ext != NULL) {
- *ext = '\0';
- }
- strncpy(name, temp, sizeof(name) - 1);
-
-#ifdef DEBUGPRINT
- fprintf(stdout, "In: %s %s\n", path, name);
-#endif
+ char * sName = argv[1];
+ char * sPngFileName = argv[2];
+ char * sXpmFileName = argv[3];
+ process( sPngFileName, sName );
- for (icon = 16; icon <= 32; icon += 8) {
- process(path, name, icon);
- }
-
- // Write the xpm file
- strncpy(buffer, argv[1], sizeof(buffer) - 1);
-#ifdef DEBUGPRINT
- fprintf(stdout, "XPM: %s\n", buffer);
-#endif
-
- FILE* ptr;
- ptr = fopen(buffer, "w");
- if (ptr == NULL) {
- fprintf(stderr, "XPM3 file could not be created.\n");
+ FILE* fXpmFile = fopen( sXpmFileName, "w");
+ if (fXpmFile == NULL) {
+ fprintf(stderr, "Output file %s could not be created.\n", sXpmFileName );
exit(1);
}
- fprintf(ptr, "%s", xpm3Buff);
- fclose(ptr);
+ fprintf( fXpmFile, "%s", xpmBuff);
+ fclose( fXpmFile);
return 0;
}