From 5fe7a890f16e5a8afad43171ed011487926e157a Mon Sep 17 00:00:00 2001 From: Paul Keller Date: Sat, 24 Feb 2007 18:55:51 -0500 Subject: [PATCH] [PATCH] I cleaned the bitmap.c file from the /* old */ commented code. --- libtool | 327 ++++++++++++++++++- src/misc/bitmap.c | 947 ++++++------------------------------------------------ 2 files changed, 413 insertions(+), 861 deletions(-) diff --git a/libtool b/libtool index da483e5..24cae3a 100755 --- a/libtool +++ b/libtool @@ -30,21 +30,21 @@ # the same distribution terms that you use for the rest of that program. # A sed program that does not truncate output. -SED="/usr/bin/sed" +SED="/bin/sed" # Sed that helps us avoid accidentally triggering echo(1) options like -n. -Xsed="/usr/bin/sed -e s/^X//" +Xsed="/bin/sed -e s/^X//" # The HP-UX ksh and POSIX shell print the target directory to stdout # if CDPATH is set. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # The names of the tagged configurations supported by this script. -available_tags=" CXX" +available_tags=" CXX F77" # ### BEGIN LIBTOOL CONFIG -# Libtool was configured on host neuroponic.com: +# Libtool was configured on host Gentoo: # Shell to use when invoking shell scripts. SHELL="/bin/sh" @@ -88,7 +88,7 @@ with_gcc=yes EGREP="grep -E" # The linker used to build libraries. -LD="/usr/i486-slackware-linux/bin/ld" +LD="/usr/i386-pc-linux-gnu/bin/ld" # Whether we need hard or soft links. LN_S="ln -s" @@ -316,10 +316,10 @@ variables_saved_for_relink="PATH LD_RUN_PATH GCC_EXEC_PREFIX COMPILER_PATH LIBR link_all_deplibs=unknown # Compile-time system search path for libraries -sys_lib_search_path_spec=" /usr/lib/gcc-lib/i486-slackware-linux/3.3.4/ /usr/lib/gcc/i486-slackware-linux/3.3.4/ /usr/lib/gcc-lib/i486-slackware-linux/3.3.4/../../../../i486-slackware-linux/lib/i486-slackware-linux/3.3.4/ /usr/lib/gcc-lib/i486-slackware-linux/3.3.4/../../../../i486-slackware-linux/lib/ /usr/lib/gcc-lib/i486-slackware-linux/3.3.4/../../../i486-slackware-linux/3.3.4/ /usr/lib/gcc-lib/i486-slackware-linux/3.3.4/../../../ /lib/i486-slackware-linux/3.3.4/ /lib/ /usr/lib/i486-slackware-linux/3.3.4/ /usr/lib/" +sys_lib_search_path_spec=" /usr/lib/gcc/i386-pc-linux-gnu/4.1.1/ /usr/lib/gcc/i386-pc-linux-gnu/4.1.1/ /usr/lib/gcc/i386-pc-linux-gnu/4.1.1/../../../../i386-pc-linux-gnu/lib/i386-pc-linux-gnu/4.1.1/ /usr/lib/gcc/i386-pc-linux-gnu/4.1.1/../../../../i386-pc-linux-gnu/lib/ /usr/lib/gcc/i386-pc-linux-gnu/4.1.1/../../../i386-pc-linux-gnu/4.1.1/ /usr/lib/gcc/i386-pc-linux-gnu/4.1.1/../../../ /lib/i386-pc-linux-gnu/4.1.1/ /lib/ /usr/lib/i386-pc-linux-gnu/4.1.1/ /usr/lib/" # Run-time system search path for libraries -sys_lib_dlsearch_path_spec="/lib /usr/lib /usr/local/lib /usr/lib /usr/X11R6/lib " +sys_lib_dlsearch_path_spec="/lib /usr/lib # ld.so.conf autogenerated by env-update; make all changes to # contents of /etc/env.d directory /usr/local/lib /usr/lib/opengl/ati/lib /usr/i386-pc-linux-gnu/lib /usr/lib/gcc/i386-pc-linux-gnu/4.1.1 /usr/lib/nspr /usr/lib/nss /usr/lib /usr/lib/openmotif-2.2 /usr/lib/qt4 /usr/kde/3.5/lib /usr/qt/3/lib /usr/games/lib /usr/lib/libstdc++-v3/ " # Fix the shell variable $srcfile for the compiler. fix_srcfile_path="" @@ -6745,7 +6745,7 @@ build_old_libs=`case $build_libtool_libs in yes) $echo no;; *) $echo yes;; esac` # End: # ### BEGIN LIBTOOL TAG CONFIG: CXX -# Libtool was configured on host neuroponic.com: +# Libtool was configured on host Gentoo: # Shell to use when invoking shell scripts. SHELL="/bin/sh" @@ -6789,7 +6789,7 @@ with_gcc=yes EGREP="grep -E" # The linker used to build libraries. -LD="/usr/i486-slackware-linux/bin/ld" +LD="/usr/i386-pc-linux-gnu/bin/ld" # Whether we need hard or soft links. LN_S="ln -s" @@ -6918,11 +6918,11 @@ striplib="strip --strip-unneeded" # Dependencies to place before the objects being linked to create a # shared library. -predep_objects="/usr/lib/gcc-lib/i486-slackware-linux/3.3.4/../../../crti.o /usr/lib/gcc-lib/i486-slackware-linux/3.3.4/crtbeginS.o" +predep_objects="/usr/lib/gcc/i386-pc-linux-gnu/4.1.1/../../../crti.o /usr/lib/gcc/i386-pc-linux-gnu/4.1.1/crtbeginS.o" # Dependencies to place after the objects being linked to create a # shared library. -postdep_objects="/usr/lib/gcc-lib/i486-slackware-linux/3.3.4/crtendS.o /usr/lib/gcc-lib/i486-slackware-linux/3.3.4/../../../crtn.o" +postdep_objects="/usr/lib/gcc/i386-pc-linux-gnu/4.1.1/crtendS.o /usr/lib/gcc/i386-pc-linux-gnu/4.1.1/../../../crtn.o" # Dependencies to place before the objects being linked to create a # shared library. @@ -6934,7 +6934,7 @@ postdeps="-lstdc++ -lm -lgcc_s -lc -lgcc_s" # The library search path used internally by the compiler when linking # a shared library. -compiler_lib_search_path="-L/usr/lib/gcc-lib/i486-slackware-linux/3.3.4 -L/usr/lib/gcc/i486-slackware-linux/3.3.4 -L/usr/lib/gcc-lib/i486-slackware-linux/3.3.4/../../../../i486-slackware-linux/lib -L/usr/lib/gcc-lib/i486-slackware-linux/3.3.4/../../.." +compiler_lib_search_path="-L/usr/lib/gcc/i386-pc-linux-gnu/4.1.1 -L/usr/lib/gcc/i386-pc-linux-gnu/4.1.1 -L/usr/lib/gcc/i386-pc-linux-gnu/4.1.1/../../../../i386-pc-linux-gnu/lib -L/usr/lib/gcc/i386-pc-linux-gnu/4.1.1/../../.." # Method to check whether dependent libraries are shared objects. deplibs_check_method="pass_all" @@ -7014,10 +7014,10 @@ variables_saved_for_relink="PATH LD_LIBRARY_PATH LD_RUN_PATH GCC_EXEC_PREFIX COM link_all_deplibs=unknown # Compile-time system search path for libraries -sys_lib_search_path_spec=" /usr/lib/gcc-lib/i486-slackware-linux/3.3.4/ /usr/lib/gcc/i486-slackware-linux/3.3.4/ /usr/lib/gcc-lib/i486-slackware-linux/3.3.4/../../../../i486-slackware-linux/lib/i486-slackware-linux/3.3.4/ /usr/lib/gcc-lib/i486-slackware-linux/3.3.4/../../../../i486-slackware-linux/lib/ /usr/lib/gcc-lib/i486-slackware-linux/3.3.4/../../../i486-slackware-linux/3.3.4/ /usr/lib/gcc-lib/i486-slackware-linux/3.3.4/../../../ /lib/i486-slackware-linux/3.3.4/ /lib/ /usr/lib/i486-slackware-linux/3.3.4/ /usr/lib/" +sys_lib_search_path_spec=" /usr/lib/gcc/i386-pc-linux-gnu/4.1.1/ /usr/lib/gcc/i386-pc-linux-gnu/4.1.1/ /usr/lib/gcc/i386-pc-linux-gnu/4.1.1/../../../../i386-pc-linux-gnu/lib/i386-pc-linux-gnu/4.1.1/ /usr/lib/gcc/i386-pc-linux-gnu/4.1.1/../../../../i386-pc-linux-gnu/lib/ /usr/lib/gcc/i386-pc-linux-gnu/4.1.1/../../../i386-pc-linux-gnu/4.1.1/ /usr/lib/gcc/i386-pc-linux-gnu/4.1.1/../../../ /lib/i386-pc-linux-gnu/4.1.1/ /lib/ /usr/lib/i386-pc-linux-gnu/4.1.1/ /usr/lib/" # Run-time system search path for libraries -sys_lib_dlsearch_path_spec="/lib /usr/lib /usr/local/lib /usr/lib /usr/X11R6/lib " +sys_lib_dlsearch_path_spec="/lib /usr/lib # ld.so.conf autogenerated by env-update; make all changes to # contents of /etc/env.d directory /usr/local/lib /usr/lib/opengl/ati/lib /usr/i386-pc-linux-gnu/lib /usr/lib/gcc/i386-pc-linux-gnu/4.1.1 /usr/lib/nspr /usr/lib/nss /usr/lib /usr/lib/openmotif-2.2 /usr/lib/qt4 /usr/kde/3.5/lib /usr/qt/3/lib /usr/games/lib /usr/lib/libstdc++-v3/ " # Fix the shell variable $srcfile for the compiler. fix_srcfile_path="" @@ -7039,3 +7039,302 @@ include_expsyms="" # ### END LIBTOOL TAG CONFIG: CXX +# ### BEGIN LIBTOOL TAG CONFIG: F77 + +# Libtool was configured on host Gentoo: + +# Shell to use when invoking shell scripts. +SHELL="/bin/sh" + +# Whether or not to build shared libraries. +build_libtool_libs=yes + +# Whether or not to build static libraries. +build_old_libs=yes + +# Whether or not to add -lc for building shared libraries. +build_libtool_need_lc=no + +# Whether or not to disallow shared libs when runtime libs are static +allow_libtool_libs_with_static_runtimes=no + +# Whether or not to optimize for fast installation. +fast_install=yes + +# The host system. +host_alias= +host=i686-pc-linux-gnu + +# An echo program that does not interpret backslashes. +echo="echo" + +# The archiver. +AR="ar" +AR_FLAGS="cru" + +# A C compiler. +LTCC="gcc" + +# A language-specific compiler. +CC="gfortran" + +# Is the compiler the GNU C compiler? +with_gcc=yes + +# An ERE matcher. +EGREP="grep -E" + +# The linker used to build libraries. +LD="/usr/i386-pc-linux-gnu/bin/ld" + +# Whether we need hard or soft links. +LN_S="ln -s" + +# A BSD-compatible nm program. +NM="/usr/bin/nm -B" + +# A symbol stripping program +STRIP="strip" + +# Used to examine libraries when file_magic_cmd begins "file" +MAGIC_CMD=file + +# Used on cygwin: DLL creation program. +DLLTOOL="dlltool" + +# Used on cygwin: object dumper. +OBJDUMP="objdump" + +# Used on cygwin: assembler. +AS="as" + +# The name of the directory that contains temporary libtool files. +objdir=.libs + +# How to create reloadable object files. +reload_flag=" -r" +reload_cmds="\$LD\$reload_flag -o \$output\$reload_objs" + +# How to pass a linker flag through the compiler. +wl="-Wl," + +# Object file suffix (normally "o"). +objext="o" + +# Old archive suffix (normally "a"). +libext="a" + +# Shared library suffix (normally ".so"). +shrext_cmds='.so' + +# Executable file suffix (normally ""). +exeext="" + +# Additional compiler flags for building library objects. +pic_flag=" -fPIC" +pic_mode=default + +# What is the maximum length of a command? +max_cmd_len=32768 + +# Does compiler simultaneously support -c and -o options? +compiler_c_o="yes" + +# Must we lock files when doing compilation ? +need_locks="no" + +# Do we need the lib prefix for modules? +need_lib_prefix=no + +# Do we need a version for libraries? +need_version=no + +# Whether dlopen is supported. +dlopen_support=unknown + +# Whether dlopen of programs is supported. +dlopen_self=unknown + +# Whether dlopen of statically linked programs is supported. +dlopen_self_static=unknown + +# Compiler flag to prevent dynamic linking. +link_static_flag="-static" + +# Compiler flag to turn off builtin functions. +no_builtin_flag="" + +# Compiler flag to allow reflexive dlopens. +export_dynamic_flag_spec="\${wl}--export-dynamic" + +# Compiler flag to generate shared objects directly from archives. +whole_archive_flag_spec="\${wl}--whole-archive\$convenience \${wl}--no-whole-archive" + +# Compiler flag to generate thread-safe objects. +thread_safe_flag_spec="" + +# Library versioning type. +version_type=linux + +# Format of library name prefix. +libname_spec="lib\$name" + +# List of archive names. First name is the real one, the rest are links. +# The last name is the one that the linker finds with -lNAME. +library_names_spec="\${libname}\${release}\${shared_ext}\$versuffix \${libname}\${release}\${shared_ext}\$major \$libname\${shared_ext}" + +# The coded name of the library, if different from the real name. +soname_spec="\${libname}\${release}\${shared_ext}\$major" + +# Commands used to build and install an old-style archive. +RANLIB="ranlib" +old_archive_cmds="\$AR \$AR_FLAGS \$oldlib\$oldobjs\$old_deplibs~\$RANLIB \$oldlib" +old_postinstall_cmds="\$RANLIB \$oldlib~chmod 644 \$oldlib" +old_postuninstall_cmds="" + +# Create an old-style archive from a shared archive. +old_archive_from_new_cmds="" + +# Create a temporary old-style archive to link instead of a shared archive. +old_archive_from_expsyms_cmds="" + +# Commands used to build and install a shared archive. +archive_cmds="\$CC -shared \$libobjs \$deplibs \$compiler_flags \${wl}-soname \$wl\$soname -o \$lib" +archive_expsym_cmds="\$echo \\\"{ global:\\\" > \$output_objdir/\$libname.ver~ +cat \$export_symbols | sed -e \\\"s/\\\\(.*\\\\)/\\\\1;/\\\" >> \$output_objdir/\$libname.ver~ +\$echo \\\"local: *; };\\\" >> \$output_objdir/\$libname.ver~ + \$CC -shared \$libobjs \$deplibs \$compiler_flags \${wl}-soname \$wl\$soname \${wl}-version-script \${wl}\$output_objdir/\$libname.ver -o \$lib" +postinstall_cmds="" +postuninstall_cmds="" + +# Commands used to build a loadable module (assumed same as above if empty) +module_cmds="" +module_expsym_cmds="" + +# Commands to strip libraries. +old_striplib="strip --strip-debug" +striplib="strip --strip-unneeded" + +# Dependencies to place before the objects being linked to create a +# shared library. +predep_objects="" + +# Dependencies to place after the objects being linked to create a +# shared library. +postdep_objects="" + +# Dependencies to place before the objects being linked to create a +# shared library. +predeps="" + +# Dependencies to place after the objects being linked to create a +# shared library. +postdeps="" + +# The library search path used internally by the compiler when linking +# a shared library. +compiler_lib_search_path="" + +# Method to check whether dependent libraries are shared objects. +deplibs_check_method="pass_all" + +# Command to use when deplibs_check_method == file_magic. +file_magic_cmd="\$MAGIC_CMD" + +# Flag that allows shared libraries with undefined symbols to be built. +allow_undefined_flag="" + +# Flag that forces no undefined symbols. +no_undefined_flag="" + +# Commands used to finish a libtool library installation in a directory. +finish_cmds="PATH=\\\"\\\$PATH:/sbin\\\" ldconfig -n \$libdir" + +# Same as above, but a single script fragment to be evaled but not shown. +finish_eval="" + +# Take the output of nm and produce a listing of raw symbols and C names. +global_symbol_pipe="sed -n -e 's/^.*[ ]\\([ABCDGIRSTW][ABCDGIRSTW]*\\)[ ][ ]*\\(\\)\\([_A-Za-z][_A-Za-z0-9]*\\)\$/\\1 \\2\\3 \\3/p'" + +# Transform the output of nm in a proper C declaration +global_symbol_to_cdecl="sed -n -e 's/^. .* \\(.*\\)\$/extern int \\1;/p'" + +# Transform the output of nm in a C name address pair +global_symbol_to_c_name_address="sed -n -e 's/^: \\([^ ]*\\) \$/ {\\\"\\1\\\", (lt_ptr) 0},/p' -e 's/^[BCDEGRST] \\([^ ]*\\) \\([^ ]*\\)\$/ {\"\\2\", (lt_ptr) \\&\\2},/p'" + +# This is the shared library runtime path variable. +runpath_var=LD_RUN_PATH + +# This is the shared library path variable. +shlibpath_var=LD_LIBRARY_PATH + +# Is shlibpath searched before the hard-coded library search path? +shlibpath_overrides_runpath=no + +# How to hardcode a shared library path into an executable. +hardcode_action=immediate + +# Whether we should hardcode library paths into libraries. +hardcode_into_libs=yes + +# Flag to hardcode $libdir into a binary during linking. +# This must work even if $libdir does not exist. +hardcode_libdir_flag_spec="\${wl}--rpath \${wl}\$libdir" + +# If ld is used when linking, flag to hardcode $libdir into +# a binary during linking. This must work even if $libdir does +# not exist. +hardcode_libdir_flag_spec_ld="" + +# Whether we need a single -rpath flag with a separated argument. +hardcode_libdir_separator="" + +# Set to yes if using DIR/libNAME during linking hardcodes DIR into the +# resulting binary. +hardcode_direct=no + +# Set to yes if using the -LDIR flag during linking hardcodes DIR into the +# resulting binary. +hardcode_minus_L=no + +# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into +# the resulting binary. +hardcode_shlibpath_var=unsupported + +# Set to yes if building a shared library automatically hardcodes DIR into the library +# and all subsequent libraries and executables linked against it. +hardcode_automatic=no + +# Variables whose values should be saved in libtool wrapper scripts and +# restored at relink time. +variables_saved_for_relink="PATH LD_LIBRARY_PATH LD_RUN_PATH GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" + +# Whether libtool must link a program against all its dependency libraries. +link_all_deplibs=unknown + +# Compile-time system search path for libraries +sys_lib_search_path_spec=" /usr/lib/gcc/i386-pc-linux-gnu/4.1.1/ /usr/lib/gcc/i386-pc-linux-gnu/4.1.1/ /usr/lib/gcc/i386-pc-linux-gnu/4.1.1/../../../../i386-pc-linux-gnu/lib/i386-pc-linux-gnu/4.1.1/ /usr/lib/gcc/i386-pc-linux-gnu/4.1.1/../../../../i386-pc-linux-gnu/lib/ /usr/lib/gcc/i386-pc-linux-gnu/4.1.1/../../../i386-pc-linux-gnu/4.1.1/ /usr/lib/gcc/i386-pc-linux-gnu/4.1.1/../../../ /lib/i386-pc-linux-gnu/4.1.1/ /lib/ /usr/lib/i386-pc-linux-gnu/4.1.1/ /usr/lib/" + +# Run-time system search path for libraries +sys_lib_dlsearch_path_spec="/lib /usr/lib # ld.so.conf autogenerated by env-update; make all changes to # contents of /etc/env.d directory /usr/local/lib /usr/lib/opengl/ati/lib /usr/i386-pc-linux-gnu/lib /usr/lib/gcc/i386-pc-linux-gnu/4.1.1 /usr/lib/nspr /usr/lib/nss /usr/lib /usr/lib/openmotif-2.2 /usr/lib/qt4 /usr/kde/3.5/lib /usr/qt/3/lib /usr/games/lib /usr/lib/libstdc++-v3/ " + +# Fix the shell variable $srcfile for the compiler. +fix_srcfile_path="" + +# Set to yes if exported symbols are required. +always_export_symbols=no + +# The commands to list exported symbols. +export_symbols_cmds="\$NM \$libobjs \$convenience | \$global_symbol_pipe | \$SED 's/.* //' | sort | uniq > \$export_symbols" + +# The commands to extract the exported symbol list from a shared archive. +extract_expsyms_cmds="" + +# Symbols that should not be listed in the preloaded symbols. +exclude_expsyms="_GLOBAL_OFFSET_TABLE_" + +# Symbols that must always be exported. +include_expsyms="" + +# ### END LIBTOOL TAG CONFIG: F77 + diff --git a/src/misc/bitmap.c b/src/misc/bitmap.c index 448b055..a35e614 100644 --- a/src/misc/bitmap.c +++ b/src/misc/bitmap.c @@ -28,13 +28,6 @@ #define old 0 -#if old - -/* this is the only way I found so theres no warning with this function */ -extern FILE *fmemopen(void *_s, size_t size, __const char *modes); - -#endif /* old */ - #if USE_ZLIB /* this is used to open the bitmaps, * the beauty of this is it works @@ -105,7 +98,6 @@ static int fpdata32(nFILE *input, u32 *output) __attribute__((unused)); /* static functions */ - static void clean_bmap_color(void *eng) { @@ -297,106 +289,10 @@ process_palette(nFILE *input, BITMAP_HDATA *bmap, EBUF *bcolors) /* skip the alpha color */ fgetc(input); #endif /* NOT USE_ZLIB */ - -#if old - if (i == 0) - { - buf->symbol = calloc(2, sizeof(unsigned char)); - - buf->symbol[0] = ' '; - buf->symbol[1] = '\0'; - } - else - { - /* generate a character based on the current color count */ - Uchar(i, &buf->symbol); - } -#endif /* old */ - i++; } } -#if old -static void -process_RGB(EBUF *bcolors, EBUF *bpixels, u8 ir, u8 ig, u8 ib) -{ - u8 found = 0; - u32 ctotal = 0; /* colors and pixels frontend variables */ - BITMAP_COLOR *cbuf = NULL; - BITMAP_MAP *pbuf = NULL; - u8 r, g, b; - - r = ir; - g = ig; - b = ib; - - /* printf("rgb %d%d%d\n", r, g, b); */ - /* printf("bcolors status : %d\n", Neuro_EBufIsEmpty(bcolors)); */ - - if (!Neuro_EBufIsEmpty(bcolors)) - { - ctotal = Neuro_GiveEBufCount(bcolors); - /* printf("%d\n", ctotal); */ - ctotal++; - - while (ctotal-- > 0) - { - cbuf = Neuro_GiveEBuf(bcolors, ctotal); - if (cbuf->r == r && cbuf->g == g && cbuf->b == b) - { - found = 1; - break; - } - } - } - else - { - /* add the color to the buffer */ - /* printf("bcolors is empty, will feed it\n"); */ - found = 0; - } - - /* if we didn't find a corresponding color in the buffer - * we add the new one to the buffer or else, we will have - * to make the pixel point to the corresponding color. - */ - if (!found) - { - /* Debug_Val(0, "had to allocate for a color\n"); */ - Neuro_AllocEBuf(bcolors, sizeof(BITMAP_COLOR*), sizeof(BITMAP_COLOR)); - cbuf = Neuro_GiveCurEBuf(bcolors); - - cbuf->r = r; - cbuf->g = g; - cbuf->b = b; - - - if (Neuro_GiveEBufCount(bcolors) == 0) - { - cbuf->symbol = calloc(2, sizeof(unsigned char)); - - cbuf->symbol[0] = ' '; - cbuf->symbol[1] = '\0'; - } - else - { - /* generate a character based on ctotal */ - Uchar(Neuro_GiveEBufCount(bcolors), &cbuf->symbol); - } - } - - Neuro_AllocEBuf(bpixels, sizeof(BITMAP_MAP*), sizeof(BITMAP_MAP)); - - pbuf = Neuro_GiveCurEBuf(bpixels); - - pbuf->color = cbuf; - - found = 0; - -} -#endif /* old */ - /* input the bits per pixel of the image * input a 1 byte of data to process */ @@ -690,568 +586,121 @@ process_bitmap2(BITMAP_HDATA *bmap, v_object *image, u8 *palette, u8 *data, EBUF } } - -#if old -/* input the bits per pixel of the image - * input a 1 byte of data to process - */ -static void -process_bitmap(BITMAP_HDATA *bmap, u8 *palette, u8 *data, EBUF *bcolors, EBUF *bpixels, int *aux, char **buf) +static v_object * +processFD_BMP(nFILE *f_bitmap) { + /* major (buffers) */ + EBUF *bmap_colors = NULL; /* the colors */ + u8 *buf = NULL; /* the buffer that will contain the content of the file */ - /* we will call functions depending on the bpp of the image */ - switch (bmap->infoheader.bits) + /* minor (mostly pointers and temporary variables) */ + register i32 i = 0; /* incremental variable */ + u32 skip_i = 0, x = 0, y = 0; + + u32 psize = 0; /* the full size of the pixels data */ + u8 *palette = NULL; /* the pointer to the palette if theres one */ + BITMAP_HDATA *bmap; /* this is how we will get informations about the bitmap */ + int aux_var = 0; /* auxiliary variable that can be used by external functions */ + char *aux_buf = NULL; /* same as aux_var but a buffer */ + double msize = 0; + double calc = 0; + double tmp = 0; + u32 wmult = 0; + double pixellen = 0; + u32 increm = 0; + u8 DATA; + v_object *output; /* the image into which we will load the bitmap */ + + if (f_bitmap == NULL) + return NULL; + + bmap = parse_bitmap_header(f_bitmap); + + /* TODO TODO XXX check here if the bitmap is valid or not + * first check for the BM word + * then we check for the size of the file in header and size + * we got when reading the file + */ { - case 1: - { - /* will do a loop to get each 8 pixels from the data */ - - /* this is pretty much for little endian - * the minimum data size we can have for a certain width is - * 32 bits (4 bytes increments). Those 32 bits will be able - * to hold up to 32 pixels. In case the width is higher than - * 32 pixels, it will put 32 bits until the whole width - * can be fulfilled. - */ - /* we will need to have the width value because we will need - * to know how many bits we have to read from 32 bits (4 bytes). - */ - /* aux will keep how many 32 bits still need to be done in a - * certain width - */ - u8 temp; - /* double calc = 0; */ - - /* u8 r, g, b; */ - - const u8 values[8] = { - 0x80, - 0x40, - 0x20, - 0x10, - 0x08, - 0x04, - 0x02, - 0x01 - }; - u32 i = 0; - u32 max = 0; - - if (*buf == NULL) - { - *buf = calloc(1, sizeof(char)); - **buf = 0; - *aux = 0; - } + + } - /* set up aux for remaining pixels */ - if (*aux == 0) - *aux = bmap->infoheader.width; + /* if it is valid, we create the buffers */ + Neuro_CreateEBuf(&bmap_colors); + Neuro_SetcallbEBuf(bmap_colors, &clean_bmap_color); + + + /* print_bitmap_infos(bmap); */ + + /* process the bitmap(load it in memory) */ + i = 0; + psize = bmap->header.size - (sizeof(BITMAP_HEADER) + sizeof(BITMAP_INFOHEADER)); + psize = psize - (bmap->infoheader.ncolors * 4); + /* printf("data size %d\n", psize); */ - /* set up the number of pixels we need to process in this cycle */ - if (*aux > 8) - { - max = 8; - *aux = *aux - 8; - } - else - { - max = *aux; - *aux = 0; - } - - temp = *data; + if (bmap->infoheader.ncolors) + { + process_palette(f_bitmap, bmap, bmap_colors); + } - while (i < max) - { - BITMAP_COLOR *cbuf = NULL; - BITMAP_MAP *pbuf = NULL; + /* we create the v_object + * + * will need to put better values for the masks to support SDL. + */ + { + u32 rmask = 0, gmask = 0, bmask = 0, amask = 0; - if (IsLittleEndian()) - temp = *data & values[i]; - else - temp = *data & values[7 - i]; - + if (IsLittleEndian()) + { + switch (Lib_GetDefaultDepth()) + { + case 16: + { + rmask = 0x0000f800; + gmask = 0x000007e0; + bmask = 0x0000001f; + amask = 0x00000000; + } + break; - if (temp) - temp = 1; - - - Neuro_AllocEBuf(bpixels, sizeof(BITMAP_MAP*), sizeof(BITMAP_MAP)); + case 24: + { + rmask = 0x00ff0000; + gmask = 0x0000ff00; + bmask = 0x000000ff; + amask = 0x00000000; + } + break; - cbuf = Neuro_GiveEBuf(bcolors, temp); - pbuf = Neuro_GiveCurEBuf(bpixels); - - pbuf->color = cbuf; - i++; + default: + break; } } - break; - - case 4: + else { - /* will do a loop to get each 2 pixels from the data */ - u8 temp; - /* double calc = 0; */ - - /* u8 r, g, b; */ - - const u8 values[2] = { - 0xF0, - 0x0F, - }; - u32 i = 0; - u32 max = 0; - - if (*buf == NULL) + switch (Lib_GetDefaultDepth()) { - *buf = calloc(1, sizeof(char)); - **buf = 0; - *aux = 0; - } - - /* set up aux for remaining pixels */ - if (*aux == 0) - *aux = bmap->infoheader.width; + case 16: + { + rmask = 0x0000001f; + gmask = 0x000007e0; + bmask = 0x0000f800; + amask = 0x00000000; + } + break; + + case 24: + { + rmask = 0x0000ff00; + gmask = 0x00ff0000; + bmask = 0xff000000; + amask = 0x00000000; + } + break; - /* set up the number of pixels we need to process in this cycle */ - if (*aux > 2) - { - max = 2; - *aux = *aux - 2; - } - else - { - max = *aux; - *aux = 0; - } - - temp = *data; - - while (i < max) - { - BITMAP_COLOR *cbuf = NULL; - BITMAP_MAP *pbuf = NULL; - - - if (IsLittleEndian()) - { - temp = *data & values[i]; - - if (temp > values[1]) - temp >>= 4; - } - else - { - temp = *data & values[1 - i]; - - if (temp > values[0]) - temp <<= 4; - } - - Neuro_AllocEBuf(bpixels, sizeof(BITMAP_MAP*), sizeof(BITMAP_MAP)); - - cbuf = Neuro_GiveEBuf(bcolors, temp); - pbuf = Neuro_GiveCurEBuf(bpixels); - - pbuf->color = cbuf; - - i++; - } - - } - break; - - case 8: - { - /* will get the single pixel from the data */ - u8 temp; - /* double calc = 0; */ - - /* u8 r, g, b; */ - - u32 i = 0; - u32 max = 0; - - if (*buf == NULL) - { - *buf = calloc(1, sizeof(char)); - **buf = 0; - *aux = 0; - } - - /* set up aux for remaining pixels */ - if (*aux == 0) - *aux = bmap->infoheader.width; - - /* set up the number of pixels we need to process in this cycle */ - if (*aux > 1) - { - max = 1; - *aux = *aux - 1; - } - else - { - max = *aux; - *aux = 0; - } - - temp = *data; - - while (i < max) - { - BITMAP_COLOR *cbuf = NULL; - BITMAP_MAP *pbuf = NULL; - temp = *data; - - Neuro_AllocEBuf(bpixels, sizeof(BITMAP_MAP*), sizeof(BITMAP_MAP)); - - cbuf = Neuro_GiveEBuf(bcolors, temp); - pbuf = Neuro_GiveCurEBuf(bpixels); - - pbuf->color = cbuf; - - - i++; - } - - } - break; - - case 16: - { - /* we do not support 16 bit because I think they - * use 24 bit for those. we'll see through use. - * if not, I really think this depth is pointless... - */ - } - break; - - case 24: - { - /* will need to gather the data for 2 other bytes to get a - * single pixel. We will use the auxiliary variable to keep - * track of were we are at in the gathering. - */ - - if (!*buf) - { - *buf = calloc(3, sizeof(u8)); - *aux = 0; - } - - (*buf)[*aux] = *data; - *aux = *aux + 1; - if (*aux >= 3) - { - *aux = 0; - process_RGB(bcolors, bpixels, (*buf)[2], (*buf)[1], (*buf)[0]); - } - } - break; - - case 32: - { - /* we do not support 32 bit because it is Very uncommon if it - * actually exist. Pretty much the same as 16 bpp. - */ - } - break; - - default: - { - /* an error occured */ - } - break; - - } -} -#endif /* old */ - -#if old -static void -outputDataToPixmap(BITMAP_HDATA *bmap, EBUF *bcolors, EBUF *bpixels, EBUF **output_pixmap) -{ - BITMAP_COLOR *cbuf = NULL; /* colors frontend pointer */ - BITMAP_MAP *pbuf = NULL; /* pixels map frontend pointer */ - - register u32 i = 0; - - u32 symbol_count = 0; /* number of symbols maximum */ - double temp = 0; /* temporary variable */ - u32 ctotal = 0; /* colors frontend count */ - u32 ptotal = 0; /* pixels frontend count */ - char *control2, *control3; /* control strings for printfish(printf ish) functions */ - int width = 0, width2 = 0; /* used in the loops */ - u8 done = 0; /* used in the loops */ - char *buf = NULL, *bufe = NULL; - EBUF *bufa = NULL; - - /* gather the number of colors and the address of the first - * color element. - */ - ctotal = Neuro_GiveEBufCount(bcolors); - cbuf = Neuro_GiveEBuf(bcolors, ctotal); - - /* - * formula to get the maximum number of characters each symbols will have. - * Those symbols are each attached to a color. - * Note : Theres 81 symbols. - */ - temp = (log10(ctotal) / log10(81)); - /* temp is a double, this will drop the extra numbers after the dot. */ - symbol_count = (u32)temp; - - /* */ - if (temp > symbol_count || (ctotal == 1 || !Neuro_EBufIsEmpty(bcolors))) - { - symbol_count++; - } - else - return; - - Neuro_CreateEBuf(output_pixmap); - bufa = *output_pixmap; - - - - Neuro_AllocEBuf(bufa, sizeof(char*), 512); /* static 512 is temporary */ - - buf = Neuro_GiveCurEBuf(bufa); - - /* prepare the control string for the header of the pixmap format */ - sprintf(buf, "%d %d %d %d", - bmap->infoheader.width, - bmap->infoheader.height, - ctotal + 1, - symbol_count); - - - control2 = calloc(40 + 25, sizeof(char)); - control3 = calloc(40 + 25, sizeof(char)); /* this is too much mem I think */ - - - sprintf(control2, "%%-%ds c #%%02x%%02x%%02x", symbol_count); - sprintf(control3, "%%-%ds c %%s", symbol_count); - - - i = ctotal + 1; - - while (i-- > 0) - { - int Rr, Gg, Bb; - - - if (IsLittleEndian()) - { - Rr = (color_key & 0xff000000) >> 24; - Gg = (color_key & 0x00ff0000) >> 16; - Bb = (color_key & 0x0000ff00) >> 8; - } - else - { - Rr = (color_key & 0x0000ff00) << 24; - Gg = (color_key & 0x00ff0000) << 16; - Bb = (color_key & 0xff000000) << 8; - } - - - cbuf = Neuro_GiveEBuf(bcolors, i); - - Neuro_AllocEBuf(bufa, sizeof(char*), 512); - - buf = Neuro_GiveCurEBuf(bufa); - - if (cbuf->r == Rr && cbuf->g == Gg && cbuf->b == Bb) - { - sprintf(buf, control3, cbuf->symbol, "None"); - } - else - { - sprintf(buf, control2, cbuf->symbol, cbuf->r, cbuf->g, cbuf->b); - } - } - - ptotal = Neuro_GiveEBufCount(bpixels); - i = ptotal; - - /* will buffer each rows */ - bufe = calloc((symbol_count * bmap->infoheader.width) + 1, sizeof(char)); - - if (bufe == NULL) - { - Error_Print("Out of memory"); - return; - } - - while (!done) - { - if (i == 0) - { - /* a bit overkill ;P */ - done = 1; - break; - } - else - { - width = 0; - width2 = bmap->infoheader.width; - - while (width < bmap->infoheader.width) - { - u32 t; - /* we need to inverse i */ - pbuf = Neuro_GiveEBuf(bpixels, abs((i + 1) - width2)); - width2 -= 2; - - - t = 0; - while (t < symbol_count) - { - if (t + 1 >= symbol_count && pbuf->color->symbol[t] == '\0') - bufe[(width * symbol_count) + t] = ' '; - else - bufe[(width * symbol_count) + t] = pbuf->color->symbol[t]; - - t++; - } - - width++; - if (i > 0) - i--; - } - bufe[width * symbol_count] = '\0'; - - Neuro_AllocEBuf(bufa, sizeof(char*), symbol_count * bmap->infoheader.width + 1); - buf = Neuro_GiveCurEBuf(bufa); - - /* strncpy(buf, bufe, symbol_count * bmap->infoheader.width); */ - sprintf(buf, "%s", bufe); - } - } - - free(control3); - free(control2); - free(bufe); -} -#endif /* old */ - -static v_object * -processFD_BMP(nFILE *f_bitmap) -{ - /* major (buffers) */ - EBUF *bmap_colors = NULL; /* the colors */ - u8 *buf = NULL; /* the buffer that will contain the content of the file */ - - /* minor (mostly pointers and temporary variables) */ - register i32 i = 0; /* incremental variable */ - u32 skip_i = 0, x = 0, y = 0; - - u32 psize = 0; /* the full size of the pixels data */ - u8 *palette = NULL; /* the pointer to the palette if theres one */ - BITMAP_HDATA *bmap; /* this is how we will get informations about the bitmap */ - int aux_var = 0; /* auxiliary variable that can be used by external functions */ - char *aux_buf = NULL; /* same as aux_var but a buffer */ - double msize = 0; - double calc = 0; - double tmp = 0; - u32 wmult = 0; - double pixellen = 0; - u32 increm = 0; - u8 DATA; - v_object *output; /* the image into which we will load the bitmap */ - - if (f_bitmap == NULL) - return NULL; - - bmap = parse_bitmap_header(f_bitmap); - - /* TODO TODO XXX check here if the bitmap is valid or not - * first check for the BM word - * then we check for the size of the file in header and size - * we got when reading the file - */ - { - - } - - /* if it is valid, we create the buffers */ - Neuro_CreateEBuf(&bmap_colors); - Neuro_SetcallbEBuf(bmap_colors, &clean_bmap_color); - - - /* print_bitmap_infos(bmap); */ - - /* process the bitmap(load it in memory) */ - i = 0; - psize = bmap->header.size - (sizeof(BITMAP_HEADER) + sizeof(BITMAP_INFOHEADER)); - psize = psize - (bmap->infoheader.ncolors * 4); - /* printf("data size %d\n", psize); */ - - if (bmap->infoheader.ncolors) - { - process_palette(f_bitmap, bmap, bmap_colors); - } - - /* we create the v_object - * - * will need to put better values for the masks to support SDL. - */ - { - u32 rmask = 0, gmask = 0, bmask = 0, amask = 0; - - if (IsLittleEndian()) - { - switch (Lib_GetDefaultDepth()) - { - case 16: - { - rmask = 0x0000f800; - gmask = 0x000007e0; - bmask = 0x0000001f; - amask = 0x00000000; - } - break; - - case 24: - { - rmask = 0x00ff0000; - gmask = 0x0000ff00; - bmask = 0x000000ff; - amask = 0x00000000; - } - break; - - - default: - break; - } - } - else - { - switch (Lib_GetDefaultDepth()) - { - case 16: - { - rmask = 0x0000001f; - gmask = 0x000007e0; - bmask = 0x0000f800; - amask = 0x00000000; - } - break; - - case 24: - { - rmask = 0x0000ff00; - gmask = 0x00ff0000; - bmask = 0xff000000; - amask = 0x00000000; - } - break; - - default: - break; + default: + break; } } /* @@ -1419,182 +868,6 @@ processFD_BMP(nFILE *f_bitmap) return output; } -#if old -static void -processFD_BMP2XPM(nFILE *f_bitmap, EBUF **output_pixmap) -{ - /* major (buffers) */ - EBUF *bmap_colors = NULL; /* the colors */ - EBUF *bmap_map = NULL; /* the map of pixels */ - u8 *buf = NULL; /* the buffer that will contain the content of the file */ - - /* minor (mostly pointers and temporary variables) */ - register i32 i = 0, t = 0; /* incremental variable */ - - u32 psize = 0; /* the full size of the pixels data */ - u8 *palette = NULL; /* the pointer to the palette if theres one */ - BITMAP_HDATA *bmap; /* this is how we will get informations about the bitmap */ - int aux_var = 0; /* auxiliary variable that can be used by external functions */ - char *aux_buf = NULL; /* same as aux_var but a buffer */ - double msize = 0; - double calc = 0; - double tmp = 0; - u32 wmult = 0; - double pixellen = 0; - u32 increm = 0; - u8 DATA; - - if (f_bitmap == NULL) - { - *output_pixmap = NULL; - return; - } - - bmap = parse_bitmap_header(f_bitmap); - - /* TODO TODO XXX check here if the bitmap is valid or not - * first check for the BM word - * then we check for the size of the file in header and size - * we got when reading the file - */ - { - - } - - /* if it is valid, we create the buffers */ - Neuro_CreateEBuf(&bmap_colors); - Neuro_SetcallbEBuf(bmap_colors, &clean_bmap_color); - - Neuro_CreateEBuf(&bmap_map); - - - /* print_bitmap_infos(bmap); */ - - /* process the bitmap(load it in memory) */ - i = 0; - psize = bmap->header.size - (sizeof(BITMAP_HEADER) + sizeof(BITMAP_INFOHEADER)); - psize = psize - (bmap->infoheader.ncolors * 4); - /* printf("data size %d\n", psize); */ - - if (bmap->infoheader.ncolors) - { - process_palette(f_bitmap, bmap, bmap_colors); - } - - /* semi static values to skip bytes that form 32 bit chunks in the data */ - - pixellen = (8 / (double)bmap->infoheader.bits); - msize = pixellen * 4; - - wmult = (u32)bmap->infoheader.bits / 8; - - if (wmult == 0) - wmult++; - - wmult = wmult * bmap->infoheader.width; - - increm = (u32)pixellen; - - if (increm == 0) - increm++; - - t = (u32)(bmap->infoheader.width / msize); - tmp = msize * t; - tmp = (double)bmap->infoheader.width - tmp; - tmp = tmp - 0.000001; /* to avoid bugs */ - - t = 0; -#if USE_ZLIB - gzseek(f_bitmap, bmap->header.offset, SEEK_SET); -#else /* NOT USE_ZLIB */ - fseek(f_bitmap, bmap->header.offset, SEEK_SET); -#endif /* NOT USE_ZLIB */ - - while (i < psize) - { - if (tmp > 0) - { - if (t >= wmult) - { - calc = tmp / pixellen; - t = (u32)calc; - if (t < calc) - { - t++; - } - t = (4 - t); - i += t; - -#if USE_ZLIB - gzseek(f_bitmap, bmap->header.offset + i, SEEK_SET); -#else /* NOT USE_ZLIB */ - fseek(f_bitmap, bmap->header.offset + i, SEEK_SET); -#endif /* NOT USE_ZLIB */ - - /* - printf("skipping %d bytes wmult %d width %d tmp %f plen %f calc %f\n", - t, - wmult, - bmap->infoheader.width, - tmp, - pixellen, calc); - */ - - t = 0; - } - - t += increm; - - if (i >= psize) - break; - } - - - fpdata8(f_bitmap, &DATA); - /* DATA = fgetc(f_bitmap); */ - - process_bitmap(bmap, palette, &DATA, - bmap_colors, bmap_map, - &aux_var, &aux_buf); - - /* printf("i %d psize %d\n", i, psize); */ - i++; - } - - /* now that we have the bitmap all in memory, write it to the buffer */ - if (!Neuro_EBufIsEmpty(bmap_colors) && !Neuro_EBufIsEmpty(bmap_map)) - { - outputDataToPixmap(bmap, bmap_colors, - bmap_map, output_pixmap); - } - else - { - printf("Error, buffers are empty\n"); - } - - - if (bmap) - free(bmap); - if (buf) - free(buf); - if (aux_buf) - free(aux_buf); - - Neuro_CleanEBuf(&bmap_colors); - Neuro_CleanEBuf(&bmap_map); - -#if USE_ZLIB - if (f_bitmap) - gzclose(f_bitmap); -#else /* NOT USE_ZLIB */ - if (f_bitmap) - fclose(f_bitmap); -#endif /* NOT USE_ZLIB */ -} -#endif /* old */ - - - /* Global functions */ void @@ -1612,31 +885,11 @@ setBitmapColorKey(u32 key) void readBitmapBufferToPixmap(char *data, EBUF **output_pixmap) { - -#if old - FILE *f_bitmap; - - f_bitmap = fmemopen((void*)data, 512, "r"); - - processFD_BMP2XPM((nFILE*)f_bitmap, output_pixmap); - -#endif /* old */ } void readBitmapFileToPixmap(const char *bitmap, EBUF **output_pixmap) { -#if old - nFILE *f_bitmap; - -#if USE_ZLIB - f_bitmap = gzopen(bitmap, "r"); /* can also be used for non compressed files */ -#else /* NOT USE_ZLIB */ - f_bitmap = fopen(bitmap, "r"); -#endif /* NOT USE_ZLIB */ - - processFD_BMP2XPM(f_bitmap, output_pixmap); -#endif /* old */ } v_object * -- 2.11.4.GIT