From 2de8808ff45e8a8bf73cd6c6fd7379b76c318491 Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Sat, 13 Feb 2010 00:49:06 +0000 Subject: Merge imported librosprite onto trunk svn path=/trunk/librosprite/; revision=10029 --- COPYING | 19 + Doxyfile | 1252 +++++++++++++++++++++++++++++++++++ Makefile | 63 ++ example.c | 177 +++++ librosprite.c | 840 +++++++++++++++++++++++ librosprite.h | 185 ++++++ librosprite.pc.in | 10 + palette2c.c | 48 ++ palettes/16colour | Bin 0 -> 120 bytes palettes/16mono | Bin 0 -> 120 bytes palettes/256colour | Bin 0 -> 1536 bytes palettes/256mono | Bin 0 -> 1536 bytes palettes/2mono | Bin 0 -> 12 bytes palettes/4mono | Bin 0 -> 24 bytes test-data/32bpp-alpha-test | Bin 0 -> 30356 bytes test-data/primary-color-16bpp | Bin 0 -> 180144 bytes test-data/small | Bin 0 -> 224 bytes trunk/COPYING | 19 - trunk/Doxyfile | 1252 ----------------------------------- trunk/Makefile | 63 -- trunk/example.c | 177 ----- trunk/librosprite.c | 840 ----------------------- trunk/librosprite.h | 185 ------ trunk/librosprite.pc.in | 10 - trunk/palette2c.c | 48 -- trunk/palettes/16colour | Bin 120 -> 0 bytes trunk/palettes/16mono | Bin 120 -> 0 bytes trunk/palettes/256colour | Bin 1536 -> 0 bytes trunk/palettes/256mono | Bin 1536 -> 0 bytes trunk/palettes/2mono | Bin 12 -> 0 bytes trunk/palettes/4mono | Bin 24 -> 0 bytes trunk/test-data/32bpp-alpha-test | Bin 30356 -> 0 bytes trunk/test-data/primary-color-16bpp | Bin 180144 -> 0 bytes trunk/test-data/small | Bin 224 -> 0 bytes 34 files changed, 2594 insertions(+), 2594 deletions(-) create mode 100644 COPYING create mode 100644 Doxyfile create mode 100644 Makefile create mode 100644 example.c create mode 100644 librosprite.c create mode 100644 librosprite.h create mode 100644 librosprite.pc.in create mode 100644 palette2c.c create mode 100644 palettes/16colour create mode 100644 palettes/16mono create mode 100644 palettes/256colour create mode 100644 palettes/256mono create mode 100644 palettes/2mono create mode 100644 palettes/4mono create mode 100644 test-data/32bpp-alpha-test create mode 100644 test-data/primary-color-16bpp create mode 100644 test-data/small delete mode 100644 trunk/COPYING delete mode 100644 trunk/Doxyfile delete mode 100644 trunk/Makefile delete mode 100644 trunk/example.c delete mode 100644 trunk/librosprite.c delete mode 100644 trunk/librosprite.h delete mode 100644 trunk/librosprite.pc.in delete mode 100644 trunk/palette2c.c delete mode 100644 trunk/palettes/16colour delete mode 100644 trunk/palettes/16mono delete mode 100644 trunk/palettes/256colour delete mode 100644 trunk/palettes/256mono delete mode 100644 trunk/palettes/2mono delete mode 100644 trunk/palettes/4mono delete mode 100644 trunk/test-data/32bpp-alpha-test delete mode 100644 trunk/test-data/primary-color-16bpp delete mode 100644 trunk/test-data/small diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..d78f0a7 --- /dev/null +++ b/COPYING @@ -0,0 +1,19 @@ +Copyright (c) 2008 James Shaw + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/Doxyfile b/Doxyfile new file mode 100644 index 0000000..c2bd8a3 --- /dev/null +++ b/Doxyfile @@ -0,0 +1,1252 @@ +# Doxyfile 1.5.1 + +# This file describes the settings to be used by the documentation system +# doxygen (www.doxygen.org) for a project +# +# All text after a hash (#) is considered a comment and will be ignored +# The format is: +# TAG = value [value, ...] +# For lists items can also be appended using: +# TAG += value [value, ...] +# Values that contain spaces should be placed between quotes (" ") + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- + +# The PROJECT_NAME tag is a single word (or a sequence of words surrounded +# by quotes) that should identify the project. + +PROJECT_NAME = librosprite + +# The PROJECT_NUMBER tag can be used to enter a project or revision number. +# This could be handy for archiving the generated documentation or +# if some version control system is used. + +PROJECT_NUMBER = + +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) +# base path where the generated documentation will be put. +# If a relative path is entered, it will be relative to the location +# where doxygen was started. If left blank the current directory will be used. + +OUTPUT_DIRECTORY = + +# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create +# 4096 sub-directories (in 2 levels) under the output directory of each output +# format and will distribute the generated files over these directories. +# Enabling this option can be useful when feeding doxygen a huge amount of +# source files, where putting all generated files in the same directory would +# otherwise cause performance problems for the file system. + +CREATE_SUBDIRS = NO + +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# The default language is English, other supported languages are: +# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, +# Croatian, Czech, Danish, Dutch, Finnish, French, German, Greek, Hungarian, +# Italian, Japanese, Japanese-en (Japanese with English messages), Korean, +# Korean-en, Lithuanian, Norwegian, Polish, Portuguese, Romanian, Russian, +# Serbian, Slovak, Slovene, Spanish, Swedish, and Ukrainian. + +OUTPUT_LANGUAGE = English + +# This tag can be used to specify the encoding used in the generated output. +# The encoding is not always determined by the language that is chosen, +# but also whether or not the output is meant for Windows or non-Windows users. +# In case there is a difference, setting the USE_WINDOWS_ENCODING tag to YES +# forces the Windows encoding (this is the default for the Windows binary), +# whereas setting the tag to NO uses a Unix-style encoding (the default for +# all platforms other than Windows). + +USE_WINDOWS_ENCODING = NO + +# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will +# include brief member descriptions after the members that are listed in +# the file and class documentation (similar to JavaDoc). +# Set to NO to disable this. + +BRIEF_MEMBER_DESC = YES + +# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend +# the brief description of a member or function before the detailed description. +# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# brief descriptions will be completely suppressed. + +REPEAT_BRIEF = YES + +# This tag implements a quasi-intelligent brief description abbreviator +# that is used to form the text in various listings. Each string +# in this list, if found as the leading text of the brief description, will be +# stripped from the text and the result after processing the whole list, is +# used as the annotated text. Otherwise, the brief description is used as-is. +# If left blank, the following values are used ("$name" is automatically +# replaced with the name of the entity): "The $name class" "The $name widget" +# "The $name file" "is" "provides" "specifies" "contains" +# "represents" "a" "an" "the" + +ABBREVIATE_BRIEF = + +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# Doxygen will generate a detailed section even if there is only a brief +# description. + +ALWAYS_DETAILED_SEC = NO + +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all +# inherited members of a class in the documentation of that class as if those +# members were ordinary class members. Constructors, destructors and assignment +# operators of the base classes will not be shown. + +INLINE_INHERITED_MEMB = NO + +# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full +# path before files name in the file list and in the header files. If set +# to NO the shortest path that makes the file name unique will be used. + +FULL_PATH_NAMES = YES + +# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag +# can be used to strip a user-defined part of the path. Stripping is +# only done if one of the specified strings matches the left-hand part of +# the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the +# path to strip. + +STRIP_FROM_PATH = + +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of +# the path mentioned in the documentation of a class, which tells +# the reader which header file to include in order to use a class. +# If left blank only the name of the header file containing the class +# definition is used. Otherwise one should specify the include paths that +# are normally passed to the compiler using the -I flag. + +STRIP_FROM_INC_PATH = + +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter +# (but less readable) file names. This can be useful is your file systems +# doesn't support long names like on DOS, Mac, or CD-ROM. + +SHORT_NAMES = NO + +# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen +# will interpret the first line (until the first dot) of a JavaDoc-style +# comment as the brief description. If set to NO, the JavaDoc +# comments will behave just like the Qt-style comments (thus requiring an +# explicit @brief command for a brief description. + +JAVADOC_AUTOBRIEF = YES + +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen +# treat a multi-line C++ special comment block (i.e. a block of //! or /// +# comments) as a brief description. This used to be the default behaviour. +# The new default is to treat a multi-line C++ comment block as a detailed +# description. Set this tag to YES if you prefer the old behaviour instead. + +MULTILINE_CPP_IS_BRIEF = NO + +# If the DETAILS_AT_TOP tag is set to YES then Doxygen +# will output the detailed description near the top, like JavaDoc. +# If set to NO, the detailed description appears after the member +# documentation. + +DETAILS_AT_TOP = NO + +# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented +# member inherits the documentation from any documented member that it +# re-implements. + +INHERIT_DOCS = YES + +# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce +# a new page for each member. If set to NO, the documentation of a member will +# be part of the file/class/namespace that contains it. + +SEPARATE_MEMBER_PAGES = NO + +# The TAB_SIZE tag can be used to set the number of spaces in a tab. +# Doxygen uses this value to replace tabs by spaces in code fragments. + +TAB_SIZE = 8 + +# This tag can be used to specify a number of aliases that acts +# as commands in the documentation. An alias has the form "name=value". +# For example adding "sideeffect=\par Side Effects:\n" will allow you to +# put the command \sideeffect (or @sideeffect) in the documentation, which +# will result in a user-defined paragraph with heading "Side Effects:". +# You can put \n's in the value part of an alias to insert newlines. + +ALIASES = + +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C +# sources only. Doxygen will then generate output that is more tailored for C. +# For instance, some of the names that are used will be different. The list +# of all members will be omitted, etc. + +OPTIMIZE_OUTPUT_FOR_C = NO + +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java +# sources only. Doxygen will then generate output that is more tailored for Java. +# For instance, namespaces will be presented as packages, qualified scopes +# will look different, etc. + +OPTIMIZE_OUTPUT_JAVA = NO + +# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want to +# include (a tag file for) the STL sources as input, then you should +# set this tag to YES in order to let doxygen match functions declarations and +# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. +# func(std::string) {}). This also make the inheritance and collaboration +# diagrams that involve STL classes more complete and accurate. + +BUILTIN_STL_SUPPORT = NO + +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES, then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default +# all members of a group must be documented explicitly. + +DISTRIBUTE_GROUP_DOC = NO + +# Set the SUBGROUPING tag to YES (the default) to allow class member groups of +# the same type (for instance a group of public functions) to be put as a +# subgroup of that type (e.g. under the Public Functions section). Set it to +# NO to prevent subgrouping. Alternatively, this can be done per class using +# the \nosubgrouping command. + +SUBGROUPING = YES + +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- + +# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in +# documentation are documented, even if no documentation was available. +# Private class members and static file members will be hidden unless +# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES + +EXTRACT_ALL = NO + +# If the EXTRACT_PRIVATE tag is set to YES all private members of a class +# will be included in the documentation. + +EXTRACT_PRIVATE = NO + +# If the EXTRACT_STATIC tag is set to YES all static members of a file +# will be included in the documentation. + +EXTRACT_STATIC = YES + +# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) +# defined locally in source files will be included in the documentation. +# If set to NO only classes defined in header files are included. + +EXTRACT_LOCAL_CLASSES = YES + +# This flag is only useful for Objective-C code. When set to YES local +# methods, which are defined in the implementation section but not in +# the interface are included in the documentation. +# If set to NO (the default) only methods in the interface are included. + +EXTRACT_LOCAL_METHODS = NO + +# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all +# undocumented members of documented classes, files or namespaces. +# If set to NO (the default) these members will be included in the +# various overviews, but no documentation section is generated. +# This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_MEMBERS = NO + +# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. +# If set to NO (the default) these classes will be included in the various +# overviews. This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_CLASSES = NO + +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all +# friend (class|struct|union) declarations. +# If set to NO (the default) these declarations will be included in the +# documentation. + +HIDE_FRIEND_COMPOUNDS = NO + +# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any +# documentation blocks found inside the body of a function. +# If set to NO (the default) these blocks will be appended to the +# function's detailed documentation block. + +HIDE_IN_BODY_DOCS = NO + +# The INTERNAL_DOCS tag determines if documentation +# that is typed after a \internal command is included. If the tag is set +# to NO (the default) then the documentation will be excluded. +# Set it to YES to include the internal documentation. + +INTERNAL_DOCS = NO + +# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate +# file names in lower-case letters. If set to YES upper-case letters are also +# allowed. This is useful if you have classes or files whose names only differ +# in case and if your file system supports case sensitive file names. Windows +# and Mac users are advised to set this option to NO. + +CASE_SENSE_NAMES = YES + +# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen +# will show members with their full class and namespace scopes in the +# documentation. If set to YES the scope will be hidden. + +HIDE_SCOPE_NAMES = NO + +# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen +# will put a list of the files that are included by a file in the documentation +# of that file. + +SHOW_INCLUDE_FILES = YES + +# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] +# is inserted in the documentation for inline members. + +INLINE_INFO = YES + +# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen +# will sort the (detailed) documentation of file and class members +# alphabetically by member name. If set to NO the members will appear in +# declaration order. + +SORT_MEMBER_DOCS = YES + +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the +# brief documentation of file, namespace and class members alphabetically +# by member name. If set to NO (the default) the members will appear in +# declaration order. + +SORT_BRIEF_DOCS = NO + +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be +# sorted by fully-qualified names, including namespaces. If set to +# NO (the default), the class list will be sorted only by class name, +# not including the namespace part. +# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. +# Note: This option applies only to the class list, not to the +# alphabetical list. + +SORT_BY_SCOPE_NAME = NO + +# The GENERATE_TODOLIST tag can be used to enable (YES) or +# disable (NO) the todo list. This list is created by putting \todo +# commands in the documentation. + +GENERATE_TODOLIST = YES + +# The GENERATE_TESTLIST tag can be used to enable (YES) or +# disable (NO) the test list. This list is created by putting \test +# commands in the documentation. + +GENERATE_TESTLIST = YES + +# The GENERATE_BUGLIST tag can be used to enable (YES) or +# disable (NO) the bug list. This list is created by putting \bug +# commands in the documentation. + +GENERATE_BUGLIST = YES + +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or +# disable (NO) the deprecated list. This list is created by putting +# \deprecated commands in the documentation. + +GENERATE_DEPRECATEDLIST= YES + +# The ENABLED_SECTIONS tag can be used to enable conditional +# documentation sections, marked by \if sectionname ... \endif. + +ENABLED_SECTIONS = + +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines +# the initial value of a variable or define consists of for it to appear in +# the documentation. If the initializer consists of more lines than specified +# here it will be hidden. Use a value of 0 to hide initializers completely. +# The appearance of the initializer of individual variables and defines in the +# documentation can be controlled using \showinitializer or \hideinitializer +# command in the documentation regardless of this setting. + +MAX_INITIALIZER_LINES = 30 + +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated +# at the bottom of the documentation of classes and structs. If set to YES the +# list will mention the files that were used to generate the documentation. + +SHOW_USED_FILES = YES + +# If the sources in your project are distributed over multiple directories +# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy +# in the documentation. The default is NO. + +SHOW_DIRECTORIES = NO + +# The FILE_VERSION_FILTER tag can be used to specify a program or script that +# doxygen should invoke to get the current version for each file (typically from the +# version control system). Doxygen will invoke the program by executing (via +# popen()) the command , where is the value of +# the FILE_VERSION_FILTER tag, and is the name of an input file +# provided by doxygen. Whatever the program writes to standard output +# is used as the file version. See the manual for examples. + +FILE_VERSION_FILTER = + +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- + +# The QUIET tag can be used to turn on/off the messages that are generated +# by doxygen. Possible values are YES and NO. If left blank NO is used. + +QUIET = NO + +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated by doxygen. Possible values are YES and NO. If left blank +# NO is used. + +WARNINGS = YES + +# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings +# for undocumented members. If EXTRACT_ALL is set to YES then this flag will +# automatically be disabled. + +WARN_IF_UNDOCUMENTED = YES + +# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as not documenting some +# parameters in a documented function, or documenting parameters that +# don't exist or using markup commands wrongly. + +WARN_IF_DOC_ERROR = YES + +# This WARN_NO_PARAMDOC option can be abled to get warnings for +# functions that are documented, but have no documentation for their parameters +# or return value. If set to NO (the default) doxygen will only warn about +# wrong or incomplete parameter documentation, but not about the absence of +# documentation. + +WARN_NO_PARAMDOC = NO + +# The WARN_FORMAT tag determines the format of the warning messages that +# doxygen can produce. The string should contain the $file, $line, and $text +# tags, which will be replaced by the file and line number from which the +# warning originated and the warning text. Optionally the format may contain +# $version, which will be replaced by the version of the file (if it could +# be obtained via FILE_VERSION_FILTER) + +WARN_FORMAT = "$file:$line: $text" + +# The WARN_LOGFILE tag can be used to specify a file to which warning +# and error messages should be written. If left blank the output is written +# to stderr. + +WARN_LOGFILE = + +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- + +# The INPUT tag can be used to specify the files and/or directories that contain +# documented source files. You may enter file names like "myfile.cpp" or +# directories like "/usr/src/myproject". Separate the files or directories +# with spaces. + +INPUT = + +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank the following patterns are tested: +# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx +# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py + +FILE_PATTERNS = + +# The RECURSIVE tag can be used to turn specify whether or not subdirectories +# should be searched for input files as well. Possible values are YES and NO. +# If left blank NO is used. + +RECURSIVE = NO + +# The EXCLUDE tag can be used to specify files and/or directories that should +# excluded from the INPUT source files. This way you can easily exclude a +# subdirectory from a directory tree whose root is specified with the INPUT tag. + +EXCLUDE = + +# The EXCLUDE_SYMLINKS tag can be used select whether or not files or +# directories that are symbolic links (a Unix filesystem feature) are excluded +# from the input. + +EXCLUDE_SYMLINKS = NO + +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. Note that the wildcards are matched +# against the file with absolute path, so to exclude all test directories +# for example use the pattern */test/* + +EXCLUDE_PATTERNS = + +# The EXAMPLE_PATH tag can be used to specify one or more files or +# directories that contain example code fragments that are included (see +# the \include command). + +EXAMPLE_PATH = + +# If the value of the EXAMPLE_PATH tag contains directories, you can use the +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank all files are included. + +EXAMPLE_PATTERNS = + +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be +# searched for input files to be used with the \include or \dontinclude +# commands irrespective of the value of the RECURSIVE tag. +# Possible values are YES and NO. If left blank NO is used. + +EXAMPLE_RECURSIVE = NO + +# The IMAGE_PATH tag can be used to specify one or more files or +# directories that contain image that are included in the documentation (see +# the \image command). + +IMAGE_PATH = + +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command , where +# is the value of the INPUT_FILTER tag, and is the name of an +# input file. Doxygen will then use the output that the filter program writes +# to standard output. If FILTER_PATTERNS is specified, this tag will be +# ignored. + +INPUT_FILTER = + +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern +# basis. Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. The filters are a list of the form: +# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further +# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER +# is applied to all files. + +FILTER_PATTERNS = + +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using +# INPUT_FILTER) will be used to filter the input files when producing source +# files to browse (i.e. when SOURCE_BROWSER is set to YES). + +FILTER_SOURCE_FILES = NO + +#--------------------------------------------------------------------------- +# configuration options related to source browsing +#--------------------------------------------------------------------------- + +# If the SOURCE_BROWSER tag is set to YES then a list of source files will +# be generated. Documented entities will be cross-referenced with these sources. +# Note: To get rid of all source code in the generated output, make sure also +# VERBATIM_HEADERS is set to NO. + +SOURCE_BROWSER = NO + +# Setting the INLINE_SOURCES tag to YES will include the body +# of functions and classes directly in the documentation. + +INLINE_SOURCES = NO + +# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct +# doxygen to hide any special comment blocks from generated source code +# fragments. Normal C and C++ comments will always remain visible. + +STRIP_CODE_COMMENTS = YES + +# If the REFERENCED_BY_RELATION tag is set to YES (the default) +# then for each documented function all documented +# functions referencing it will be listed. + +REFERENCED_BY_RELATION = YES + +# If the REFERENCES_RELATION tag is set to YES (the default) +# then for each documented function all documented entities +# called/used by that function will be listed. + +REFERENCES_RELATION = YES + +# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) +# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from +# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will +# link to the source code. Otherwise they will link to the documentstion. + +REFERENCES_LINK_SOURCE = YES + +# If the USE_HTAGS tag is set to YES then the references to source code +# will point to the HTML generated by the htags(1) tool instead of doxygen +# built-in source browser. The htags tool is part of GNU's global source +# tagging system (see http://www.gnu.org/software/global/global.html). You +# will need version 4.8.6 or higher. + +USE_HTAGS = NO + +# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen +# will generate a verbatim copy of the header file for each class for +# which an include is specified. Set to NO to disable this. + +VERBATIM_HEADERS = YES + +#--------------------------------------------------------------------------- +# configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- + +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index +# of all compounds will be generated. Enable this if the project +# contains a lot of classes, structs, unions or interfaces. + +ALPHABETICAL_INDEX = NO + +# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then +# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns +# in which this list will be split (can be a number in the range [1..20]) + +COLS_IN_ALPHA_INDEX = 5 + +# In case all classes in a project start with a common prefix, all +# classes will be put under the same header in the alphabetical index. +# The IGNORE_PREFIX tag can be used to specify one or more prefixes that +# should be ignored while generating the index headers. + +IGNORE_PREFIX = + +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- + +# If the GENERATE_HTML tag is set to YES (the default) Doxygen will +# generate HTML output. + +GENERATE_HTML = YES + +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `html' will be used as the default path. + +HTML_OUTPUT = doc + +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for +# each generated HTML page (for example: .htm,.php,.asp). If it is left blank +# doxygen will generate files with .html extension. + +HTML_FILE_EXTENSION = .html + +# The HTML_HEADER tag can be used to specify a personal HTML header for +# each generated HTML page. If it is left blank doxygen will generate a +# standard header. + +HTML_HEADER = + +# The HTML_FOOTER tag can be used to specify a personal HTML footer for +# each generated HTML page. If it is left blank doxygen will generate a +# standard footer. + +HTML_FOOTER = + +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading +# style sheet that is used by each HTML page. It can be used to +# fine-tune the look of the HTML output. If the tag is left blank doxygen +# will generate a default style sheet. Note that doxygen will try to copy +# the style sheet file to the HTML output directory, so don't put your own +# stylesheet in the HTML output directory as well, or it will be erased! + +HTML_STYLESHEET = + +# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, +# files or namespaces will be aligned in HTML using tables. If set to +# NO a bullet list will be used. + +HTML_ALIGN_MEMBERS = YES + +# If the GENERATE_HTMLHELP tag is set to YES, additional index files +# will be generated that can be used as input for tools like the +# Microsoft HTML help workshop to generate a compressed HTML help file (.chm) +# of the generated HTML documentation. + +GENERATE_HTMLHELP = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can +# be used to specify the file name of the resulting .chm file. You +# can add a path in front of the file if the result should not be +# written to the html output directory. + +CHM_FILE = + +# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can +# be used to specify the location (absolute path including file name) of +# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run +# the HTML help compiler on the generated index.hhp. + +HHC_LOCATION = + +# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag +# controls if a separate .chi index file is generated (YES) or that +# it should be included in the master .chm file (NO). + +GENERATE_CHI = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag +# controls whether a binary table of contents is generated (YES) or a +# normal table of contents (NO) in the .chm file. + +BINARY_TOC = NO + +# The TOC_EXPAND flag can be set to YES to add extra items for group members +# to the contents of the HTML help documentation and to the tree view. + +TOC_EXPAND = NO + +# The DISABLE_INDEX tag can be used to turn on/off the condensed index at +# top of each HTML page. The value NO (the default) enables the index and +# the value YES disables it. + +DISABLE_INDEX = NO + +# This tag can be used to set the number of enum values (range [1..20]) +# that doxygen will group on one line in the generated HTML documentation. + +ENUM_VALUES_PER_LINE = 4 + +# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be +# generated containing a tree-like index structure (just like the one that +# is generated for HTML Help). For this to work a browser that supports +# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, +# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are +# probably better off using the HTML help feature. + +GENERATE_TREEVIEW = NO + +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be +# used to set the initial width (in pixels) of the frame in which the tree +# is shown. + +TREEVIEW_WIDTH = 250 + +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- + +# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will +# generate Latex output. + +GENERATE_LATEX = NO + +# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `latex' will be used as the default path. + +LATEX_OUTPUT = latex + +# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be +# invoked. If left blank `latex' will be used as the default command name. + +LATEX_CMD_NAME = latex + +# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to +# generate index for LaTeX. If left blank `makeindex' will be used as the +# default command name. + +MAKEINDEX_CMD_NAME = makeindex + +# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact +# LaTeX documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_LATEX = NO + +# The PAPER_TYPE tag can be used to set the paper type that is used +# by the printer. Possible values are: a4, a4wide, letter, legal and +# executive. If left blank a4wide will be used. + +PAPER_TYPE = a4wide + +# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX +# packages that should be included in the LaTeX output. + +EXTRA_PACKAGES = + +# The LATEX_HEADER tag can be used to specify a personal LaTeX header for +# the generated latex document. The header should contain everything until +# the first chapter. If it is left blank doxygen will generate a +# standard header. Notice: only use this tag if you know what you are doing! + +LATEX_HEADER = + +# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated +# is prepared for conversion to pdf (using ps2pdf). The pdf file will +# contain links (just like the HTML output) instead of page references +# This makes the output suitable for online browsing using a pdf viewer. + +PDF_HYPERLINKS = NO + +# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of +# plain latex in the generated Makefile. Set this option to YES to get a +# higher quality PDF documentation. + +USE_PDFLATEX = NO + +# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. +# command to the generated LaTeX files. This will instruct LaTeX to keep +# running if errors occur, instead of asking the user for help. +# This option is also used when generating formulas in HTML. + +LATEX_BATCHMODE = NO + +# If LATEX_HIDE_INDICES is set to YES then doxygen will not +# include the index chapters (such as File Index, Compound Index, etc.) +# in the output. + +LATEX_HIDE_INDICES = NO + +#--------------------------------------------------------------------------- +# configuration options related to the RTF output +#--------------------------------------------------------------------------- + +# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output +# The RTF output is optimized for Word 97 and may not look very pretty with +# other RTF readers or editors. + +GENERATE_RTF = NO + +# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `rtf' will be used as the default path. + +RTF_OUTPUT = rtf + +# If the COMPACT_RTF tag is set to YES Doxygen generates more compact +# RTF documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_RTF = NO + +# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated +# will contain hyperlink fields. The RTF file will +# contain links (just like the HTML output) instead of page references. +# This makes the output suitable for online browsing using WORD or other +# programs which support those fields. +# Note: wordpad (write) and others do not support links. + +RTF_HYPERLINKS = NO + +# Load stylesheet definitions from file. Syntax is similar to doxygen's +# config file, i.e. a series of assignments. You only have to provide +# replacements, missing definitions are set to their default value. + +RTF_STYLESHEET_FILE = + +# Set optional variables used in the generation of an rtf document. +# Syntax is similar to doxygen's config file. + +RTF_EXTENSIONS_FILE = + +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- + +# If the GENERATE_MAN tag is set to YES (the default) Doxygen will +# generate man pages + +GENERATE_MAN = NO + +# The MAN_OUTPUT tag is used to specify where the man pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `man' will be used as the default path. + +MAN_OUTPUT = man + +# The MAN_EXTENSION tag determines the extension that is added to +# the generated man pages (default is the subroutine's section .3) + +MAN_EXTENSION = .3 + +# If the MAN_LINKS tag is set to YES and Doxygen generates man output, +# then it will generate one additional man file for each entity +# documented in the real man page(s). These additional files +# only source the real man page, but without them the man command +# would be unable to find the correct page. The default is NO. + +MAN_LINKS = NO + +#--------------------------------------------------------------------------- +# configuration options related to the XML output +#--------------------------------------------------------------------------- + +# If the GENERATE_XML tag is set to YES Doxygen will +# generate an XML file that captures the structure of +# the code including all documentation. + +GENERATE_XML = NO + +# The XML_OUTPUT tag is used to specify where the XML pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `xml' will be used as the default path. + +XML_OUTPUT = xml + +# The XML_SCHEMA tag can be used to specify an XML schema, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_SCHEMA = + +# The XML_DTD tag can be used to specify an XML DTD, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_DTD = + +# If the XML_PROGRAMLISTING tag is set to YES Doxygen will +# dump the program listings (including syntax highlighting +# and cross-referencing information) to the XML output. Note that +# enabling this will significantly increase the size of the XML output. + +XML_PROGRAMLISTING = YES + +#--------------------------------------------------------------------------- +# configuration options for the AutoGen Definitions output +#--------------------------------------------------------------------------- + +# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will +# generate an AutoGen Definitions (see autogen.sf.net) file +# that captures the structure of the code including all +# documentation. Note that this feature is still experimental +# and incomplete at the moment. + +GENERATE_AUTOGEN_DEF = NO + +#--------------------------------------------------------------------------- +# configuration options related to the Perl module output +#--------------------------------------------------------------------------- + +# If the GENERATE_PERLMOD tag is set to YES Doxygen will +# generate a Perl module file that captures the structure of +# the code including all documentation. Note that this +# feature is still experimental and incomplete at the +# moment. + +GENERATE_PERLMOD = NO + +# If the PERLMOD_LATEX tag is set to YES Doxygen will generate +# the necessary Makefile rules, Perl scripts and LaTeX code to be able +# to generate PDF and DVI output from the Perl module output. + +PERLMOD_LATEX = NO + +# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be +# nicely formatted so it can be parsed by a human reader. This is useful +# if you want to understand what is going on. On the other hand, if this +# tag is set to NO the size of the Perl module output will be much smaller +# and Perl will parse it just the same. + +PERLMOD_PRETTY = YES + +# The names of the make variables in the generated doxyrules.make file +# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. +# This is useful so different doxyrules.make files included by the same +# Makefile don't overwrite each other's variables. + +PERLMOD_MAKEVAR_PREFIX = + +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- + +# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will +# evaluate all C-preprocessor directives found in the sources and include +# files. + +ENABLE_PREPROCESSING = YES + +# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro +# names in the source code. If set to NO (the default) only conditional +# compilation will be performed. Macro expansion can be done in a controlled +# way by setting EXPAND_ONLY_PREDEF to YES. + +MACRO_EXPANSION = NO + +# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES +# then the macro expansion is limited to the macros specified with the +# PREDEFINED and EXPAND_AS_DEFINED tags. + +EXPAND_ONLY_PREDEF = NO + +# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files +# in the INCLUDE_PATH (see below) will be search if a #include is found. + +SEARCH_INCLUDES = YES + +# The INCLUDE_PATH tag can be used to specify one or more directories that +# contain include files that are not input files but should be processed by +# the preprocessor. + +INCLUDE_PATH = + +# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard +# patterns (like *.h and *.hpp) to filter out the header-files in the +# directories. If left blank, the patterns specified with FILE_PATTERNS will +# be used. + +INCLUDE_FILE_PATTERNS = + +# The PREDEFINED tag can be used to specify one or more macro names that +# are defined before the preprocessor is started (similar to the -D option of +# gcc). The argument of the tag is a list of macros of the form: name +# or name=definition (no spaces). If the definition and the = are +# omitted =1 is assumed. To prevent a macro definition from being +# undefined via #undef or recursively expanded use the := operator +# instead of the = operator. + +PREDEFINED = + +# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then +# this tag can be used to specify a list of macro names that should be expanded. +# The macro definition that is found in the sources will be used. +# Use the PREDEFINED tag if you want to use a different macro definition. + +EXPAND_AS_DEFINED = + +# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then +# doxygen's preprocessor will remove all function-like macros that are alone +# on a line, have an all uppercase name, and do not end with a semicolon. Such +# function macros are typically used for boiler-plate code, and will confuse +# the parser if not removed. + +SKIP_FUNCTION_MACROS = YES + +#--------------------------------------------------------------------------- +# Configuration::additions related to external references +#--------------------------------------------------------------------------- + +# The TAGFILES option can be used to specify one or more tagfiles. +# Optionally an initial location of the external documentation +# can be added for each tagfile. The format of a tag file without +# this location is as follows: +# TAGFILES = file1 file2 ... +# Adding location for the tag files is done as follows: +# TAGFILES = file1=loc1 "file2 = loc2" ... +# where "loc1" and "loc2" can be relative or absolute paths or +# URLs. If a location is present for each tag, the installdox tool +# does not have to be run to correct the links. +# Note that each tag file must have a unique name +# (where the name does NOT include the path) +# If a tag file is not located in the directory in which doxygen +# is run, you must also specify the path to the tagfile here. + +TAGFILES = + +# When a file name is specified after GENERATE_TAGFILE, doxygen will create +# a tag file that is based on the input files it reads. + +GENERATE_TAGFILE = + +# If the ALLEXTERNALS tag is set to YES all external classes will be listed +# in the class index. If set to NO only the inherited external classes +# will be listed. + +ALLEXTERNALS = NO + +# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed +# in the modules index. If set to NO, only the current project's groups will +# be listed. + +EXTERNAL_GROUPS = YES + +# The PERL_PATH should be the absolute path and name of the perl script +# interpreter (i.e. the result of `which perl'). + +PERL_PATH = /usr/bin/perl + +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- + +# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will +# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base +# or super classes. Setting the tag to NO turns the diagrams off. Note that +# this option is superseded by the HAVE_DOT option below. This is only a +# fallback. It is recommended to install and use dot, since it yields more +# powerful graphs. + +CLASS_DIAGRAMS = YES + +# If set to YES, the inheritance and collaboration graphs will hide +# inheritance and usage relations if the target is undocumented +# or is not a class. + +HIDE_UNDOC_RELATIONS = YES + +# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is +# available from the path. This tool is part of Graphviz, a graph visualization +# toolkit from AT&T and Lucent Bell Labs. The other options in this section +# have no effect if this option is set to NO (the default) + +HAVE_DOT = NO + +# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect inheritance relations. Setting this tag to YES will force the +# the CLASS_DIAGRAMS tag to NO. + +CLASS_GRAPH = YES + +# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect implementation dependencies (inheritance, containment, and +# class references variables) of the class with other documented classes. + +COLLABORATION_GRAPH = YES + +# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for groups, showing the direct groups dependencies + +GROUP_GRAPHS = YES + +# If the UML_LOOK tag is set to YES doxygen will generate inheritance and +# collaboration diagrams in a style similar to the OMG's Unified Modeling +# Language. + +UML_LOOK = NO + +# If set to YES, the inheritance and collaboration graphs will show the +# relations between templates and their instances. + +TEMPLATE_RELATIONS = NO + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT +# tags are set to YES then doxygen will generate a graph for each documented +# file showing the direct and indirect include dependencies of the file with +# other documented files. + +INCLUDE_GRAPH = YES + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and +# HAVE_DOT tags are set to YES then doxygen will generate a graph for each +# documented header file showing the documented files that directly or +# indirectly include this file. + +INCLUDED_BY_GRAPH = YES + +# If the CALL_GRAPH and HAVE_DOT tags are set to YES then doxygen will +# generate a call dependency graph for every global function or class method. +# Note that enabling this option will significantly increase the time of a run. +# So in most cases it will be better to enable call graphs for selected +# functions only using the \callgraph command. + +CALL_GRAPH = NO + +# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then doxygen will +# generate a caller dependency graph for every global function or class method. +# Note that enabling this option will significantly increase the time of a run. +# So in most cases it will be better to enable caller graphs for selected +# functions only using the \callergraph command. + +CALLER_GRAPH = NO + +# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen +# will graphical hierarchy of all classes instead of a textual one. + +GRAPHICAL_HIERARCHY = YES + +# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES +# then doxygen will show the dependencies a directory has on other directories +# in a graphical way. The dependency relations are determined by the #include +# relations between the files in the directories. + +DIRECTORY_GRAPH = YES + +# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images +# generated by dot. Possible values are png, jpg, or gif +# If left blank png will be used. + +DOT_IMAGE_FORMAT = png + +# The tag DOT_PATH can be used to specify the path where the dot tool can be +# found. If left blank, it is assumed the dot tool can be found in the path. + +DOT_PATH = + +# The DOTFILE_DIRS tag can be used to specify one or more directories that +# contain dot files that are included in the documentation (see the +# \dotfile command). + +DOTFILE_DIRS = + +# The MAX_DOT_GRAPH_WIDTH tag can be used to set the maximum allowed width +# (in pixels) of the graphs generated by dot. If a graph becomes larger than +# this value, doxygen will try to truncate the graph, so that it fits within +# the specified constraint. Beware that most browsers cannot cope with very +# large images. + +MAX_DOT_GRAPH_WIDTH = 1024 + +# The MAX_DOT_GRAPH_HEIGHT tag can be used to set the maximum allows height +# (in pixels) of the graphs generated by dot. If a graph becomes larger than +# this value, doxygen will try to truncate the graph, so that it fits within +# the specified constraint. Beware that most browsers cannot cope with very +# large images. + +MAX_DOT_GRAPH_HEIGHT = 1024 + +# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the +# graphs generated by dot. A depth value of 3 means that only nodes reachable +# from the root by following a path via at most 3 edges will be shown. Nodes +# that lay further from the root node will be omitted. Note that setting this +# option to 1 or 2 may greatly reduce the computation time needed for large +# code bases. Also note that a graph may be further truncated if the graph's +# image dimensions are not sufficient to fit the graph (see MAX_DOT_GRAPH_WIDTH +# and MAX_DOT_GRAPH_HEIGHT). If 0 is used for the depth value (the default), +# the graph is not depth-constrained. + +MAX_DOT_GRAPH_DEPTH = 0 + +# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent +# background. This is disabled by default, which results in a white background. +# Warning: Depending on the platform used, enabling this option may lead to +# badly anti-aliased labels on the edges of a graph (i.e. they become hard to +# read). + +DOT_TRANSPARENT = NO + +# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output +# files in one run (i.e. multiple -o and -T options on the command line). This +# makes dot run faster, but since only newer versions of dot (>1.8.10) +# support this, this feature is disabled by default. + +DOT_MULTI_TARGETS = NO + +# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will +# generate a legend page explaining the meaning of the various boxes and +# arrows in the dot generated graphs. + +GENERATE_LEGEND = YES + +# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will +# remove the intermediate dot files that are used to generate +# the various graphs. + +DOT_CLEANUP = YES + +#--------------------------------------------------------------------------- +# Configuration::additions related to the search engine +#--------------------------------------------------------------------------- + +# The SEARCHENGINE tag specifies whether or not a search engine should be +# used. If set to NO the values of all tags below this one will be ignored. + +SEARCHENGINE = NO diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..b32bace --- /dev/null +++ b/Makefile @@ -0,0 +1,63 @@ +AR = ar +CC = gcc +LD = gcc +DOXYGEN = doxygen +INSTALL = install +SED = sed +MKDIR = mkdir +PKG_CONFIG = pkg-config + +ARFLAGS = -cru +CFLAGS = -g -Wall -Wextra -Wundef -Wpointer-arith -Wcast-align \ + -Wwrite-strings -Wstrict-prototypes \ + -Wnested-externs -Werror -pedantic -std=c99 \ + -Wno-format-zero-length -Wformat-security -Wstrict-aliasing=2 \ + -Wmissing-format-attribute -Wunused -Wunreachable-code \ + -Wformat=2 -Werror-implicit-function-declaration \ + -Wmissing-declarations -Wmissing-prototypes +LDFLAGS = -g -L./ + +# Installation prefix, if not already defined (e.g. on command line) +PREFIX ?= /usr/local +DESTDIR ?= + +.PHONY: all clean docs install uninstall + +all: librosprite.a + +example: librosprite.a example.o + ${LD} -o $@ example.o ${LDFLAGS} \ + $(shell PKG_CONFIG_PATH=.:$(PKG_CONFIG_PATH) $(PKG_CONFIG) --cflags --libs sdl librosprite) + +palette2c: librosprite.a palette2c.o + ${LD} -o $@ palette2c.o ${LDFLAGS} \ + $(shell PKG_CONFIG_PATH=.:$(PKG_CONFIG_PATH) $(PKG_CONFIG) --cflags --libs librosprite) + +librosprite.a: librosprite.o librosprite.pc + ${AR} ${ARFLAGS} librosprite.a librosprite.o + +librosprite.pc: librosprite.pc.in + $(SED) -e 's#PREFIX#$(PREFIX)#' librosprite.pc.in > librosprite.pc + +%.o: %.c + ${CC} -c ${CFLAGS} -o $@ $< + +docs: + ${DOXYGEN} + +clean: + rm -f $(wildcard *.o) $(wildcard *.a) example palette2c librosprite.pc + rm -rf doc + +install: librosprite.a librosprite.pc + $(MKDIR) -p $(DESTDIR)$(PREFIX)/lib/pkgconfig + $(MKDIR) -p $(DESTDIR)$(PREFIX)/lib + $(MKDIR) -p $(DESTDIR)$(PREFIX)/include + $(INSTALL) --mode=644 -t $(DESTDIR)$(PREFIX)/lib librosprite.a + $(INSTALL) --mode=644 -t $(DESTDIR)$(PREFIX)/include librosprite.h + $(INSTALL) --mode=644 -t $(DESTDIR)$(PREFIX)/lib/pkgconfig librosprite.pc + +uninstall: + rm $(DESTDIR)$(PREFIX)/lib/librosprite.a + rm $(DESTDIR)$(PREFIX)/include/librosprite.h + rm $(DESTDIR)$(PREFIX)/lib/pkgconfig/librosprite.pc diff --git a/example.c b/example.c new file mode 100644 index 0000000..4f9755e --- /dev/null +++ b/example.c @@ -0,0 +1,177 @@ +/* + * This file is part of librosprite. + * Licensed under the MIT License, + * http://www.opensource.org/licenses/mit-license.php + * Copyright 2008 James Shaw + */ + +/** + * \file + * A test harness using SDL to display all sprites in a sprite file. + * + * Usage: example \ + */ + +#include +#include +#include + +#include "librosprite.h" + +void sdl_draw_pixel(SDL_Surface* surface, uint32_t x, uint32_t y, uint32_t color); +void sdl_blank(SDL_Surface* surface); +int load_file_to_memory(const char *filename, uint8_t **result); +int create_file_context(char* filename, void** result); +int create_mem_context(char* filename, void** result); + +int main(int argc, char *argv[]) +{ + if (argc < 2) { + fprintf(stderr, "Usage: example spritefile\n"); + exit(EXIT_FAILURE); + } + + if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) { + fprintf(stderr, "Unable to init SDL: %s\n", SDL_GetError()); + exit(EXIT_FAILURE); + } + atexit(SDL_Quit); + + char* filename = argv[1]; + void* ctx; + if (create_file_context(filename, &ctx) < 0) { + fprintf(stderr, "Unable to create file reader context\n"); + exit(EXIT_FAILURE); + } + + printf("Loading %s\n", filename); + + struct rosprite_area* sprite_area; + if (rosprite_load(rosprite_file_reader, ctx, &sprite_area) != ROSPRITE_OK) { + fprintf(stderr, "Error loading spritefile\n"); + exit(EXIT_FAILURE); + }; + printf("sprite_count %u\n", sprite_area->sprite_count); + printf("extension_size %u\n", sprite_area->extension_size); + + SDL_Surface *screen; + screen = SDL_SetVideoMode(800, 600, 32, SDL_ANYFORMAT); + SDL_SetAlpha(screen, SDL_SRCALPHA, 0); + + for (unsigned int i = 0; i < sprite_area->sprite_count; i++) { + struct rosprite* sprite = sprite_area->sprites[i]; + printf("\nname %s\n", sprite->name); + printf("color_model %s\n", sprite->mode.color_model == ROSPRITE_RGB ? "RGB" : "CMYK"); + printf("colorbpp %u\n", sprite->mode.colorbpp); + printf("xdpi %u\n", sprite->mode.xdpi); + printf("ydpi %u\n", sprite->mode.ydpi); + printf("width %u px\n", sprite->width); + printf("height %u px\n", sprite->height); + + printf("hasPalette %s\n", sprite->has_palette ? "YES" : "NO"); + if (sprite->has_palette) printf("paletteSize %u\n", sprite->palettesize); + + printf("hasMask %s\n", sprite->has_mask ? "YES" : "NO"); + if (sprite->has_mask) printf("mask_width %u\n", sprite->mode.mask_width); + if (sprite->has_mask) printf("maskbpp %u\n", sprite->mode.maskbpp); + + sdl_blank(screen); + + for (uint32_t y = 0; y < sprite->height; y++) { + for (uint32_t x = 0; x < sprite->width; x++) { + sdl_draw_pixel(screen, x, y, sprite->image[y*sprite->width + x]); + } + } + + SDL_UpdateRect(screen, 0, 0, 0, 0); + fgetc(stdin); + } + + rosprite_destroy_mem_context(ctx); + rosprite_destroy_sprite_area(sprite_area); + + return EXIT_SUCCESS; +} + +int create_file_context(char* filename, void** result) +{ + FILE *f = fopen(filename, "rb"); + if (!f) { + *result = NULL; + return -1; + } + + struct rosprite_file_context* ctx; + if (rosprite_create_file_context(f, &ctx) != ROSPRITE_OK) { + return -1; + } + *result = ctx; + + return 0; +} + +int create_mem_context(char* filename, void** result) +{ + uint8_t* content; + + int size = load_file_to_memory(filename, &content); + if (size < 0) return -1; + struct rosprite_mem_context* ctx; + if (rosprite_create_mem_context(content, size, &ctx) != ROSPRITE_OK) { + return -1; + } + *result = ctx; + + return 0; +} + +int load_file_to_memory(const char *filename, uint8_t **result) +{ + int size = 0; + FILE *f = fopen(filename, "rb"); + if (f == NULL) + { + *result = NULL; + return -1; // -1 means file opening fail + } + fseek(f, 0, SEEK_END); + size = ftell(f); + fseek(f, 0, SEEK_SET); + *result = (uint8_t *)malloc(size+1); + if ((unsigned int) size != fread(*result, sizeof(char), size, f)) + { + free(*result); + return -2; // -2 means file reading fail + } + fclose(f); + (*result)[size] = 0; + return size; +} + +/* color is 0xrrggbbaa */ +void sdl_draw_pixel(SDL_Surface* surface, uint32_t x, uint32_t y, uint32_t color) +{ + uint32_t* pixel = ((uint32_t*) (surface->pixels)) + (y * surface->pitch/4) + x; + /* pretty sure SDL can do this, but can't figure out how */ + uint32_t bg_color = ((int) (x / 4.0) + ((int)(y / 4.0) % 2)) % 2 ? 0x99 : 0x66; + + uint32_t alpha = color & 0x000000ff; + uint32_t r = (color & 0xff000000) >> 24; + uint32_t g = (color & 0x00ff0000) >> 16; + uint32_t b = (color & 0x0000ff00) >> 8; + r = ((alpha / 255.0) * r) + (((255-alpha) / 255.0) * bg_color); + g = ((alpha / 255.0) * g) + (((255-alpha) / 255.0) * bg_color); + b = ((alpha / 255.0) * b) + (((255-alpha) / 255.0) * bg_color); + uint32_t mapped_color = SDL_MapRGB(surface->format, r, g, b); + + *pixel = mapped_color; +} + +void sdl_blank(SDL_Surface* surface) +{ + for (uint32_t y = 0; y < (uint32_t) surface->h; y++) { + for (uint32_t x = 0; x < (uint32_t) surface->w; x++) { + sdl_draw_pixel(surface, x, y, (uint32_t) ((int) (x / 4.0) + ((int)(y / 4.0) % 2)) % 2 ? 0x999999ff : 0x666666ff); + } + } +} diff --git a/librosprite.c b/librosprite.c new file mode 100644 index 0000000..e21b8cb --- /dev/null +++ b/librosprite.c @@ -0,0 +1,840 @@ +/* + * This file is part of librosprite. + * Licensed under the MIT License, + * http://www.opensource.org/licenses/mit-license.php + * Copyright 2008 James Shaw + */ + +/** + * \file + */ + +#include +#include +#include +#include +#include +#include + +#include "librosprite.h" + +/** + * Reads four bytes, 00, 11, 22 and 33, of a byte array b to give 0x33221100. + */ +#define BTUINT(b) (b[0] | (b[1] << 8) | (b[2] << 16) | (b[3] << 24)) + +/** + * Reverse the byte order of a word such that 0xAABBCCDD becomes 0xDDCCBBAA. + */ +#define BSWAP(word) (((word & (0x000000ff)) << 24) | ((word & 0x0000ff00) << 8) | ((word & 0x00ff0000) >> 8) | ((word & 0xff000000) >> 24)) + +#define ERRCHK(x) do { \ + rosprite_error err = x; \ + if (err != ROSPRITE_OK) return err; \ +} while(0) + +struct rosprite_header { + uint32_t width_words; /* width in words */ + /* height defined in sprite struct */ + uint32_t first_used_bit; /* old format only (spriteType = 0) */ + uint32_t last_used_bit; + + /** + * Image size in bytes + */ + uint32_t image_size; + + /** + * Mask size in bytes + */ + uint32_t mask_size; +}; + +struct rosprite_mask_state { + uint32_t x; + uint32_t y; + uint32_t first_used_bit; + uint32_t row_max_bit; + uint32_t height; + uint32_t current_byte_index; + uint32_t current_word; + uint32_t bpp; +}; + +struct rosprite_file_context { + FILE* f; +}; + +struct rosprite_mem_context { + uint8_t* base; + unsigned long offset; + bool known_size; + unsigned long size; +}; + +static const struct rosprite_mode oldmodes[] = { +/*0*/{ .colorbpp = 1, .maskbpp = 1, .mask_width = 1, .xdpi = 90, .ydpi = 45, .color_model = ROSPRITE_RGB }, +/*1*/{ .colorbpp = 2, .maskbpp = 1, .mask_width = 2, .xdpi = 45, .ydpi = 45, .color_model = ROSPRITE_RGB }, +/*2*/{ .colorbpp = 4, .maskbpp = 1, .mask_width = 4, .xdpi = 22, .ydpi = 45, .color_model = ROSPRITE_RGB }, + +/*3*/{ .colorbpp = 0, .maskbpp = 0, .mask_width = 0, .xdpi = 0, .ydpi = 0, .color_model = ROSPRITE_RGB }, + +/*4*/{ .colorbpp = 1, .maskbpp = 1, .mask_width = 1, .xdpi = 45, .ydpi = 45, .color_model = ROSPRITE_RGB }, +/*5*/{ .colorbpp = 2, .maskbpp = 1, .mask_width = 2, .xdpi = 22, .ydpi = 45, .color_model = ROSPRITE_RGB }, + +/*6*/{ .colorbpp = 0, .maskbpp = 0, .mask_width = 0, .xdpi = 0, .ydpi = 0, .color_model = ROSPRITE_RGB }, +/*7*/{ .colorbpp = 0, .maskbpp = 0, .mask_width = 0, .xdpi = 0, .ydpi = 0, .color_model = ROSPRITE_RGB }, + +/*8*/{ .colorbpp = 2, .maskbpp = 1, .mask_width = 2, .xdpi = 90, .ydpi = 45, .color_model = ROSPRITE_RGB }, +/*9*/{ .colorbpp = 4, .maskbpp = 1, .mask_width = 4, .xdpi = 45, .ydpi = 45, .color_model = ROSPRITE_RGB }, +/*10*/{.colorbpp = 8, .maskbpp = 1, .mask_width = 8, .xdpi = 22, .ydpi = 45, .color_model = ROSPRITE_RGB }, +/*11*/{.colorbpp = 2, .maskbpp = 1, .mask_width = 2, .xdpi = 90, .ydpi = 45, .color_model = ROSPRITE_RGB }, +/*12*/{.colorbpp = 4, .maskbpp = 1, .mask_width = 4, .xdpi = 90, .ydpi = 45, .color_model = ROSPRITE_RGB }, +/*13*/{.colorbpp = 8, .maskbpp = 1, .mask_width = 8, .xdpi = 45, .ydpi = 45, .color_model = ROSPRITE_RGB }, +/*14*/{.colorbpp = 4, .maskbpp = 1, .mask_width = 4, .xdpi = 90, .ydpi = 45, .color_model = ROSPRITE_RGB }, +/*15*/{.colorbpp = 8, .maskbpp = 1, .mask_width = 8, .xdpi = 90, .ydpi = 45, .color_model = ROSPRITE_RGB }, +/*16*/{.colorbpp = 4, .maskbpp = 1, .mask_width = 4, .xdpi = 90, .ydpi = 45, .color_model = ROSPRITE_RGB }, +/*17*/{.colorbpp = 4, .maskbpp = 1, .mask_width = 4, .xdpi = 90, .ydpi = 45, .color_model = ROSPRITE_RGB }, +/*18*/{.colorbpp = 1, .maskbpp = 1, .mask_width = 1, .xdpi = 90, .ydpi = 90, .color_model = ROSPRITE_RGB }, +/*19*/{.colorbpp = 2, .maskbpp = 1, .mask_width = 2, .xdpi = 90, .ydpi = 90, .color_model = ROSPRITE_RGB }, +/*20*/{.colorbpp = 4, .maskbpp = 1, .mask_width = 4, .xdpi = 90, .ydpi = 90, .color_model = ROSPRITE_RGB }, +/*21*/{.colorbpp = 8, .maskbpp = 1, .mask_width = 8, .xdpi = 90, .ydpi = 90, .color_model = ROSPRITE_RGB }, +/*22*/{.colorbpp = 4, .maskbpp = 1, .mask_width = 4, .xdpi =180, .ydpi = 90, .color_model = ROSPRITE_RGB }, +/*23*/{.colorbpp = 1, .maskbpp = 1, .mask_width = 1, .xdpi = 90, .ydpi = 90, .color_model = ROSPRITE_RGB }, +/*24*/{.colorbpp = 8, .maskbpp = 1, .mask_width = 8, .xdpi = 90, .ydpi = 45, .color_model = ROSPRITE_RGB }, +/*25*/{.colorbpp = 1, .maskbpp = 1, .mask_width = 1, .xdpi = 90, .ydpi = 90, .color_model = ROSPRITE_RGB }, +/*26*/{.colorbpp = 2, .maskbpp = 1, .mask_width = 2, .xdpi = 90, .ydpi = 90, .color_model = ROSPRITE_RGB }, +/*27*/{.colorbpp = 4, .maskbpp = 1, .mask_width = 4, .xdpi = 90, .ydpi = 90, .color_model = ROSPRITE_RGB }, +/*28*/{.colorbpp = 8, .maskbpp = 1, .mask_width = 8, .xdpi = 90, .ydpi = 90, .color_model = ROSPRITE_RGB }, +/*29*/{.colorbpp = 1, .maskbpp = 1, .mask_width = 1, .xdpi = 90, .ydpi = 90, .color_model = ROSPRITE_RGB }, +/*30*/{.colorbpp = 2, .maskbpp = 1, .mask_width = 2, .xdpi = 90, .ydpi = 90, .color_model = ROSPRITE_RGB }, +/*31*/{.colorbpp = 4, .maskbpp = 1, .mask_width = 4, .xdpi = 90, .ydpi = 90, .color_model = ROSPRITE_RGB }, +/*32*/{.colorbpp = 8, .maskbpp = 1, .mask_width = 8, .xdpi = 90, .ydpi = 90, .color_model = ROSPRITE_RGB }, +/*33*/{.colorbpp = 1, .maskbpp = 1, .mask_width = 1, .xdpi = 90, .ydpi = 45, .color_model = ROSPRITE_RGB }, +/*34*/{.colorbpp = 2, .maskbpp = 1, .mask_width = 2, .xdpi = 90, .ydpi = 45, .color_model = ROSPRITE_RGB }, +/*35*/{.colorbpp = 4, .maskbpp = 1, .mask_width = 4, .xdpi = 90, .ydpi = 45, .color_model = ROSPRITE_RGB }, +/*36*/{.colorbpp = 8, .maskbpp = 1, .mask_width = 8, .xdpi = 90, .ydpi = 45, .color_model = ROSPRITE_RGB }, +/*37*/{.colorbpp = 1, .maskbpp = 1, .mask_width = 1, .xdpi = 90, .ydpi = 45, .color_model = ROSPRITE_RGB }, +/*38*/{.colorbpp = 2, .maskbpp = 1, .mask_width = 2, .xdpi = 90, .ydpi = 45, .color_model = ROSPRITE_RGB }, +/*39*/{.colorbpp = 4, .maskbpp = 1, .mask_width = 4, .xdpi = 90, .ydpi = 45, .color_model = ROSPRITE_RGB }, +/*40*/{.colorbpp = 8, .maskbpp = 1, .mask_width = 8, .xdpi = 90, .ydpi = 45, .color_model = ROSPRITE_RGB }, +/*41*/{.colorbpp = 1, .maskbpp = 1, .mask_width = 1, .xdpi = 90, .ydpi = 45, .color_model = ROSPRITE_RGB }, +/*42*/{.colorbpp = 2, .maskbpp = 1, .mask_width = 2, .xdpi = 90, .ydpi = 45, .color_model = ROSPRITE_RGB }, +/*43*/{.colorbpp = 4, .maskbpp = 1, .mask_width = 4, .xdpi = 90, .ydpi = 45, .color_model = ROSPRITE_RGB }, +/*44*/{.colorbpp = 1, .maskbpp = 1, .mask_width = 1, .xdpi = 90, .ydpi = 45, .color_model = ROSPRITE_RGB }, +/*45*/{.colorbpp = 2, .maskbpp = 1, .mask_width = 2, .xdpi = 90, .ydpi = 45, .color_model = ROSPRITE_RGB }, +/*46*/{.colorbpp = 4, .maskbpp = 1, .mask_width = 4, .xdpi = 90, .ydpi = 45, .color_model = ROSPRITE_RGB }, +/*47*/{.colorbpp = 8, .maskbpp = 1, .mask_width = 8, .xdpi = 45, .ydpi = 45, .color_model = ROSPRITE_RGB }, +/*48*/{.colorbpp = 4, .maskbpp = 1, .mask_width = 4, .xdpi = 45, .ydpi = 90, .color_model = ROSPRITE_RGB }, +/*49*/{.colorbpp = 8, .maskbpp = 1, .mask_width = 8, .xdpi = 45, .ydpi = 90, .color_model = ROSPRITE_RGB } +}; + +/* table for converting a 5bit channel into an 8bit channel (used for 16bpp to 32bpp conversion) */ +static const uint8_t sprite_16bpp_translate[] = { + 0x00, 0x08, 0x10, 0x18, 0x20, 0x29, 0x31, 0x39, + 0x41, 0x4a, 0x52, 0x5a, 0x62, 0x6a, 0x73, 0x7b, + 0x83, 0x8b, 0x94, 0x9c, 0xa4, 0xac, 0xb4, 0xbd, + 0xc5, 0xcd, 0xd5, 0xde, 0xe6, 0xee, 0xf6, 0xff +}; + +/* palettes generated with palette2c.c + * which in turn requires rosprite_load_palette(FILE* f) + * defined in this file + */ +static const uint32_t sprite_1bpp_palette[] = { 0xffffffff, 0xff }; + +static const uint32_t sprite_2bpp_palette[] = { 0xffffffff, 0xbbbbbbff, 0x777777ff, 0xff }; + +static const uint32_t sprite_4bpp_palette[] = { +0xffffffff, 0xddddddff, 0xbbbbbbff, 0x999999ff, +0x777777ff, 0x555555ff, 0x333333ff, 0xff, +0x4499ff, 0xeeee00ff, 0xcc00ff, 0xdd0000ff, +0xeeeebbff, 0x558800ff, 0xffbb00ff, 0xbbffff +}; + +static const uint32_t sprite_8bpp_palette[] = { +0xff, 0x111111ff, 0x222222ff, 0x333333ff, +0x440000ff, 0x551111ff, 0x662222ff, 0x773333ff, +0x44ff, 0x111155ff, 0x222266ff, 0x333377ff, +0x440044ff, 0x551155ff, 0x662266ff, 0x773377ff, +0x880000ff, 0x991111ff, 0xaa2222ff, 0xbb3333ff, +0xcc0000ff, 0xdd1111ff, 0xee2222ff, 0xff3333ff, +0x880044ff, 0x991155ff, 0xaa2266ff, 0xbb3377ff, +0xcc0044ff, 0xdd1155ff, 0xee2266ff, 0xff3377ff, +0x4400ff, 0x115511ff, 0x226622ff, 0x337733ff, +0x444400ff, 0x555511ff, 0x666622ff, 0x777733ff, +0x4444ff, 0x115555ff, 0x226666ff, 0x337777ff, +0x444444ff, 0x555555ff, 0x666666ff, 0x777777ff, +0x884400ff, 0x995511ff, 0xaa6622ff, 0xbb7733ff, +0xcc4400ff, 0xdd5511ff, 0xee6622ff, 0xff7733ff, +0x884444ff, 0x995555ff, 0xaa6666ff, 0xbb7777ff, +0xcc4444ff, 0xdd5555ff, 0xee6666ff, 0xff7777ff, +0x8800ff, 0x119911ff, 0x22aa22ff, 0x33bb33ff, +0x448800ff, 0x559911ff, 0x66aa22ff, 0x77bb33ff, +0x8844ff, 0x119955ff, 0x22aa66ff, 0x33bb77ff, +0x448844ff, 0x559955ff, 0x66aa66ff, 0x77bb77ff, +0x888800ff, 0x999911ff, 0xaaaa22ff, 0xbbbb33ff, +0xcc8800ff, 0xdd9911ff, 0xeeaa22ff, 0xffbb33ff, +0x888844ff, 0x999955ff, 0xaaaa66ff, 0xbbbb77ff, +0xcc8844ff, 0xdd9955ff, 0xeeaa66ff, 0xffbb77ff, +0xcc00ff, 0x11dd11ff, 0x22ee22ff, 0x33ff33ff, +0x44cc00ff, 0x55dd11ff, 0x66ee22ff, 0x77ff33ff, +0xcc44ff, 0x11dd55ff, 0x22ee66ff, 0x33ff77ff, +0x44cc44ff, 0x55dd55ff, 0x66ee66ff, 0x77ff77ff, +0x88cc00ff, 0x99dd11ff, 0xaaee22ff, 0xbbff33ff, +0xcccc00ff, 0xdddd11ff, 0xeeee22ff, 0xffff33ff, +0x88cc44ff, 0x99dd55ff, 0xaaee66ff, 0xbbff77ff, +0xcccc44ff, 0xdddd55ff, 0xeeee66ff, 0xffff77ff, +0x88ff, 0x111199ff, 0x2222aaff, 0x3333bbff, +0x440088ff, 0x551199ff, 0x6622aaff, 0x7733bbff, +0xccff, 0x1111ddff, 0x2222eeff, 0x3333ffff, +0x4400ccff, 0x5511ddff, 0x6622eeff, 0x7733ffff, +0x880088ff, 0x991199ff, 0xaa22aaff, 0xbb33bbff, +0xcc0088ff, 0xdd1199ff, 0xee22aaff, 0xff33bbff, +0x8800ccff, 0x9911ddff, 0xaa22eeff, 0xbb33ffff, +0xcc00ccff, 0xdd11ddff, 0xee22eeff, 0xff33ffff, +0x4488ff, 0x115599ff, 0x2266aaff, 0x3377bbff, +0x444488ff, 0x555599ff, 0x6666aaff, 0x7777bbff, +0x44ccff, 0x1155ddff, 0x2266eeff, 0x3377ffff, +0x4444ccff, 0x5555ddff, 0x6666eeff, 0x7777ffff, +0x884488ff, 0x995599ff, 0xaa66aaff, 0xbb77bbff, +0xcc4488ff, 0xdd5599ff, 0xee66aaff, 0xff77bbff, +0x8844ccff, 0x9955ddff, 0xaa66eeff, 0xbb77ffff, +0xcc44ccff, 0xdd55ddff, 0xee66eeff, 0xff77ffff, +0x8888ff, 0x119999ff, 0x22aaaaff, 0x33bbbbff, +0x448888ff, 0x559999ff, 0x66aaaaff, 0x77bbbbff, +0x88ccff, 0x1199ddff, 0x22aaeeff, 0x33bbffff, +0x4488ccff, 0x5599ddff, 0x66aaeeff, 0x77bbffff, +0x888888ff, 0x999999ff, 0xaaaaaaff, 0xbbbbbbff, +0xcc8888ff, 0xdd9999ff, 0xeeaaaaff, 0xffbbbbff, +0x8888ccff, 0x9999ddff, 0xaaaaeeff, 0xbbbbffff, +0xcc88ccff, 0xdd99ddff, 0xeeaaeeff, 0xffbbffff, +0xcc88ff, 0x11dd99ff, 0x22eeaaff, 0x33ffbbff, +0x44cc88ff, 0x55dd99ff, 0x66eeaaff, 0x77ffbbff, +0xccccff, 0x11ddddff, 0x22eeeeff, 0x33ffffff, +0x44ccccff, 0x55ddddff, 0x66eeeeff, 0x77ffffff, +0x88cc88ff, 0x99dd99ff, 0xaaeeaaff, 0xbbffbbff, +0xcccc88ff, 0xdddd99ff, 0xeeeeaaff, 0xffffbbff, +0x88ccccff, 0x99ddddff, 0xaaeeeeff, 0xbbffffff, +0xccccccff, 0xddddddff, 0xeeeeeeff, 0xffffffff +}; + +static inline rosprite_error rosprite_read_word(reader reader, void* ctx, uint32_t* result); +static rosprite_error rosprite_get_mode(uint32_t spriteMode, struct rosprite_mode* result); +static uint32_t rosprite_palette_lookup(struct rosprite* sprite, uint32_t pixel); +static inline uint32_t rosprite_cmyk_to_rgb(uint32_t cmyk); +static uint32_t rosprite_next_mask_pixel(uint8_t* mask, struct rosprite_mask_state* mask_state); +static rosprite_error rosprite_load_high_color(uint8_t* image_in, uint8_t* mask, struct rosprite* sprite, struct rosprite_header* header); +static rosprite_error rosprite_load_low_color(uint8_t* image_in, uint8_t* mask, struct rosprite* sprite, struct rosprite_header* header); +rosprite_error rosprite_load_sprite(reader reader, void* ctx, struct rosprite** result); +static rosprite_error rosprite_init_mask_state(struct rosprite* sprite, struct rosprite_header* header, uint8_t* mask, struct rosprite_mask_state** result); +static uint32_t rosprite_upscale_color(uint32_t pixel, struct rosprite_mode* mode, bool* has_alpha_pixel_data); +static inline void rosprite_fix_alpha(uint32_t* image, unsigned long pixels); + +rosprite_error rosprite_load(reader reader, void* ctx, struct rosprite_area** result) +{ + struct rosprite_area* sprite_area = malloc(sizeof(struct rosprite_area)); + + ERRCHK(rosprite_read_word(reader, ctx, &(sprite_area->sprite_count))); + + uint32_t firstSpriteOffset, firstFreeWordOffset; + ERRCHK(rosprite_read_word(reader, ctx, &firstSpriteOffset)); + ERRCHK(rosprite_read_word(reader, ctx, &firstFreeWordOffset)); /* TODO: use this for some sanity checking? */ + sprite_area->extension_size = 16 - firstSpriteOffset; + + sprite_area->extension_words = NULL; + if (sprite_area->extension_size > 0) { + sprite_area->extension_words = malloc(sprite_area->extension_size); + int bytes_read = reader(sprite_area->extension_words, (size_t) (sprite_area->extension_size), ctx); + if (bytes_read < (signed long) sprite_area->extension_size) { + return ROSPRITE_EOF; + } + } + + sprite_area->sprites = malloc(sizeof(struct rosprite*) * sprite_area->sprite_count); /* allocate array of pointers */ + for (uint32_t i = 0; i < sprite_area->sprite_count; i++) { + struct rosprite* sprite; + ERRCHK(rosprite_load_sprite(reader, ctx, &sprite)); + sprite_area->sprites[i] = sprite; + } + + *result = sprite_area; + + return ROSPRITE_OK; +} + +void rosprite_destroy_sprite_area(struct rosprite_area* sprite_area) +{ + for (uint32_t i = 0; i < sprite_area->sprite_count; i++) { + struct rosprite* sprite = sprite_area->sprites[i]; + if (sprite->has_palette) free(sprite->palette); + free(sprite->image); + free(sprite); + } + + free(sprite_area->sprites); + if (sprite_area->extension_size > 0) free(sprite_area->extension_words); + free(sprite_area); +} + +rosprite_error rosprite_load_palette(reader reader, void* ctx, struct rosprite_palette** result) +{ + /* TODO: currently assume palette has linear entries (2nd byte in is 00, 01, 02 etc) */ + struct rosprite_palette* palette = malloc(sizeof(struct rosprite_palette)); + + palette->palette = malloc(sizeof(uint32_t) * 256); /* allocate 256 whether we need them all or not */ + + uint32_t c = 0; + uint8_t b[6]; + + unsigned int bytesRead = reader(b, 6, ctx); + assert(bytesRead % 6 == 0); + while (bytesRead == 6) { + assert(b[0] == 19); /* VDU 19 */ + + /* only process logical colours */ + if (b[2] == 16) { + /*assert(c == b[1]);*/ + + uint32_t entry = (b[3] << 24) | (b[4] << 16) | (b[5] << 8) | 0xff; /* last byte is alpha */ + palette->palette[c] = entry; + + c++; + assert(c <= 256); + } + + bytesRead = reader(b, 6, ctx); + assert(bytesRead % 6 == 0); + } + + palette->size = c; + + *result = palette; + + return ROSPRITE_OK; +} + +void rosprite_destroy_palette(struct rosprite_palette* palette) +{ + free(palette->palette); + free(palette); +} + +rosprite_error rosprite_create_file_context(FILE* f, struct rosprite_file_context** result) +{ + struct rosprite_file_context* ctx = malloc(sizeof(struct rosprite_file_context)); + if (!ctx) return ROSPRITE_NOMEM; + ctx->f = f; + *result = ctx; + + return ROSPRITE_OK; +} + +void rosprite_destroy_file_context(struct rosprite_file_context* ctx) +{ + free(ctx); +} + +int rosprite_file_reader(uint8_t* buf, size_t count, void* ctx) +{ + return fread(buf, 1 /*size*/, count, ((struct rosprite_file_context*) ctx)->f); +} + +rosprite_error rosprite_create_mem_context(uint8_t* p, unsigned long total_size, struct rosprite_mem_context** result) +{ + struct rosprite_mem_context* ctx = malloc(sizeof(struct rosprite_mem_context)); + if (!ctx) return ROSPRITE_NOMEM; + + ctx->base = p; + ctx->offset = 0; + ctx->size = total_size; + *result = ctx; + + return ROSPRITE_OK; +} + +void rosprite_destroy_mem_context(struct rosprite_mem_context* ctx) +{ + free(ctx); +} + +int rosprite_mem_reader(uint8_t* buf, size_t count, void* ctx) +{ + struct rosprite_mem_context* memctx = (struct rosprite_mem_context*) ctx; + if (memctx->offset + count > memctx->size) { + return -1; + } + + // if we're asked for more memory than the block contains, only copy as much as we can + size_t copy_size; + if ((memctx->offset + count) > memctx->size) { + copy_size = memctx->size - memctx->offset; + } else { + copy_size = count; + } + memcpy(buf, memctx->base + memctx->offset, count); + memctx->offset += count; + return copy_size; +} + +/** + * Load a single sprite. + * + * \param[out] result + */ +rosprite_error rosprite_load_sprite(reader reader, void* ctx, struct rosprite** result) +{ + uint32_t nextSpriteOffset; + ERRCHK(rosprite_read_word(reader, ctx, &nextSpriteOffset)); + + struct rosprite* sprite = malloc(sizeof(struct rosprite)); + struct rosprite_header* header = malloc(sizeof(struct rosprite_header)); + + reader(sprite->name, 12, ctx); + sprite->name[12] = '\0'; + + ERRCHK(rosprite_read_word(reader, ctx, &header->width_words)); /* file has width - 1 and height - 1 */ + header->width_words += 1; + ERRCHK(rosprite_read_word(reader, ctx, &(sprite->height))); + sprite->height += 1; + ERRCHK(rosprite_read_word(reader, ctx, &(header->first_used_bit))); /* old format only (spriteType = 0) */ + ERRCHK(rosprite_read_word(reader, ctx, &(header->last_used_bit))); + + uint32_t imageOffset; + ERRCHK(rosprite_read_word(reader, ctx, &imageOffset)); + assert(imageOffset >= 44); /* should never be smaller than the size of the header) */ + + uint32_t maskOffset, spriteModeWord; + ERRCHK(rosprite_read_word(reader, ctx, &maskOffset)); + ERRCHK(rosprite_read_word(reader, ctx, &spriteModeWord)); + + ERRCHK(rosprite_get_mode(spriteModeWord, &(sprite->mode))); + + /* TODO left-hand wastage */ + + assert((header->last_used_bit + 1) % sprite->mode.colorbpp == 0); + /*assert(header->width_words % sprite->mode->colorbpp == 0);*/ + sprite->width = (header->width_words * 32 - header->first_used_bit - (31 - header->last_used_bit)) / sprite->mode.colorbpp; + + sprite->palettesize = imageOffset - 44; + sprite->has_palette = (sprite->palettesize > 0); + + /* sprite has no mask if imageOffset == maskOffset */ + if (imageOffset == maskOffset) { + sprite->has_mask = false; + header->image_size = nextSpriteOffset - 44 - sprite->palettesize; + header->mask_size = 0; + } else { + sprite->has_mask = true; + header->image_size = maskOffset - imageOffset; + header->mask_size = nextSpriteOffset - 44 - sprite->palettesize - header->image_size; + } + + if (sprite->has_palette) { + assert(sprite->palettesize % 8 == 0); + sprite->palette = malloc(sizeof(uint32_t) * sprite->palettesize); + uint32_t paletteEntries = sprite->palettesize / 8; + + /* Each palette entry is two words big + * The second word is a duplicate of the first + * I think this is in case you ever wanted flashing colours + * PRM1-730 + */ + for (uint32_t j = 0; j < paletteEntries; j++) { + uint32_t word1, word2; + ERRCHK(rosprite_read_word(reader, ctx, &word1)); + ERRCHK(rosprite_read_word(reader, ctx, &word2)); + assert(word1 == word2); /* if they aren't equal, flashing colours are desired, which we don't support */ + + /* swap rr and bb parts -- PRM1-731 */ + uint32_t entry = ((word1 & 0xff000000) >> 16) | (word1 & 0x00ff0000) | ((word1 & 0x0000ff00) << 16) | 0xff; + sprite->palette[j] = entry; + } + } + + uint8_t* image = malloc(header->image_size); + reader(image, header->image_size, ctx); + + uint8_t* mask = NULL; + if (sprite->has_mask) { + mask = malloc(header->mask_size); + reader(mask, header->mask_size, ctx); + } + + /* sanity check image_size */ + assert((header->width_words) * 4 * (sprite->height) == header->image_size); + /* TODO: sanity check mask_size */ + if (sprite->mode.colorbpp > 8) { + ERRCHK(rosprite_load_high_color(image, mask, sprite, header)); + } else { + ERRCHK(rosprite_load_low_color(image, mask, sprite, header)); + } + + free(image); + free(mask); + free(header); + + *result = sprite; + + return ROSPRITE_OK; +} + +/** + * Determine the sprite_mode for the specified sprite_mode_word. + * + * \param[out] result + */ +static rosprite_error rosprite_get_mode(uint32_t sprite_mode_word, struct rosprite_mode* result) +{ + struct rosprite_mode mode; + + uint32_t spriteType = (sprite_mode_word & (15 << 27)) >> 27; /* preserve bits 27-30 only */ + + if (spriteType != 0) { + bool hasEightBitAlpha = sprite_mode_word >> 31; /* bit 31 */ + /* new modes have 1bpp masks (PRM5a-111) + * unless bit 31 is set (http://select.riscos.com/prm/graphics/sprites/alphachannel.html) + */ + mode.maskbpp = (hasEightBitAlpha ? 8 : 1); + mode.mask_width = mode.maskbpp; + mode.xdpi = (sprite_mode_word & (8191 << 14)) >> 14; /* preserve bits 14-26 only */ + mode.ydpi = (sprite_mode_word & (8191 << 1)) >> 1; /* preserve bits 1-13 only */ + + mode.color_model = ROSPRITE_RGB; + switch (spriteType) { + case 1: + mode.colorbpp = 1; break; + case 2: + mode.colorbpp = 2; break; + case 3: + mode.colorbpp = 4; break; + case 4: + mode.colorbpp = 8; break; + case 5: + mode.colorbpp = 16; break; + case 6: + mode.colorbpp = 32; break; + case 7: + mode.colorbpp = 32; + mode.color_model = ROSPRITE_CMYK; + break; + case 8: + mode.colorbpp = 24; break; + default: + return ROSPRITE_BADMODE; + } + } else { + assert(sprite_mode_word < 256); /* don't think you can have modes over 255? */ + + mode = oldmodes[sprite_mode_word]; + } + + /* illegal mode check */ + if ((mode.colorbpp == 0) || (mode.xdpi == 0) || (mode.ydpi == 0)) { + return ROSPRITE_BADMODE; + } + + memcpy(result, &mode, sizeof(struct rosprite_mode)); + + return ROSPRITE_OK; +} + +/** + * Load a sprite image with 16 or more bpp. + * + * \param[out] sprite On exit, sprite.image will be populated + */ +static rosprite_error rosprite_load_high_color(uint8_t* image_in, uint8_t* mask, struct rosprite* sprite, struct rosprite_header* header) +{ + struct rosprite_mask_state* mask_state = NULL; + if (sprite->has_mask) { + ERRCHK(rosprite_init_mask_state(sprite, header, mask, &mask_state)); + } + + sprite->image = malloc(sprite->width * sprite->height * 4); /* all image data is 32bpp going out */ + + uint32_t currentByteIndex = 0; + const uint32_t bpp = sprite->mode.colorbpp; + const uint32_t bytesPerPixel = bpp / 8; + const uint32_t row_max_bit = header->width_words * 32 - (31 - header->last_used_bit); /* Last used bit in row */ + + bool has_alpha_pixel_data = false; + + /* Spec says that there must be no left-hand wastage */ + assert(header->first_used_bit == 0); + + for (uint32_t y = 0; y < sprite->height; y++) { + uint32_t x_pixels = 0; + for (uint32_t x = 0; x < row_max_bit; x += bpp) { + uint32_t pixel = 0; + for (uint32_t j = 0; j < bytesPerPixel; j++) { + uint8_t b = image_in[currentByteIndex++]; + pixel = pixel | (b << (j * 8)); + } + + bool old_has_alpha = has_alpha_pixel_data; + pixel = rosprite_upscale_color(pixel, &(sprite->mode), &has_alpha_pixel_data); + if (old_has_alpha != has_alpha_pixel_data && (y > 0 || x_pixels > 0)) { + rosprite_fix_alpha(sprite->image, (y * sprite->width) + x_pixels - 1); + } + if (sprite->has_mask) { + uint8_t mask_pixel = rosprite_next_mask_pixel(mask, mask_state); + pixel = (pixel & 0xffffff00) | mask_pixel; + } + sprite->image[y*sprite->width + x_pixels] = pixel; + x_pixels++; + } + + /* Ensure byte index is pointing at start of next row */ + if (y + 1 < sprite->height) { + currentByteIndex = (currentByteIndex + 3) & ~3; /* Round up to next multiple of 4 */ + } + } + + if (sprite->has_mask) free(mask_state); + return ROSPRITE_OK; +} + +/** + * Iterate over the specified number of pixels, starting at the image pointer, + * and set the alpha channel to 0x00. + */ +static inline void rosprite_fix_alpha(uint32_t* image, unsigned long pixels) +{ + for (uint32_t i = 0; i <= pixels; i++) { + image[i] = image[i] & 0xffffff00; + } +} + +/** + * Load a sprite image with 8 or fewer bpp. + * + * \param[out] sprite On exit, sprite.image will be populated + */ +static rosprite_error rosprite_load_low_color(uint8_t* image_in, uint8_t* mask, struct rosprite* sprite, struct rosprite_header* header) +{ + struct rosprite_mask_state* mask_state = NULL; + if (sprite->has_mask) { + ERRCHK(rosprite_init_mask_state(sprite, header, mask, &mask_state)); + } + + sprite->image = malloc(sprite->width * sprite->height * 4); /* all image data is 32bpp going out */ + + const uint32_t bpp = sprite->mode.colorbpp; + const uint32_t row_max_bit = header->width_words * 32 - (31 - header->last_used_bit); /* Last used bit in row */ + const uint32_t bitmask = (1 << bpp) - 1; /* creates a mask of 1s that is bpp bits wide */ + + uint32_t current_byte_index = 0; + uint32_t currentword = BTUINT((image_in + current_byte_index)); + current_byte_index += 4; + + for (uint32_t y = 0; y < sprite->height; y++) { + uint32_t x_pixels = 0; + for (uint32_t x = header->first_used_bit; x < row_max_bit ; x += bpp) { + const uint32_t offset_into_word = x % 32; + + uint32_t pixel = (currentword & (bitmask << offset_into_word)) >> offset_into_word; + pixel = rosprite_palette_lookup(sprite, pixel); /* lookup returns 32bpp */ + if (sprite->has_mask) { + uint8_t mask_pixel = rosprite_next_mask_pixel(mask, mask_state); + pixel = (pixel & 0xffffff00) | mask_pixel; + } + sprite->image[y*sprite->width + x_pixels] = pixel; + x_pixels++; + + /* If we're not at the end of the row and we've processed all of this word, fetch the next one */ + if (x + bpp < row_max_bit && offset_into_word + bpp == 32) { + currentword = BTUINT((image_in + current_byte_index)); + current_byte_index += 4; + } + } + + /* Advance to first word of next row */ + if (y + 1 < sprite->height) { + currentword = BTUINT((image_in + current_byte_index)); + current_byte_index += 4; + } + } + + if (sprite->has_mask) free(mask_state); + + return ROSPRITE_OK; +} + +static uint32_t rosprite_palette_lookup(struct rosprite* sprite, uint32_t pixel) +{ + uint32_t translated_pixel; + /* because we're dealing with 8bpp or less */ + if (sprite->has_palette) { + assert(pixel <= sprite->palettesize); /* TODO: what to do if your color depth is bigger than palette? */ + translated_pixel = sprite->palette[pixel]; + } else { + switch (sprite->mode.colorbpp) { + case 8: + assert(pixel < 256); + translated_pixel = sprite_8bpp_palette[pixel]; + break; + case 4: + assert(pixel < 16); + translated_pixel = sprite_4bpp_palette[pixel]; + break; + case 2: + assert(pixel < 4); + translated_pixel = sprite_2bpp_palette[pixel]; + break; + case 1: + assert(pixel < 2); + translated_pixel = sprite_1bpp_palette[pixel]; + break; + default: + assert(false); + } + } + return translated_pixel; +} + +static rosprite_error rosprite_init_mask_state(struct rosprite* sprite, struct rosprite_header* header, uint8_t* mask, struct rosprite_mask_state** result) +{ + struct rosprite_mask_state* mask_state = malloc(sizeof(struct rosprite_mask_state)); + if (!mask_state) return ROSPRITE_NOMEM; + + mask_state->x = header->first_used_bit; + mask_state->y = 0; + mask_state->first_used_bit = header->first_used_bit; + mask_state->row_max_bit = sprite->width * sprite->mode.mask_width; + mask_state->height = sprite->height; + mask_state->bpp = sprite->mode.mask_width; + mask_state->current_word = BTUINT(mask); + mask_state->current_byte_index = 4; + + *result = mask_state; + + return ROSPRITE_OK; +} + +/** + * Get the next mask byte. + * A mask of 0xff denotes 100% opaque, 0x00 denotes 100% transparent. + * + * \param[in,out] mask_state + */ +static uint32_t rosprite_next_mask_pixel(uint8_t* mask, struct rosprite_mask_state* mask_state) +{ + /* a 1bpp mask (for new mode sprites), each row is word aligned (therefore potential righthand wastage */ + const uint32_t bitmask = (1 << mask_state->bpp) - 1; + const uint32_t offset_into_word = mask_state->x % 32; + uint32_t pixel = (mask_state->current_word & (bitmask << offset_into_word)) >> offset_into_word; + + if (mask_state->x + mask_state->bpp < mask_state->row_max_bit && offset_into_word + mask_state->bpp == 32) { + mask_state->current_word = BTUINT((mask + mask_state->current_byte_index)); + mask_state->current_byte_index += 4; + } + + mask_state->x += mask_state->bpp; + if (mask_state->x >= mask_state->row_max_bit) { + mask_state->x = mask_state->first_used_bit; + + if (mask_state->y + 1 < mask_state->height) { + mask_state->current_word = BTUINT((mask + mask_state->current_byte_index)); + mask_state->current_byte_index += 4; + } + + mask_state->y++; + } + + /* + * if the mask is 1bpp, make sure the whole byte is 0x00 or 0xff + */ + if (mask_state->bpp < 8) { + pixel = (pixel & 1) ? 0xff : 0x00; + } + + return pixel; +} + +/** + * Upscale a 16, 24 or 32bpp sprite to the 0xRRGGBBAA representation. + * Do not call this function with a sprite with less than 16bpp, + * but use a palette lookup instead. + */ +static uint32_t rosprite_upscale_color(uint32_t pixel, struct rosprite_mode* mode, bool* has_alpha_pixel_data) +{ + switch (mode->colorbpp) { + case 32: + if (mode->color_model == ROSPRITE_RGB) { + /* swap from 0xAABBGGRR to 0xRRGGBBAA */ + pixel = BSWAP(pixel); + } else { + pixel = rosprite_cmyk_to_rgb(pixel); + } + break; + case 24: + /* reverse byte order */ + pixel = BSWAP(pixel); + break; + case 16: + /* incoming format is b_00000000000000000bbbbbgggggrrrrr */ + { + uint8_t red = pixel & 31; + uint8_t green = (pixel & (31 << 5)) >> 5; + uint8_t blue = (pixel & (31 << 10)) >> 10; + + /* sanity check */ + assert(red < 32); + assert(green < 32); + assert(blue < 32); + + pixel = (sprite_16bpp_translate[red] << 24) + | (sprite_16bpp_translate[green] << 16) + | (sprite_16bpp_translate[blue] << 8); + } + break; + case 8: + case 4: + case 2: + case 1: + assert(false); /* shouldn't need to call for <= 8bpp, since a palette lookup will return 32bpp */ + default: + assert(false); /* unknown bpp */ + } + + uint8_t alpha = pixel & 0xff; + if (alpha == 0x00) { + if (!(*has_alpha_pixel_data)) { + pixel = pixel | 0xff; + } + } else { + *has_alpha_pixel_data = true; + } + return pixel; +} + +static inline uint32_t rosprite_cmyk_to_rgb(uint32_t cmyk) +{ + uint8_t c = cmyk & 0xff; + uint8_t m = (cmyk & 0xff00) >> 8; + uint8_t y = (cmyk & 0xff0000) >> 16; + uint8_t k = cmyk >> 24; + + /* Convert to CMY colourspace */ + uint8_t C = c + k; + uint8_t M = m + k; + uint8_t Y = y + k; + + /* And to RGB */ + uint8_t r = 255 - C; + uint8_t g = 255 - M; + uint8_t b = 255 - Y; + + return r << 24 | g << 16 | b << 8; +} + +static inline rosprite_error rosprite_read_word(reader reader, void* ctx, uint32_t* result) +{ + unsigned char b[4]; + if (reader(b, 4, ctx) < 4) { + return ROSPRITE_EOF; + } + *result = BTUINT(b); + return ROSPRITE_OK; +} diff --git a/librosprite.h b/librosprite.h new file mode 100644 index 0000000..f54eaf2 --- /dev/null +++ b/librosprite.h @@ -0,0 +1,185 @@ +/* + * This file is part of librosprite. + * Licensed under the MIT License, + * http://www.opensource.org/licenses/mit-license.php + * Copyright 2008 James Shaw + */ + +/** + * \mainpage + * + * librosprite is a library for reading RISC OS sprite and palette files. The following subformats are supported: + *
    + *
  • 1-bit and 8-bit transparency masks
  • + *
  • Sprites with custom palettes
  • + *
  • Standard RISC OS 1-bit, 2-bit palettes, and 4-bit and 8-bit colour palettes
  • + *
  • Old-style sprites with most screen modes from 0-49 supported
  • + *
  • 32bpp CMYK
  • + *
  • Inline alpha channel, as used by Photodesk and Tinct
  • + *
+ * + */ + +/** + * \file librosprite.h + * + * Sprite file reading is performed by rosprite_load(), and palette file reading by rosprite_load_palette(). + * + * Retrieving sprite or palette data is performed by a reader. + * librosprite implements file and memory readers. + * To use a reader, create a context by calling the + * rosprite_create_file_context() or rosprite_create_mem_context(). + * Pass the reader function, and the context you have created, to the load function, + * typically rosprite_load(). + */ + +#ifndef ROSPRITE_H +#define ROSPRITE_H + +#include +#include +#include + +typedef enum { ROSPRITE_OK, ROSPRITE_NOMEM, ROSPRITE_EOF, ROSPRITE_BADMODE } rosprite_error; + +typedef enum { ROSPRITE_RGB, ROSPRITE_CMYK } rosprite_color_model; + +/** + * A reader interface used to load sprite files. + */ +typedef int (*reader)(uint8_t* buf, size_t count, void* ctx); + +struct rosprite_file_context; + +/** + * A sprite area comprises zero or more rosprites. Optionally, it may also have an extension_words block. + */ +struct rosprite_area { + uint32_t extension_size; /* size of extension_words in bytes */ + uint8_t* extension_words; + uint32_t sprite_count; + struct rosprite** sprites; /* array of length sprite_count */ +}; + +/** + * A sprite mode defines the colour depth, colour model and bitmap resolution of a sprite. + */ +struct rosprite_mode { + /** + * The bits per colour channel. Legal values are 1, 2, 4, 8, 16, 24 and 32. + */ + uint32_t colorbpp; + /* maskbpp denotes the amount of alpha bpp used + * while mask_width is the bits used to store the mask. + * Old modes have the same mask_width as their colorbpp, but the value + * is always all-zeroes or all-ones. + * New modes can have 1bpp or 8bpp masks + */ + uint32_t maskbpp; + uint32_t mask_width; /* in pixels */ + + /** + * Horizontal dots per inch. Typical values are 22, 45, 90 and 180. + */ + uint32_t xdpi; + + /** + * Vertical dots per inch. Typical values are 22, 45, 90 and 180. + */ + uint32_t ydpi; + rosprite_color_model color_model; +}; + +struct rosprite_palette { + uint32_t size; /* in number of entries (each entry is a word) */ + uint32_t* palette; +}; + +/** + * A sprite is a bitmap image which has a mode, width and height. + */ +struct rosprite { + + /** + * The sprite name. This may be up to 12 characters long, and must be zero terminated. + */ + unsigned char name[13]; + struct rosprite_mode mode; + bool has_mask; + bool has_palette; + uint32_t palettesize; /* in number of entries (each entry is a word) */ + uint32_t* palette; + + /** + * Width in pixels + */ + uint32_t width; + + /** + * Height in pixels + */ + uint32_t height; + + /** + * Image data is a series of words, appearing on screen left-to-right, top-to-bottom. + * Each word takes the form 0xRRGGBBAA. A is the alpha channel, where 0 is transparent, and 255 is opaque. + */ + uint32_t* image; /* image data in 0xRRGGBBAA words */ +}; + +struct rosprite_file_context; + +/** + * Create a file reader context using the specified file handle. + * Clients must call rosprite_destroy_file_context() to dispose of the context. + * + * \param[out] result + */ +rosprite_error rosprite_create_file_context(FILE* f, struct rosprite_file_context** result); +void rosprite_destroy_file_context(struct rosprite_file_context* ctx); +int rosprite_file_reader(uint8_t* buf, size_t count, void* ctx); + +struct rosprite_mem_context; + +/** + * Create a memory reader context using the specified memory pointer. + * Clients must call rosprite_destroy_mem_context() to dispose of the context. + * + * \param[in] p pointer to the start of the memory block + * \param[in] total_size the size of the block pointed to by p, in bytes + * \param[out] result + */ +rosprite_error rosprite_create_mem_context(uint8_t* p, unsigned long total_size, struct rosprite_mem_context** result); +void rosprite_destroy_mem_context(struct rosprite_mem_context* ctx); +int rosprite_mem_reader(uint8_t* buf, size_t count, void* ctx); + +/** + * Load a rosprite_area using the reader provided. + * Clients must call rosprite_destroy_sprite_area() to dispose of the rosprite_area. + * + * \param[out] result The pointer to be populated by this function. + */ +rosprite_error rosprite_load(reader reader, void* ctx, struct rosprite_area** result); + +/** + * Dispose of a rosprite_area and its children. + */ +void rosprite_destroy_sprite_area(struct rosprite_area *); + +/** + * Load a RISC OS palette file. A palette file has RISC OS filetype 0xFED, + * and is a series of VDU 19 Set Palette commands, each command being 6 bytes long. + * + * Clients must call rosprite_destroy_palette() to dispose of the rosprite_palette. + * + * \param[out] result The pointer to be populated by this function. + * \see http://www.drobe.co.uk/show_manual.php?manual=/sh-cgi?manual=Vdu%26page=19 + */ +rosprite_error rosprite_load_palette(reader reader, void* ctx, struct rosprite_palette** result); + +/** + * Dispose of a rosprite_palette and its children. + */ +void rosprite_destroy_palette(struct rosprite_palette *); + +#endif diff --git a/librosprite.pc.in b/librosprite.pc.in new file mode 100644 index 0000000..322ca21 --- /dev/null +++ b/librosprite.pc.in @@ -0,0 +1,10 @@ +prefix=PREFIX +exec_prefix=${prefix} +libdir=${exec_prefix}/lib +includedir=${prefix}/include + +Name: librosprite +Description: Loads RISC OS sprite files +Version: 0.0.1 +Libs: -L${libdir} -lrosprite +Cflags: -I${includedir} diff --git a/palette2c.c b/palette2c.c new file mode 100644 index 0000000..bbe272c --- /dev/null +++ b/palette2c.c @@ -0,0 +1,48 @@ +/* + * This file is part of librosprite. + * Licensed under the MIT License, + * http://www.opensource.org/licenses/mit-license.php + * Copyright 2008 James Shaw + */ + +#include +#include + +#include "librosprite.h" + +int main(int argc, char *argv[]) +{ + if (argc < 2) { + printf("Usage: palette2c palettefile\n"); + exit(EXIT_FAILURE); + } + + char* filename = argv[1]; + + FILE* f = fopen(filename, "rb"); + if (f == NULL) { + printf("Can't load palettefile %s\n", filename); + exit(EXIT_FAILURE); + } + + struct rosprite_file_context* ctx; + if (rosprite_create_file_context(f, &ctx) != ROSPRITE_OK) { + exit(EXIT_FAILURE); + } + + struct rosprite_palette* palette; + if (rosprite_load_palette(rosprite_file_reader, ctx, &palette) != ROSPRITE_OK) { + exit(EXIT_FAILURE); + } + + for (uint32_t i = 0; i < palette->size; i++) { + printf("0x%x, ", palette->palette[i]); + } + + fclose(f); + + rosprite_destroy_file_context(ctx); + rosprite_destroy_palette(palette); + + return EXIT_SUCCESS; +} diff --git a/palettes/16colour b/palettes/16colour new file mode 100644 index 0000000..5ac39ea Binary files /dev/null and b/palettes/16colour differ diff --git a/palettes/16mono b/palettes/16mono new file mode 100644 index 0000000..f121b9a Binary files /dev/null and b/palettes/16mono differ diff --git a/palettes/256colour b/palettes/256colour new file mode 100644 index 0000000..e1f67bb Binary files /dev/null and b/palettes/256colour differ diff --git a/palettes/256mono b/palettes/256mono new file mode 100644 index 0000000..0866679 Binary files /dev/null and b/palettes/256mono differ diff --git a/palettes/2mono b/palettes/2mono new file mode 100644 index 0000000..a2afa45 Binary files /dev/null and b/palettes/2mono differ diff --git a/palettes/4mono b/palettes/4mono new file mode 100644 index 0000000..495ce8c Binary files /dev/null and b/palettes/4mono differ diff --git a/test-data/32bpp-alpha-test b/test-data/32bpp-alpha-test new file mode 100644 index 0000000..92ebd63 Binary files /dev/null and b/test-data/32bpp-alpha-test differ diff --git a/test-data/primary-color-16bpp b/test-data/primary-color-16bpp new file mode 100644 index 0000000..fba7a08 Binary files /dev/null and b/test-data/primary-color-16bpp differ diff --git a/test-data/small b/test-data/small new file mode 100644 index 0000000..5552782 Binary files /dev/null and b/test-data/small differ diff --git a/trunk/COPYING b/trunk/COPYING deleted file mode 100644 index d78f0a7..0000000 --- a/trunk/COPYING +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2008 James Shaw - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. \ No newline at end of file diff --git a/trunk/Doxyfile b/trunk/Doxyfile deleted file mode 100644 index c2bd8a3..0000000 --- a/trunk/Doxyfile +++ /dev/null @@ -1,1252 +0,0 @@ -# Doxyfile 1.5.1 - -# This file describes the settings to be used by the documentation system -# doxygen (www.doxygen.org) for a project -# -# All text after a hash (#) is considered a comment and will be ignored -# The format is: -# TAG = value [value, ...] -# For lists items can also be appended using: -# TAG += value [value, ...] -# Values that contain spaces should be placed between quotes (" ") - -#--------------------------------------------------------------------------- -# Project related configuration options -#--------------------------------------------------------------------------- - -# The PROJECT_NAME tag is a single word (or a sequence of words surrounded -# by quotes) that should identify the project. - -PROJECT_NAME = librosprite - -# The PROJECT_NUMBER tag can be used to enter a project or revision number. -# This could be handy for archiving the generated documentation or -# if some version control system is used. - -PROJECT_NUMBER = - -# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) -# base path where the generated documentation will be put. -# If a relative path is entered, it will be relative to the location -# where doxygen was started. If left blank the current directory will be used. - -OUTPUT_DIRECTORY = - -# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create -# 4096 sub-directories (in 2 levels) under the output directory of each output -# format and will distribute the generated files over these directories. -# Enabling this option can be useful when feeding doxygen a huge amount of -# source files, where putting all generated files in the same directory would -# otherwise cause performance problems for the file system. - -CREATE_SUBDIRS = NO - -# The OUTPUT_LANGUAGE tag is used to specify the language in which all -# documentation generated by doxygen is written. Doxygen will use this -# information to generate all constant output in the proper language. -# The default language is English, other supported languages are: -# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, -# Croatian, Czech, Danish, Dutch, Finnish, French, German, Greek, Hungarian, -# Italian, Japanese, Japanese-en (Japanese with English messages), Korean, -# Korean-en, Lithuanian, Norwegian, Polish, Portuguese, Romanian, Russian, -# Serbian, Slovak, Slovene, Spanish, Swedish, and Ukrainian. - -OUTPUT_LANGUAGE = English - -# This tag can be used to specify the encoding used in the generated output. -# The encoding is not always determined by the language that is chosen, -# but also whether or not the output is meant for Windows or non-Windows users. -# In case there is a difference, setting the USE_WINDOWS_ENCODING tag to YES -# forces the Windows encoding (this is the default for the Windows binary), -# whereas setting the tag to NO uses a Unix-style encoding (the default for -# all platforms other than Windows). - -USE_WINDOWS_ENCODING = NO - -# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will -# include brief member descriptions after the members that are listed in -# the file and class documentation (similar to JavaDoc). -# Set to NO to disable this. - -BRIEF_MEMBER_DESC = YES - -# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend -# the brief description of a member or function before the detailed description. -# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the -# brief descriptions will be completely suppressed. - -REPEAT_BRIEF = YES - -# This tag implements a quasi-intelligent brief description abbreviator -# that is used to form the text in various listings. Each string -# in this list, if found as the leading text of the brief description, will be -# stripped from the text and the result after processing the whole list, is -# used as the annotated text. Otherwise, the brief description is used as-is. -# If left blank, the following values are used ("$name" is automatically -# replaced with the name of the entity): "The $name class" "The $name widget" -# "The $name file" "is" "provides" "specifies" "contains" -# "represents" "a" "an" "the" - -ABBREVIATE_BRIEF = - -# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then -# Doxygen will generate a detailed section even if there is only a brief -# description. - -ALWAYS_DETAILED_SEC = NO - -# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all -# inherited members of a class in the documentation of that class as if those -# members were ordinary class members. Constructors, destructors and assignment -# operators of the base classes will not be shown. - -INLINE_INHERITED_MEMB = NO - -# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full -# path before files name in the file list and in the header files. If set -# to NO the shortest path that makes the file name unique will be used. - -FULL_PATH_NAMES = YES - -# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag -# can be used to strip a user-defined part of the path. Stripping is -# only done if one of the specified strings matches the left-hand part of -# the path. The tag can be used to show relative paths in the file list. -# If left blank the directory from which doxygen is run is used as the -# path to strip. - -STRIP_FROM_PATH = - -# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of -# the path mentioned in the documentation of a class, which tells -# the reader which header file to include in order to use a class. -# If left blank only the name of the header file containing the class -# definition is used. Otherwise one should specify the include paths that -# are normally passed to the compiler using the -I flag. - -STRIP_FROM_INC_PATH = - -# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter -# (but less readable) file names. This can be useful is your file systems -# doesn't support long names like on DOS, Mac, or CD-ROM. - -SHORT_NAMES = NO - -# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen -# will interpret the first line (until the first dot) of a JavaDoc-style -# comment as the brief description. If set to NO, the JavaDoc -# comments will behave just like the Qt-style comments (thus requiring an -# explicit @brief command for a brief description. - -JAVADOC_AUTOBRIEF = YES - -# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen -# treat a multi-line C++ special comment block (i.e. a block of //! or /// -# comments) as a brief description. This used to be the default behaviour. -# The new default is to treat a multi-line C++ comment block as a detailed -# description. Set this tag to YES if you prefer the old behaviour instead. - -MULTILINE_CPP_IS_BRIEF = NO - -# If the DETAILS_AT_TOP tag is set to YES then Doxygen -# will output the detailed description near the top, like JavaDoc. -# If set to NO, the detailed description appears after the member -# documentation. - -DETAILS_AT_TOP = NO - -# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented -# member inherits the documentation from any documented member that it -# re-implements. - -INHERIT_DOCS = YES - -# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce -# a new page for each member. If set to NO, the documentation of a member will -# be part of the file/class/namespace that contains it. - -SEPARATE_MEMBER_PAGES = NO - -# The TAB_SIZE tag can be used to set the number of spaces in a tab. -# Doxygen uses this value to replace tabs by spaces in code fragments. - -TAB_SIZE = 8 - -# This tag can be used to specify a number of aliases that acts -# as commands in the documentation. An alias has the form "name=value". -# For example adding "sideeffect=\par Side Effects:\n" will allow you to -# put the command \sideeffect (or @sideeffect) in the documentation, which -# will result in a user-defined paragraph with heading "Side Effects:". -# You can put \n's in the value part of an alias to insert newlines. - -ALIASES = - -# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C -# sources only. Doxygen will then generate output that is more tailored for C. -# For instance, some of the names that are used will be different. The list -# of all members will be omitted, etc. - -OPTIMIZE_OUTPUT_FOR_C = NO - -# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java -# sources only. Doxygen will then generate output that is more tailored for Java. -# For instance, namespaces will be presented as packages, qualified scopes -# will look different, etc. - -OPTIMIZE_OUTPUT_JAVA = NO - -# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want to -# include (a tag file for) the STL sources as input, then you should -# set this tag to YES in order to let doxygen match functions declarations and -# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. -# func(std::string) {}). This also make the inheritance and collaboration -# diagrams that involve STL classes more complete and accurate. - -BUILTIN_STL_SUPPORT = NO - -# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC -# tag is set to YES, then doxygen will reuse the documentation of the first -# member in the group (if any) for the other members of the group. By default -# all members of a group must be documented explicitly. - -DISTRIBUTE_GROUP_DOC = NO - -# Set the SUBGROUPING tag to YES (the default) to allow class member groups of -# the same type (for instance a group of public functions) to be put as a -# subgroup of that type (e.g. under the Public Functions section). Set it to -# NO to prevent subgrouping. Alternatively, this can be done per class using -# the \nosubgrouping command. - -SUBGROUPING = YES - -#--------------------------------------------------------------------------- -# Build related configuration options -#--------------------------------------------------------------------------- - -# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in -# documentation are documented, even if no documentation was available. -# Private class members and static file members will be hidden unless -# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES - -EXTRACT_ALL = NO - -# If the EXTRACT_PRIVATE tag is set to YES all private members of a class -# will be included in the documentation. - -EXTRACT_PRIVATE = NO - -# If the EXTRACT_STATIC tag is set to YES all static members of a file -# will be included in the documentation. - -EXTRACT_STATIC = YES - -# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) -# defined locally in source files will be included in the documentation. -# If set to NO only classes defined in header files are included. - -EXTRACT_LOCAL_CLASSES = YES - -# This flag is only useful for Objective-C code. When set to YES local -# methods, which are defined in the implementation section but not in -# the interface are included in the documentation. -# If set to NO (the default) only methods in the interface are included. - -EXTRACT_LOCAL_METHODS = NO - -# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all -# undocumented members of documented classes, files or namespaces. -# If set to NO (the default) these members will be included in the -# various overviews, but no documentation section is generated. -# This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_MEMBERS = NO - -# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all -# undocumented classes that are normally visible in the class hierarchy. -# If set to NO (the default) these classes will be included in the various -# overviews. This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_CLASSES = NO - -# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all -# friend (class|struct|union) declarations. -# If set to NO (the default) these declarations will be included in the -# documentation. - -HIDE_FRIEND_COMPOUNDS = NO - -# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any -# documentation blocks found inside the body of a function. -# If set to NO (the default) these blocks will be appended to the -# function's detailed documentation block. - -HIDE_IN_BODY_DOCS = NO - -# The INTERNAL_DOCS tag determines if documentation -# that is typed after a \internal command is included. If the tag is set -# to NO (the default) then the documentation will be excluded. -# Set it to YES to include the internal documentation. - -INTERNAL_DOCS = NO - -# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate -# file names in lower-case letters. If set to YES upper-case letters are also -# allowed. This is useful if you have classes or files whose names only differ -# in case and if your file system supports case sensitive file names. Windows -# and Mac users are advised to set this option to NO. - -CASE_SENSE_NAMES = YES - -# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen -# will show members with their full class and namespace scopes in the -# documentation. If set to YES the scope will be hidden. - -HIDE_SCOPE_NAMES = NO - -# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen -# will put a list of the files that are included by a file in the documentation -# of that file. - -SHOW_INCLUDE_FILES = YES - -# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] -# is inserted in the documentation for inline members. - -INLINE_INFO = YES - -# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen -# will sort the (detailed) documentation of file and class members -# alphabetically by member name. If set to NO the members will appear in -# declaration order. - -SORT_MEMBER_DOCS = YES - -# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the -# brief documentation of file, namespace and class members alphabetically -# by member name. If set to NO (the default) the members will appear in -# declaration order. - -SORT_BRIEF_DOCS = NO - -# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be -# sorted by fully-qualified names, including namespaces. If set to -# NO (the default), the class list will be sorted only by class name, -# not including the namespace part. -# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. -# Note: This option applies only to the class list, not to the -# alphabetical list. - -SORT_BY_SCOPE_NAME = NO - -# The GENERATE_TODOLIST tag can be used to enable (YES) or -# disable (NO) the todo list. This list is created by putting \todo -# commands in the documentation. - -GENERATE_TODOLIST = YES - -# The GENERATE_TESTLIST tag can be used to enable (YES) or -# disable (NO) the test list. This list is created by putting \test -# commands in the documentation. - -GENERATE_TESTLIST = YES - -# The GENERATE_BUGLIST tag can be used to enable (YES) or -# disable (NO) the bug list. This list is created by putting \bug -# commands in the documentation. - -GENERATE_BUGLIST = YES - -# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or -# disable (NO) the deprecated list. This list is created by putting -# \deprecated commands in the documentation. - -GENERATE_DEPRECATEDLIST= YES - -# The ENABLED_SECTIONS tag can be used to enable conditional -# documentation sections, marked by \if sectionname ... \endif. - -ENABLED_SECTIONS = - -# The MAX_INITIALIZER_LINES tag determines the maximum number of lines -# the initial value of a variable or define consists of for it to appear in -# the documentation. If the initializer consists of more lines than specified -# here it will be hidden. Use a value of 0 to hide initializers completely. -# The appearance of the initializer of individual variables and defines in the -# documentation can be controlled using \showinitializer or \hideinitializer -# command in the documentation regardless of this setting. - -MAX_INITIALIZER_LINES = 30 - -# Set the SHOW_USED_FILES tag to NO to disable the list of files generated -# at the bottom of the documentation of classes and structs. If set to YES the -# list will mention the files that were used to generate the documentation. - -SHOW_USED_FILES = YES - -# If the sources in your project are distributed over multiple directories -# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy -# in the documentation. The default is NO. - -SHOW_DIRECTORIES = NO - -# The FILE_VERSION_FILTER tag can be used to specify a program or script that -# doxygen should invoke to get the current version for each file (typically from the -# version control system). Doxygen will invoke the program by executing (via -# popen()) the command , where is the value of -# the FILE_VERSION_FILTER tag, and is the name of an input file -# provided by doxygen. Whatever the program writes to standard output -# is used as the file version. See the manual for examples. - -FILE_VERSION_FILTER = - -#--------------------------------------------------------------------------- -# configuration options related to warning and progress messages -#--------------------------------------------------------------------------- - -# The QUIET tag can be used to turn on/off the messages that are generated -# by doxygen. Possible values are YES and NO. If left blank NO is used. - -QUIET = NO - -# The WARNINGS tag can be used to turn on/off the warning messages that are -# generated by doxygen. Possible values are YES and NO. If left blank -# NO is used. - -WARNINGS = YES - -# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings -# for undocumented members. If EXTRACT_ALL is set to YES then this flag will -# automatically be disabled. - -WARN_IF_UNDOCUMENTED = YES - -# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for -# potential errors in the documentation, such as not documenting some -# parameters in a documented function, or documenting parameters that -# don't exist or using markup commands wrongly. - -WARN_IF_DOC_ERROR = YES - -# This WARN_NO_PARAMDOC option can be abled to get warnings for -# functions that are documented, but have no documentation for their parameters -# or return value. If set to NO (the default) doxygen will only warn about -# wrong or incomplete parameter documentation, but not about the absence of -# documentation. - -WARN_NO_PARAMDOC = NO - -# The WARN_FORMAT tag determines the format of the warning messages that -# doxygen can produce. The string should contain the $file, $line, and $text -# tags, which will be replaced by the file and line number from which the -# warning originated and the warning text. Optionally the format may contain -# $version, which will be replaced by the version of the file (if it could -# be obtained via FILE_VERSION_FILTER) - -WARN_FORMAT = "$file:$line: $text" - -# The WARN_LOGFILE tag can be used to specify a file to which warning -# and error messages should be written. If left blank the output is written -# to stderr. - -WARN_LOGFILE = - -#--------------------------------------------------------------------------- -# configuration options related to the input files -#--------------------------------------------------------------------------- - -# The INPUT tag can be used to specify the files and/or directories that contain -# documented source files. You may enter file names like "myfile.cpp" or -# directories like "/usr/src/myproject". Separate the files or directories -# with spaces. - -INPUT = - -# If the value of the INPUT tag contains directories, you can use the -# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank the following patterns are tested: -# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx -# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py - -FILE_PATTERNS = - -# The RECURSIVE tag can be used to turn specify whether or not subdirectories -# should be searched for input files as well. Possible values are YES and NO. -# If left blank NO is used. - -RECURSIVE = NO - -# The EXCLUDE tag can be used to specify files and/or directories that should -# excluded from the INPUT source files. This way you can easily exclude a -# subdirectory from a directory tree whose root is specified with the INPUT tag. - -EXCLUDE = - -# The EXCLUDE_SYMLINKS tag can be used select whether or not files or -# directories that are symbolic links (a Unix filesystem feature) are excluded -# from the input. - -EXCLUDE_SYMLINKS = NO - -# If the value of the INPUT tag contains directories, you can use the -# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude -# certain files from those directories. Note that the wildcards are matched -# against the file with absolute path, so to exclude all test directories -# for example use the pattern */test/* - -EXCLUDE_PATTERNS = - -# The EXAMPLE_PATH tag can be used to specify one or more files or -# directories that contain example code fragments that are included (see -# the \include command). - -EXAMPLE_PATH = - -# If the value of the EXAMPLE_PATH tag contains directories, you can use the -# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank all files are included. - -EXAMPLE_PATTERNS = - -# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be -# searched for input files to be used with the \include or \dontinclude -# commands irrespective of the value of the RECURSIVE tag. -# Possible values are YES and NO. If left blank NO is used. - -EXAMPLE_RECURSIVE = NO - -# The IMAGE_PATH tag can be used to specify one or more files or -# directories that contain image that are included in the documentation (see -# the \image command). - -IMAGE_PATH = - -# The INPUT_FILTER tag can be used to specify a program that doxygen should -# invoke to filter for each input file. Doxygen will invoke the filter program -# by executing (via popen()) the command , where -# is the value of the INPUT_FILTER tag, and is the name of an -# input file. Doxygen will then use the output that the filter program writes -# to standard output. If FILTER_PATTERNS is specified, this tag will be -# ignored. - -INPUT_FILTER = - -# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern -# basis. Doxygen will compare the file name with each pattern and apply the -# filter if there is a match. The filters are a list of the form: -# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further -# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER -# is applied to all files. - -FILTER_PATTERNS = - -# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using -# INPUT_FILTER) will be used to filter the input files when producing source -# files to browse (i.e. when SOURCE_BROWSER is set to YES). - -FILTER_SOURCE_FILES = NO - -#--------------------------------------------------------------------------- -# configuration options related to source browsing -#--------------------------------------------------------------------------- - -# If the SOURCE_BROWSER tag is set to YES then a list of source files will -# be generated. Documented entities will be cross-referenced with these sources. -# Note: To get rid of all source code in the generated output, make sure also -# VERBATIM_HEADERS is set to NO. - -SOURCE_BROWSER = NO - -# Setting the INLINE_SOURCES tag to YES will include the body -# of functions and classes directly in the documentation. - -INLINE_SOURCES = NO - -# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct -# doxygen to hide any special comment blocks from generated source code -# fragments. Normal C and C++ comments will always remain visible. - -STRIP_CODE_COMMENTS = YES - -# If the REFERENCED_BY_RELATION tag is set to YES (the default) -# then for each documented function all documented -# functions referencing it will be listed. - -REFERENCED_BY_RELATION = YES - -# If the REFERENCES_RELATION tag is set to YES (the default) -# then for each documented function all documented entities -# called/used by that function will be listed. - -REFERENCES_RELATION = YES - -# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) -# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from -# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will -# link to the source code. Otherwise they will link to the documentstion. - -REFERENCES_LINK_SOURCE = YES - -# If the USE_HTAGS tag is set to YES then the references to source code -# will point to the HTML generated by the htags(1) tool instead of doxygen -# built-in source browser. The htags tool is part of GNU's global source -# tagging system (see http://www.gnu.org/software/global/global.html). You -# will need version 4.8.6 or higher. - -USE_HTAGS = NO - -# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen -# will generate a verbatim copy of the header file for each class for -# which an include is specified. Set to NO to disable this. - -VERBATIM_HEADERS = YES - -#--------------------------------------------------------------------------- -# configuration options related to the alphabetical class index -#--------------------------------------------------------------------------- - -# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index -# of all compounds will be generated. Enable this if the project -# contains a lot of classes, structs, unions or interfaces. - -ALPHABETICAL_INDEX = NO - -# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then -# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns -# in which this list will be split (can be a number in the range [1..20]) - -COLS_IN_ALPHA_INDEX = 5 - -# In case all classes in a project start with a common prefix, all -# classes will be put under the same header in the alphabetical index. -# The IGNORE_PREFIX tag can be used to specify one or more prefixes that -# should be ignored while generating the index headers. - -IGNORE_PREFIX = - -#--------------------------------------------------------------------------- -# configuration options related to the HTML output -#--------------------------------------------------------------------------- - -# If the GENERATE_HTML tag is set to YES (the default) Doxygen will -# generate HTML output. - -GENERATE_HTML = YES - -# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `html' will be used as the default path. - -HTML_OUTPUT = doc - -# The HTML_FILE_EXTENSION tag can be used to specify the file extension for -# each generated HTML page (for example: .htm,.php,.asp). If it is left blank -# doxygen will generate files with .html extension. - -HTML_FILE_EXTENSION = .html - -# The HTML_HEADER tag can be used to specify a personal HTML header for -# each generated HTML page. If it is left blank doxygen will generate a -# standard header. - -HTML_HEADER = - -# The HTML_FOOTER tag can be used to specify a personal HTML footer for -# each generated HTML page. If it is left blank doxygen will generate a -# standard footer. - -HTML_FOOTER = - -# The HTML_STYLESHEET tag can be used to specify a user-defined cascading -# style sheet that is used by each HTML page. It can be used to -# fine-tune the look of the HTML output. If the tag is left blank doxygen -# will generate a default style sheet. Note that doxygen will try to copy -# the style sheet file to the HTML output directory, so don't put your own -# stylesheet in the HTML output directory as well, or it will be erased! - -HTML_STYLESHEET = - -# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, -# files or namespaces will be aligned in HTML using tables. If set to -# NO a bullet list will be used. - -HTML_ALIGN_MEMBERS = YES - -# If the GENERATE_HTMLHELP tag is set to YES, additional index files -# will be generated that can be used as input for tools like the -# Microsoft HTML help workshop to generate a compressed HTML help file (.chm) -# of the generated HTML documentation. - -GENERATE_HTMLHELP = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can -# be used to specify the file name of the resulting .chm file. You -# can add a path in front of the file if the result should not be -# written to the html output directory. - -CHM_FILE = - -# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can -# be used to specify the location (absolute path including file name) of -# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run -# the HTML help compiler on the generated index.hhp. - -HHC_LOCATION = - -# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag -# controls if a separate .chi index file is generated (YES) or that -# it should be included in the master .chm file (NO). - -GENERATE_CHI = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag -# controls whether a binary table of contents is generated (YES) or a -# normal table of contents (NO) in the .chm file. - -BINARY_TOC = NO - -# The TOC_EXPAND flag can be set to YES to add extra items for group members -# to the contents of the HTML help documentation and to the tree view. - -TOC_EXPAND = NO - -# The DISABLE_INDEX tag can be used to turn on/off the condensed index at -# top of each HTML page. The value NO (the default) enables the index and -# the value YES disables it. - -DISABLE_INDEX = NO - -# This tag can be used to set the number of enum values (range [1..20]) -# that doxygen will group on one line in the generated HTML documentation. - -ENUM_VALUES_PER_LINE = 4 - -# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be -# generated containing a tree-like index structure (just like the one that -# is generated for HTML Help). For this to work a browser that supports -# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, -# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are -# probably better off using the HTML help feature. - -GENERATE_TREEVIEW = NO - -# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be -# used to set the initial width (in pixels) of the frame in which the tree -# is shown. - -TREEVIEW_WIDTH = 250 - -#--------------------------------------------------------------------------- -# configuration options related to the LaTeX output -#--------------------------------------------------------------------------- - -# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will -# generate Latex output. - -GENERATE_LATEX = NO - -# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `latex' will be used as the default path. - -LATEX_OUTPUT = latex - -# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be -# invoked. If left blank `latex' will be used as the default command name. - -LATEX_CMD_NAME = latex - -# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to -# generate index for LaTeX. If left blank `makeindex' will be used as the -# default command name. - -MAKEINDEX_CMD_NAME = makeindex - -# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact -# LaTeX documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_LATEX = NO - -# The PAPER_TYPE tag can be used to set the paper type that is used -# by the printer. Possible values are: a4, a4wide, letter, legal and -# executive. If left blank a4wide will be used. - -PAPER_TYPE = a4wide - -# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX -# packages that should be included in the LaTeX output. - -EXTRA_PACKAGES = - -# The LATEX_HEADER tag can be used to specify a personal LaTeX header for -# the generated latex document. The header should contain everything until -# the first chapter. If it is left blank doxygen will generate a -# standard header. Notice: only use this tag if you know what you are doing! - -LATEX_HEADER = - -# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated -# is prepared for conversion to pdf (using ps2pdf). The pdf file will -# contain links (just like the HTML output) instead of page references -# This makes the output suitable for online browsing using a pdf viewer. - -PDF_HYPERLINKS = NO - -# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of -# plain latex in the generated Makefile. Set this option to YES to get a -# higher quality PDF documentation. - -USE_PDFLATEX = NO - -# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. -# command to the generated LaTeX files. This will instruct LaTeX to keep -# running if errors occur, instead of asking the user for help. -# This option is also used when generating formulas in HTML. - -LATEX_BATCHMODE = NO - -# If LATEX_HIDE_INDICES is set to YES then doxygen will not -# include the index chapters (such as File Index, Compound Index, etc.) -# in the output. - -LATEX_HIDE_INDICES = NO - -#--------------------------------------------------------------------------- -# configuration options related to the RTF output -#--------------------------------------------------------------------------- - -# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output -# The RTF output is optimized for Word 97 and may not look very pretty with -# other RTF readers or editors. - -GENERATE_RTF = NO - -# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `rtf' will be used as the default path. - -RTF_OUTPUT = rtf - -# If the COMPACT_RTF tag is set to YES Doxygen generates more compact -# RTF documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_RTF = NO - -# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated -# will contain hyperlink fields. The RTF file will -# contain links (just like the HTML output) instead of page references. -# This makes the output suitable for online browsing using WORD or other -# programs which support those fields. -# Note: wordpad (write) and others do not support links. - -RTF_HYPERLINKS = NO - -# Load stylesheet definitions from file. Syntax is similar to doxygen's -# config file, i.e. a series of assignments. You only have to provide -# replacements, missing definitions are set to their default value. - -RTF_STYLESHEET_FILE = - -# Set optional variables used in the generation of an rtf document. -# Syntax is similar to doxygen's config file. - -RTF_EXTENSIONS_FILE = - -#--------------------------------------------------------------------------- -# configuration options related to the man page output -#--------------------------------------------------------------------------- - -# If the GENERATE_MAN tag is set to YES (the default) Doxygen will -# generate man pages - -GENERATE_MAN = NO - -# The MAN_OUTPUT tag is used to specify where the man pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `man' will be used as the default path. - -MAN_OUTPUT = man - -# The MAN_EXTENSION tag determines the extension that is added to -# the generated man pages (default is the subroutine's section .3) - -MAN_EXTENSION = .3 - -# If the MAN_LINKS tag is set to YES and Doxygen generates man output, -# then it will generate one additional man file for each entity -# documented in the real man page(s). These additional files -# only source the real man page, but without them the man command -# would be unable to find the correct page. The default is NO. - -MAN_LINKS = NO - -#--------------------------------------------------------------------------- -# configuration options related to the XML output -#--------------------------------------------------------------------------- - -# If the GENERATE_XML tag is set to YES Doxygen will -# generate an XML file that captures the structure of -# the code including all documentation. - -GENERATE_XML = NO - -# The XML_OUTPUT tag is used to specify where the XML pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `xml' will be used as the default path. - -XML_OUTPUT = xml - -# The XML_SCHEMA tag can be used to specify an XML schema, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - -XML_SCHEMA = - -# The XML_DTD tag can be used to specify an XML DTD, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - -XML_DTD = - -# If the XML_PROGRAMLISTING tag is set to YES Doxygen will -# dump the program listings (including syntax highlighting -# and cross-referencing information) to the XML output. Note that -# enabling this will significantly increase the size of the XML output. - -XML_PROGRAMLISTING = YES - -#--------------------------------------------------------------------------- -# configuration options for the AutoGen Definitions output -#--------------------------------------------------------------------------- - -# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will -# generate an AutoGen Definitions (see autogen.sf.net) file -# that captures the structure of the code including all -# documentation. Note that this feature is still experimental -# and incomplete at the moment. - -GENERATE_AUTOGEN_DEF = NO - -#--------------------------------------------------------------------------- -# configuration options related to the Perl module output -#--------------------------------------------------------------------------- - -# If the GENERATE_PERLMOD tag is set to YES Doxygen will -# generate a Perl module file that captures the structure of -# the code including all documentation. Note that this -# feature is still experimental and incomplete at the -# moment. - -GENERATE_PERLMOD = NO - -# If the PERLMOD_LATEX tag is set to YES Doxygen will generate -# the necessary Makefile rules, Perl scripts and LaTeX code to be able -# to generate PDF and DVI output from the Perl module output. - -PERLMOD_LATEX = NO - -# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be -# nicely formatted so it can be parsed by a human reader. This is useful -# if you want to understand what is going on. On the other hand, if this -# tag is set to NO the size of the Perl module output will be much smaller -# and Perl will parse it just the same. - -PERLMOD_PRETTY = YES - -# The names of the make variables in the generated doxyrules.make file -# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. -# This is useful so different doxyrules.make files included by the same -# Makefile don't overwrite each other's variables. - -PERLMOD_MAKEVAR_PREFIX = - -#--------------------------------------------------------------------------- -# Configuration options related to the preprocessor -#--------------------------------------------------------------------------- - -# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will -# evaluate all C-preprocessor directives found in the sources and include -# files. - -ENABLE_PREPROCESSING = YES - -# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro -# names in the source code. If set to NO (the default) only conditional -# compilation will be performed. Macro expansion can be done in a controlled -# way by setting EXPAND_ONLY_PREDEF to YES. - -MACRO_EXPANSION = NO - -# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES -# then the macro expansion is limited to the macros specified with the -# PREDEFINED and EXPAND_AS_DEFINED tags. - -EXPAND_ONLY_PREDEF = NO - -# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files -# in the INCLUDE_PATH (see below) will be search if a #include is found. - -SEARCH_INCLUDES = YES - -# The INCLUDE_PATH tag can be used to specify one or more directories that -# contain include files that are not input files but should be processed by -# the preprocessor. - -INCLUDE_PATH = - -# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard -# patterns (like *.h and *.hpp) to filter out the header-files in the -# directories. If left blank, the patterns specified with FILE_PATTERNS will -# be used. - -INCLUDE_FILE_PATTERNS = - -# The PREDEFINED tag can be used to specify one or more macro names that -# are defined before the preprocessor is started (similar to the -D option of -# gcc). The argument of the tag is a list of macros of the form: name -# or name=definition (no spaces). If the definition and the = are -# omitted =1 is assumed. To prevent a macro definition from being -# undefined via #undef or recursively expanded use the := operator -# instead of the = operator. - -PREDEFINED = - -# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then -# this tag can be used to specify a list of macro names that should be expanded. -# The macro definition that is found in the sources will be used. -# Use the PREDEFINED tag if you want to use a different macro definition. - -EXPAND_AS_DEFINED = - -# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then -# doxygen's preprocessor will remove all function-like macros that are alone -# on a line, have an all uppercase name, and do not end with a semicolon. Such -# function macros are typically used for boiler-plate code, and will confuse -# the parser if not removed. - -SKIP_FUNCTION_MACROS = YES - -#--------------------------------------------------------------------------- -# Configuration::additions related to external references -#--------------------------------------------------------------------------- - -# The TAGFILES option can be used to specify one or more tagfiles. -# Optionally an initial location of the external documentation -# can be added for each tagfile. The format of a tag file without -# this location is as follows: -# TAGFILES = file1 file2 ... -# Adding location for the tag files is done as follows: -# TAGFILES = file1=loc1 "file2 = loc2" ... -# where "loc1" and "loc2" can be relative or absolute paths or -# URLs. If a location is present for each tag, the installdox tool -# does not have to be run to correct the links. -# Note that each tag file must have a unique name -# (where the name does NOT include the path) -# If a tag file is not located in the directory in which doxygen -# is run, you must also specify the path to the tagfile here. - -TAGFILES = - -# When a file name is specified after GENERATE_TAGFILE, doxygen will create -# a tag file that is based on the input files it reads. - -GENERATE_TAGFILE = - -# If the ALLEXTERNALS tag is set to YES all external classes will be listed -# in the class index. If set to NO only the inherited external classes -# will be listed. - -ALLEXTERNALS = NO - -# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed -# in the modules index. If set to NO, only the current project's groups will -# be listed. - -EXTERNAL_GROUPS = YES - -# The PERL_PATH should be the absolute path and name of the perl script -# interpreter (i.e. the result of `which perl'). - -PERL_PATH = /usr/bin/perl - -#--------------------------------------------------------------------------- -# Configuration options related to the dot tool -#--------------------------------------------------------------------------- - -# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will -# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base -# or super classes. Setting the tag to NO turns the diagrams off. Note that -# this option is superseded by the HAVE_DOT option below. This is only a -# fallback. It is recommended to install and use dot, since it yields more -# powerful graphs. - -CLASS_DIAGRAMS = YES - -# If set to YES, the inheritance and collaboration graphs will hide -# inheritance and usage relations if the target is undocumented -# or is not a class. - -HIDE_UNDOC_RELATIONS = YES - -# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is -# available from the path. This tool is part of Graphviz, a graph visualization -# toolkit from AT&T and Lucent Bell Labs. The other options in this section -# have no effect if this option is set to NO (the default) - -HAVE_DOT = NO - -# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect inheritance relations. Setting this tag to YES will force the -# the CLASS_DIAGRAMS tag to NO. - -CLASS_GRAPH = YES - -# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect implementation dependencies (inheritance, containment, and -# class references variables) of the class with other documented classes. - -COLLABORATION_GRAPH = YES - -# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for groups, showing the direct groups dependencies - -GROUP_GRAPHS = YES - -# If the UML_LOOK tag is set to YES doxygen will generate inheritance and -# collaboration diagrams in a style similar to the OMG's Unified Modeling -# Language. - -UML_LOOK = NO - -# If set to YES, the inheritance and collaboration graphs will show the -# relations between templates and their instances. - -TEMPLATE_RELATIONS = NO - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT -# tags are set to YES then doxygen will generate a graph for each documented -# file showing the direct and indirect include dependencies of the file with -# other documented files. - -INCLUDE_GRAPH = YES - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and -# HAVE_DOT tags are set to YES then doxygen will generate a graph for each -# documented header file showing the documented files that directly or -# indirectly include this file. - -INCLUDED_BY_GRAPH = YES - -# If the CALL_GRAPH and HAVE_DOT tags are set to YES then doxygen will -# generate a call dependency graph for every global function or class method. -# Note that enabling this option will significantly increase the time of a run. -# So in most cases it will be better to enable call graphs for selected -# functions only using the \callgraph command. - -CALL_GRAPH = NO - -# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then doxygen will -# generate a caller dependency graph for every global function or class method. -# Note that enabling this option will significantly increase the time of a run. -# So in most cases it will be better to enable caller graphs for selected -# functions only using the \callergraph command. - -CALLER_GRAPH = NO - -# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen -# will graphical hierarchy of all classes instead of a textual one. - -GRAPHICAL_HIERARCHY = YES - -# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES -# then doxygen will show the dependencies a directory has on other directories -# in a graphical way. The dependency relations are determined by the #include -# relations between the files in the directories. - -DIRECTORY_GRAPH = YES - -# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images -# generated by dot. Possible values are png, jpg, or gif -# If left blank png will be used. - -DOT_IMAGE_FORMAT = png - -# The tag DOT_PATH can be used to specify the path where the dot tool can be -# found. If left blank, it is assumed the dot tool can be found in the path. - -DOT_PATH = - -# The DOTFILE_DIRS tag can be used to specify one or more directories that -# contain dot files that are included in the documentation (see the -# \dotfile command). - -DOTFILE_DIRS = - -# The MAX_DOT_GRAPH_WIDTH tag can be used to set the maximum allowed width -# (in pixels) of the graphs generated by dot. If a graph becomes larger than -# this value, doxygen will try to truncate the graph, so that it fits within -# the specified constraint. Beware that most browsers cannot cope with very -# large images. - -MAX_DOT_GRAPH_WIDTH = 1024 - -# The MAX_DOT_GRAPH_HEIGHT tag can be used to set the maximum allows height -# (in pixels) of the graphs generated by dot. If a graph becomes larger than -# this value, doxygen will try to truncate the graph, so that it fits within -# the specified constraint. Beware that most browsers cannot cope with very -# large images. - -MAX_DOT_GRAPH_HEIGHT = 1024 - -# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the -# graphs generated by dot. A depth value of 3 means that only nodes reachable -# from the root by following a path via at most 3 edges will be shown. Nodes -# that lay further from the root node will be omitted. Note that setting this -# option to 1 or 2 may greatly reduce the computation time needed for large -# code bases. Also note that a graph may be further truncated if the graph's -# image dimensions are not sufficient to fit the graph (see MAX_DOT_GRAPH_WIDTH -# and MAX_DOT_GRAPH_HEIGHT). If 0 is used for the depth value (the default), -# the graph is not depth-constrained. - -MAX_DOT_GRAPH_DEPTH = 0 - -# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent -# background. This is disabled by default, which results in a white background. -# Warning: Depending on the platform used, enabling this option may lead to -# badly anti-aliased labels on the edges of a graph (i.e. they become hard to -# read). - -DOT_TRANSPARENT = NO - -# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output -# files in one run (i.e. multiple -o and -T options on the command line). This -# makes dot run faster, but since only newer versions of dot (>1.8.10) -# support this, this feature is disabled by default. - -DOT_MULTI_TARGETS = NO - -# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will -# generate a legend page explaining the meaning of the various boxes and -# arrows in the dot generated graphs. - -GENERATE_LEGEND = YES - -# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will -# remove the intermediate dot files that are used to generate -# the various graphs. - -DOT_CLEANUP = YES - -#--------------------------------------------------------------------------- -# Configuration::additions related to the search engine -#--------------------------------------------------------------------------- - -# The SEARCHENGINE tag specifies whether or not a search engine should be -# used. If set to NO the values of all tags below this one will be ignored. - -SEARCHENGINE = NO diff --git a/trunk/Makefile b/trunk/Makefile deleted file mode 100644 index b32bace..0000000 --- a/trunk/Makefile +++ /dev/null @@ -1,63 +0,0 @@ -AR = ar -CC = gcc -LD = gcc -DOXYGEN = doxygen -INSTALL = install -SED = sed -MKDIR = mkdir -PKG_CONFIG = pkg-config - -ARFLAGS = -cru -CFLAGS = -g -Wall -Wextra -Wundef -Wpointer-arith -Wcast-align \ - -Wwrite-strings -Wstrict-prototypes \ - -Wnested-externs -Werror -pedantic -std=c99 \ - -Wno-format-zero-length -Wformat-security -Wstrict-aliasing=2 \ - -Wmissing-format-attribute -Wunused -Wunreachable-code \ - -Wformat=2 -Werror-implicit-function-declaration \ - -Wmissing-declarations -Wmissing-prototypes -LDFLAGS = -g -L./ - -# Installation prefix, if not already defined (e.g. on command line) -PREFIX ?= /usr/local -DESTDIR ?= - -.PHONY: all clean docs install uninstall - -all: librosprite.a - -example: librosprite.a example.o - ${LD} -o $@ example.o ${LDFLAGS} \ - $(shell PKG_CONFIG_PATH=.:$(PKG_CONFIG_PATH) $(PKG_CONFIG) --cflags --libs sdl librosprite) - -palette2c: librosprite.a palette2c.o - ${LD} -o $@ palette2c.o ${LDFLAGS} \ - $(shell PKG_CONFIG_PATH=.:$(PKG_CONFIG_PATH) $(PKG_CONFIG) --cflags --libs librosprite) - -librosprite.a: librosprite.o librosprite.pc - ${AR} ${ARFLAGS} librosprite.a librosprite.o - -librosprite.pc: librosprite.pc.in - $(SED) -e 's#PREFIX#$(PREFIX)#' librosprite.pc.in > librosprite.pc - -%.o: %.c - ${CC} -c ${CFLAGS} -o $@ $< - -docs: - ${DOXYGEN} - -clean: - rm -f $(wildcard *.o) $(wildcard *.a) example palette2c librosprite.pc - rm -rf doc - -install: librosprite.a librosprite.pc - $(MKDIR) -p $(DESTDIR)$(PREFIX)/lib/pkgconfig - $(MKDIR) -p $(DESTDIR)$(PREFIX)/lib - $(MKDIR) -p $(DESTDIR)$(PREFIX)/include - $(INSTALL) --mode=644 -t $(DESTDIR)$(PREFIX)/lib librosprite.a - $(INSTALL) --mode=644 -t $(DESTDIR)$(PREFIX)/include librosprite.h - $(INSTALL) --mode=644 -t $(DESTDIR)$(PREFIX)/lib/pkgconfig librosprite.pc - -uninstall: - rm $(DESTDIR)$(PREFIX)/lib/librosprite.a - rm $(DESTDIR)$(PREFIX)/include/librosprite.h - rm $(DESTDIR)$(PREFIX)/lib/pkgconfig/librosprite.pc diff --git a/trunk/example.c b/trunk/example.c deleted file mode 100644 index 4f9755e..0000000 --- a/trunk/example.c +++ /dev/null @@ -1,177 +0,0 @@ -/* - * This file is part of librosprite. - * Licensed under the MIT License, - * http://www.opensource.org/licenses/mit-license.php - * Copyright 2008 James Shaw - */ - -/** - * \file - * A test harness using SDL to display all sprites in a sprite file. - * - * Usage: example \ - */ - -#include -#include -#include - -#include "librosprite.h" - -void sdl_draw_pixel(SDL_Surface* surface, uint32_t x, uint32_t y, uint32_t color); -void sdl_blank(SDL_Surface* surface); -int load_file_to_memory(const char *filename, uint8_t **result); -int create_file_context(char* filename, void** result); -int create_mem_context(char* filename, void** result); - -int main(int argc, char *argv[]) -{ - if (argc < 2) { - fprintf(stderr, "Usage: example spritefile\n"); - exit(EXIT_FAILURE); - } - - if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) { - fprintf(stderr, "Unable to init SDL: %s\n", SDL_GetError()); - exit(EXIT_FAILURE); - } - atexit(SDL_Quit); - - char* filename = argv[1]; - void* ctx; - if (create_file_context(filename, &ctx) < 0) { - fprintf(stderr, "Unable to create file reader context\n"); - exit(EXIT_FAILURE); - } - - printf("Loading %s\n", filename); - - struct rosprite_area* sprite_area; - if (rosprite_load(rosprite_file_reader, ctx, &sprite_area) != ROSPRITE_OK) { - fprintf(stderr, "Error loading spritefile\n"); - exit(EXIT_FAILURE); - }; - printf("sprite_count %u\n", sprite_area->sprite_count); - printf("extension_size %u\n", sprite_area->extension_size); - - SDL_Surface *screen; - screen = SDL_SetVideoMode(800, 600, 32, SDL_ANYFORMAT); - SDL_SetAlpha(screen, SDL_SRCALPHA, 0); - - for (unsigned int i = 0; i < sprite_area->sprite_count; i++) { - struct rosprite* sprite = sprite_area->sprites[i]; - printf("\nname %s\n", sprite->name); - printf("color_model %s\n", sprite->mode.color_model == ROSPRITE_RGB ? "RGB" : "CMYK"); - printf("colorbpp %u\n", sprite->mode.colorbpp); - printf("xdpi %u\n", sprite->mode.xdpi); - printf("ydpi %u\n", sprite->mode.ydpi); - printf("width %u px\n", sprite->width); - printf("height %u px\n", sprite->height); - - printf("hasPalette %s\n", sprite->has_palette ? "YES" : "NO"); - if (sprite->has_palette) printf("paletteSize %u\n", sprite->palettesize); - - printf("hasMask %s\n", sprite->has_mask ? "YES" : "NO"); - if (sprite->has_mask) printf("mask_width %u\n", sprite->mode.mask_width); - if (sprite->has_mask) printf("maskbpp %u\n", sprite->mode.maskbpp); - - sdl_blank(screen); - - for (uint32_t y = 0; y < sprite->height; y++) { - for (uint32_t x = 0; x < sprite->width; x++) { - sdl_draw_pixel(screen, x, y, sprite->image[y*sprite->width + x]); - } - } - - SDL_UpdateRect(screen, 0, 0, 0, 0); - fgetc(stdin); - } - - rosprite_destroy_mem_context(ctx); - rosprite_destroy_sprite_area(sprite_area); - - return EXIT_SUCCESS; -} - -int create_file_context(char* filename, void** result) -{ - FILE *f = fopen(filename, "rb"); - if (!f) { - *result = NULL; - return -1; - } - - struct rosprite_file_context* ctx; - if (rosprite_create_file_context(f, &ctx) != ROSPRITE_OK) { - return -1; - } - *result = ctx; - - return 0; -} - -int create_mem_context(char* filename, void** result) -{ - uint8_t* content; - - int size = load_file_to_memory(filename, &content); - if (size < 0) return -1; - struct rosprite_mem_context* ctx; - if (rosprite_create_mem_context(content, size, &ctx) != ROSPRITE_OK) { - return -1; - } - *result = ctx; - - return 0; -} - -int load_file_to_memory(const char *filename, uint8_t **result) -{ - int size = 0; - FILE *f = fopen(filename, "rb"); - if (f == NULL) - { - *result = NULL; - return -1; // -1 means file opening fail - } - fseek(f, 0, SEEK_END); - size = ftell(f); - fseek(f, 0, SEEK_SET); - *result = (uint8_t *)malloc(size+1); - if ((unsigned int) size != fread(*result, sizeof(char), size, f)) - { - free(*result); - return -2; // -2 means file reading fail - } - fclose(f); - (*result)[size] = 0; - return size; -} - -/* color is 0xrrggbbaa */ -void sdl_draw_pixel(SDL_Surface* surface, uint32_t x, uint32_t y, uint32_t color) -{ - uint32_t* pixel = ((uint32_t*) (surface->pixels)) + (y * surface->pitch/4) + x; - /* pretty sure SDL can do this, but can't figure out how */ - uint32_t bg_color = ((int) (x / 4.0) + ((int)(y / 4.0) % 2)) % 2 ? 0x99 : 0x66; - - uint32_t alpha = color & 0x000000ff; - uint32_t r = (color & 0xff000000) >> 24; - uint32_t g = (color & 0x00ff0000) >> 16; - uint32_t b = (color & 0x0000ff00) >> 8; - r = ((alpha / 255.0) * r) + (((255-alpha) / 255.0) * bg_color); - g = ((alpha / 255.0) * g) + (((255-alpha) / 255.0) * bg_color); - b = ((alpha / 255.0) * b) + (((255-alpha) / 255.0) * bg_color); - uint32_t mapped_color = SDL_MapRGB(surface->format, r, g, b); - - *pixel = mapped_color; -} - -void sdl_blank(SDL_Surface* surface) -{ - for (uint32_t y = 0; y < (uint32_t) surface->h; y++) { - for (uint32_t x = 0; x < (uint32_t) surface->w; x++) { - sdl_draw_pixel(surface, x, y, (uint32_t) ((int) (x / 4.0) + ((int)(y / 4.0) % 2)) % 2 ? 0x999999ff : 0x666666ff); - } - } -} diff --git a/trunk/librosprite.c b/trunk/librosprite.c deleted file mode 100644 index e21b8cb..0000000 --- a/trunk/librosprite.c +++ /dev/null @@ -1,840 +0,0 @@ -/* - * This file is part of librosprite. - * Licensed under the MIT License, - * http://www.opensource.org/licenses/mit-license.php - * Copyright 2008 James Shaw - */ - -/** - * \file - */ - -#include -#include -#include -#include -#include -#include - -#include "librosprite.h" - -/** - * Reads four bytes, 00, 11, 22 and 33, of a byte array b to give 0x33221100. - */ -#define BTUINT(b) (b[0] | (b[1] << 8) | (b[2] << 16) | (b[3] << 24)) - -/** - * Reverse the byte order of a word such that 0xAABBCCDD becomes 0xDDCCBBAA. - */ -#define BSWAP(word) (((word & (0x000000ff)) << 24) | ((word & 0x0000ff00) << 8) | ((word & 0x00ff0000) >> 8) | ((word & 0xff000000) >> 24)) - -#define ERRCHK(x) do { \ - rosprite_error err = x; \ - if (err != ROSPRITE_OK) return err; \ -} while(0) - -struct rosprite_header { - uint32_t width_words; /* width in words */ - /* height defined in sprite struct */ - uint32_t first_used_bit; /* old format only (spriteType = 0) */ - uint32_t last_used_bit; - - /** - * Image size in bytes - */ - uint32_t image_size; - - /** - * Mask size in bytes - */ - uint32_t mask_size; -}; - -struct rosprite_mask_state { - uint32_t x; - uint32_t y; - uint32_t first_used_bit; - uint32_t row_max_bit; - uint32_t height; - uint32_t current_byte_index; - uint32_t current_word; - uint32_t bpp; -}; - -struct rosprite_file_context { - FILE* f; -}; - -struct rosprite_mem_context { - uint8_t* base; - unsigned long offset; - bool known_size; - unsigned long size; -}; - -static const struct rosprite_mode oldmodes[] = { -/*0*/{ .colorbpp = 1, .maskbpp = 1, .mask_width = 1, .xdpi = 90, .ydpi = 45, .color_model = ROSPRITE_RGB }, -/*1*/{ .colorbpp = 2, .maskbpp = 1, .mask_width = 2, .xdpi = 45, .ydpi = 45, .color_model = ROSPRITE_RGB }, -/*2*/{ .colorbpp = 4, .maskbpp = 1, .mask_width = 4, .xdpi = 22, .ydpi = 45, .color_model = ROSPRITE_RGB }, - -/*3*/{ .colorbpp = 0, .maskbpp = 0, .mask_width = 0, .xdpi = 0, .ydpi = 0, .color_model = ROSPRITE_RGB }, - -/*4*/{ .colorbpp = 1, .maskbpp = 1, .mask_width = 1, .xdpi = 45, .ydpi = 45, .color_model = ROSPRITE_RGB }, -/*5*/{ .colorbpp = 2, .maskbpp = 1, .mask_width = 2, .xdpi = 22, .ydpi = 45, .color_model = ROSPRITE_RGB }, - -/*6*/{ .colorbpp = 0, .maskbpp = 0, .mask_width = 0, .xdpi = 0, .ydpi = 0, .color_model = ROSPRITE_RGB }, -/*7*/{ .colorbpp = 0, .maskbpp = 0, .mask_width = 0, .xdpi = 0, .ydpi = 0, .color_model = ROSPRITE_RGB }, - -/*8*/{ .colorbpp = 2, .maskbpp = 1, .mask_width = 2, .xdpi = 90, .ydpi = 45, .color_model = ROSPRITE_RGB }, -/*9*/{ .colorbpp = 4, .maskbpp = 1, .mask_width = 4, .xdpi = 45, .ydpi = 45, .color_model = ROSPRITE_RGB }, -/*10*/{.colorbpp = 8, .maskbpp = 1, .mask_width = 8, .xdpi = 22, .ydpi = 45, .color_model = ROSPRITE_RGB }, -/*11*/{.colorbpp = 2, .maskbpp = 1, .mask_width = 2, .xdpi = 90, .ydpi = 45, .color_model = ROSPRITE_RGB }, -/*12*/{.colorbpp = 4, .maskbpp = 1, .mask_width = 4, .xdpi = 90, .ydpi = 45, .color_model = ROSPRITE_RGB }, -/*13*/{.colorbpp = 8, .maskbpp = 1, .mask_width = 8, .xdpi = 45, .ydpi = 45, .color_model = ROSPRITE_RGB }, -/*14*/{.colorbpp = 4, .maskbpp = 1, .mask_width = 4, .xdpi = 90, .ydpi = 45, .color_model = ROSPRITE_RGB }, -/*15*/{.colorbpp = 8, .maskbpp = 1, .mask_width = 8, .xdpi = 90, .ydpi = 45, .color_model = ROSPRITE_RGB }, -/*16*/{.colorbpp = 4, .maskbpp = 1, .mask_width = 4, .xdpi = 90, .ydpi = 45, .color_model = ROSPRITE_RGB }, -/*17*/{.colorbpp = 4, .maskbpp = 1, .mask_width = 4, .xdpi = 90, .ydpi = 45, .color_model = ROSPRITE_RGB }, -/*18*/{.colorbpp = 1, .maskbpp = 1, .mask_width = 1, .xdpi = 90, .ydpi = 90, .color_model = ROSPRITE_RGB }, -/*19*/{.colorbpp = 2, .maskbpp = 1, .mask_width = 2, .xdpi = 90, .ydpi = 90, .color_model = ROSPRITE_RGB }, -/*20*/{.colorbpp = 4, .maskbpp = 1, .mask_width = 4, .xdpi = 90, .ydpi = 90, .color_model = ROSPRITE_RGB }, -/*21*/{.colorbpp = 8, .maskbpp = 1, .mask_width = 8, .xdpi = 90, .ydpi = 90, .color_model = ROSPRITE_RGB }, -/*22*/{.colorbpp = 4, .maskbpp = 1, .mask_width = 4, .xdpi =180, .ydpi = 90, .color_model = ROSPRITE_RGB }, -/*23*/{.colorbpp = 1, .maskbpp = 1, .mask_width = 1, .xdpi = 90, .ydpi = 90, .color_model = ROSPRITE_RGB }, -/*24*/{.colorbpp = 8, .maskbpp = 1, .mask_width = 8, .xdpi = 90, .ydpi = 45, .color_model = ROSPRITE_RGB }, -/*25*/{.colorbpp = 1, .maskbpp = 1, .mask_width = 1, .xdpi = 90, .ydpi = 90, .color_model = ROSPRITE_RGB }, -/*26*/{.colorbpp = 2, .maskbpp = 1, .mask_width = 2, .xdpi = 90, .ydpi = 90, .color_model = ROSPRITE_RGB }, -/*27*/{.colorbpp = 4, .maskbpp = 1, .mask_width = 4, .xdpi = 90, .ydpi = 90, .color_model = ROSPRITE_RGB }, -/*28*/{.colorbpp = 8, .maskbpp = 1, .mask_width = 8, .xdpi = 90, .ydpi = 90, .color_model = ROSPRITE_RGB }, -/*29*/{.colorbpp = 1, .maskbpp = 1, .mask_width = 1, .xdpi = 90, .ydpi = 90, .color_model = ROSPRITE_RGB }, -/*30*/{.colorbpp = 2, .maskbpp = 1, .mask_width = 2, .xdpi = 90, .ydpi = 90, .color_model = ROSPRITE_RGB }, -/*31*/{.colorbpp = 4, .maskbpp = 1, .mask_width = 4, .xdpi = 90, .ydpi = 90, .color_model = ROSPRITE_RGB }, -/*32*/{.colorbpp = 8, .maskbpp = 1, .mask_width = 8, .xdpi = 90, .ydpi = 90, .color_model = ROSPRITE_RGB }, -/*33*/{.colorbpp = 1, .maskbpp = 1, .mask_width = 1, .xdpi = 90, .ydpi = 45, .color_model = ROSPRITE_RGB }, -/*34*/{.colorbpp = 2, .maskbpp = 1, .mask_width = 2, .xdpi = 90, .ydpi = 45, .color_model = ROSPRITE_RGB }, -/*35*/{.colorbpp = 4, .maskbpp = 1, .mask_width = 4, .xdpi = 90, .ydpi = 45, .color_model = ROSPRITE_RGB }, -/*36*/{.colorbpp = 8, .maskbpp = 1, .mask_width = 8, .xdpi = 90, .ydpi = 45, .color_model = ROSPRITE_RGB }, -/*37*/{.colorbpp = 1, .maskbpp = 1, .mask_width = 1, .xdpi = 90, .ydpi = 45, .color_model = ROSPRITE_RGB }, -/*38*/{.colorbpp = 2, .maskbpp = 1, .mask_width = 2, .xdpi = 90, .ydpi = 45, .color_model = ROSPRITE_RGB }, -/*39*/{.colorbpp = 4, .maskbpp = 1, .mask_width = 4, .xdpi = 90, .ydpi = 45, .color_model = ROSPRITE_RGB }, -/*40*/{.colorbpp = 8, .maskbpp = 1, .mask_width = 8, .xdpi = 90, .ydpi = 45, .color_model = ROSPRITE_RGB }, -/*41*/{.colorbpp = 1, .maskbpp = 1, .mask_width = 1, .xdpi = 90, .ydpi = 45, .color_model = ROSPRITE_RGB }, -/*42*/{.colorbpp = 2, .maskbpp = 1, .mask_width = 2, .xdpi = 90, .ydpi = 45, .color_model = ROSPRITE_RGB }, -/*43*/{.colorbpp = 4, .maskbpp = 1, .mask_width = 4, .xdpi = 90, .ydpi = 45, .color_model = ROSPRITE_RGB }, -/*44*/{.colorbpp = 1, .maskbpp = 1, .mask_width = 1, .xdpi = 90, .ydpi = 45, .color_model = ROSPRITE_RGB }, -/*45*/{.colorbpp = 2, .maskbpp = 1, .mask_width = 2, .xdpi = 90, .ydpi = 45, .color_model = ROSPRITE_RGB }, -/*46*/{.colorbpp = 4, .maskbpp = 1, .mask_width = 4, .xdpi = 90, .ydpi = 45, .color_model = ROSPRITE_RGB }, -/*47*/{.colorbpp = 8, .maskbpp = 1, .mask_width = 8, .xdpi = 45, .ydpi = 45, .color_model = ROSPRITE_RGB }, -/*48*/{.colorbpp = 4, .maskbpp = 1, .mask_width = 4, .xdpi = 45, .ydpi = 90, .color_model = ROSPRITE_RGB }, -/*49*/{.colorbpp = 8, .maskbpp = 1, .mask_width = 8, .xdpi = 45, .ydpi = 90, .color_model = ROSPRITE_RGB } -}; - -/* table for converting a 5bit channel into an 8bit channel (used for 16bpp to 32bpp conversion) */ -static const uint8_t sprite_16bpp_translate[] = { - 0x00, 0x08, 0x10, 0x18, 0x20, 0x29, 0x31, 0x39, - 0x41, 0x4a, 0x52, 0x5a, 0x62, 0x6a, 0x73, 0x7b, - 0x83, 0x8b, 0x94, 0x9c, 0xa4, 0xac, 0xb4, 0xbd, - 0xc5, 0xcd, 0xd5, 0xde, 0xe6, 0xee, 0xf6, 0xff -}; - -/* palettes generated with palette2c.c - * which in turn requires rosprite_load_palette(FILE* f) - * defined in this file - */ -static const uint32_t sprite_1bpp_palette[] = { 0xffffffff, 0xff }; - -static const uint32_t sprite_2bpp_palette[] = { 0xffffffff, 0xbbbbbbff, 0x777777ff, 0xff }; - -static const uint32_t sprite_4bpp_palette[] = { -0xffffffff, 0xddddddff, 0xbbbbbbff, 0x999999ff, -0x777777ff, 0x555555ff, 0x333333ff, 0xff, -0x4499ff, 0xeeee00ff, 0xcc00ff, 0xdd0000ff, -0xeeeebbff, 0x558800ff, 0xffbb00ff, 0xbbffff -}; - -static const uint32_t sprite_8bpp_palette[] = { -0xff, 0x111111ff, 0x222222ff, 0x333333ff, -0x440000ff, 0x551111ff, 0x662222ff, 0x773333ff, -0x44ff, 0x111155ff, 0x222266ff, 0x333377ff, -0x440044ff, 0x551155ff, 0x662266ff, 0x773377ff, -0x880000ff, 0x991111ff, 0xaa2222ff, 0xbb3333ff, -0xcc0000ff, 0xdd1111ff, 0xee2222ff, 0xff3333ff, -0x880044ff, 0x991155ff, 0xaa2266ff, 0xbb3377ff, -0xcc0044ff, 0xdd1155ff, 0xee2266ff, 0xff3377ff, -0x4400ff, 0x115511ff, 0x226622ff, 0x337733ff, -0x444400ff, 0x555511ff, 0x666622ff, 0x777733ff, -0x4444ff, 0x115555ff, 0x226666ff, 0x337777ff, -0x444444ff, 0x555555ff, 0x666666ff, 0x777777ff, -0x884400ff, 0x995511ff, 0xaa6622ff, 0xbb7733ff, -0xcc4400ff, 0xdd5511ff, 0xee6622ff, 0xff7733ff, -0x884444ff, 0x995555ff, 0xaa6666ff, 0xbb7777ff, -0xcc4444ff, 0xdd5555ff, 0xee6666ff, 0xff7777ff, -0x8800ff, 0x119911ff, 0x22aa22ff, 0x33bb33ff, -0x448800ff, 0x559911ff, 0x66aa22ff, 0x77bb33ff, -0x8844ff, 0x119955ff, 0x22aa66ff, 0x33bb77ff, -0x448844ff, 0x559955ff, 0x66aa66ff, 0x77bb77ff, -0x888800ff, 0x999911ff, 0xaaaa22ff, 0xbbbb33ff, -0xcc8800ff, 0xdd9911ff, 0xeeaa22ff, 0xffbb33ff, -0x888844ff, 0x999955ff, 0xaaaa66ff, 0xbbbb77ff, -0xcc8844ff, 0xdd9955ff, 0xeeaa66ff, 0xffbb77ff, -0xcc00ff, 0x11dd11ff, 0x22ee22ff, 0x33ff33ff, -0x44cc00ff, 0x55dd11ff, 0x66ee22ff, 0x77ff33ff, -0xcc44ff, 0x11dd55ff, 0x22ee66ff, 0x33ff77ff, -0x44cc44ff, 0x55dd55ff, 0x66ee66ff, 0x77ff77ff, -0x88cc00ff, 0x99dd11ff, 0xaaee22ff, 0xbbff33ff, -0xcccc00ff, 0xdddd11ff, 0xeeee22ff, 0xffff33ff, -0x88cc44ff, 0x99dd55ff, 0xaaee66ff, 0xbbff77ff, -0xcccc44ff, 0xdddd55ff, 0xeeee66ff, 0xffff77ff, -0x88ff, 0x111199ff, 0x2222aaff, 0x3333bbff, -0x440088ff, 0x551199ff, 0x6622aaff, 0x7733bbff, -0xccff, 0x1111ddff, 0x2222eeff, 0x3333ffff, -0x4400ccff, 0x5511ddff, 0x6622eeff, 0x7733ffff, -0x880088ff, 0x991199ff, 0xaa22aaff, 0xbb33bbff, -0xcc0088ff, 0xdd1199ff, 0xee22aaff, 0xff33bbff, -0x8800ccff, 0x9911ddff, 0xaa22eeff, 0xbb33ffff, -0xcc00ccff, 0xdd11ddff, 0xee22eeff, 0xff33ffff, -0x4488ff, 0x115599ff, 0x2266aaff, 0x3377bbff, -0x444488ff, 0x555599ff, 0x6666aaff, 0x7777bbff, -0x44ccff, 0x1155ddff, 0x2266eeff, 0x3377ffff, -0x4444ccff, 0x5555ddff, 0x6666eeff, 0x7777ffff, -0x884488ff, 0x995599ff, 0xaa66aaff, 0xbb77bbff, -0xcc4488ff, 0xdd5599ff, 0xee66aaff, 0xff77bbff, -0x8844ccff, 0x9955ddff, 0xaa66eeff, 0xbb77ffff, -0xcc44ccff, 0xdd55ddff, 0xee66eeff, 0xff77ffff, -0x8888ff, 0x119999ff, 0x22aaaaff, 0x33bbbbff, -0x448888ff, 0x559999ff, 0x66aaaaff, 0x77bbbbff, -0x88ccff, 0x1199ddff, 0x22aaeeff, 0x33bbffff, -0x4488ccff, 0x5599ddff, 0x66aaeeff, 0x77bbffff, -0x888888ff, 0x999999ff, 0xaaaaaaff, 0xbbbbbbff, -0xcc8888ff, 0xdd9999ff, 0xeeaaaaff, 0xffbbbbff, -0x8888ccff, 0x9999ddff, 0xaaaaeeff, 0xbbbbffff, -0xcc88ccff, 0xdd99ddff, 0xeeaaeeff, 0xffbbffff, -0xcc88ff, 0x11dd99ff, 0x22eeaaff, 0x33ffbbff, -0x44cc88ff, 0x55dd99ff, 0x66eeaaff, 0x77ffbbff, -0xccccff, 0x11ddddff, 0x22eeeeff, 0x33ffffff, -0x44ccccff, 0x55ddddff, 0x66eeeeff, 0x77ffffff, -0x88cc88ff, 0x99dd99ff, 0xaaeeaaff, 0xbbffbbff, -0xcccc88ff, 0xdddd99ff, 0xeeeeaaff, 0xffffbbff, -0x88ccccff, 0x99ddddff, 0xaaeeeeff, 0xbbffffff, -0xccccccff, 0xddddddff, 0xeeeeeeff, 0xffffffff -}; - -static inline rosprite_error rosprite_read_word(reader reader, void* ctx, uint32_t* result); -static rosprite_error rosprite_get_mode(uint32_t spriteMode, struct rosprite_mode* result); -static uint32_t rosprite_palette_lookup(struct rosprite* sprite, uint32_t pixel); -static inline uint32_t rosprite_cmyk_to_rgb(uint32_t cmyk); -static uint32_t rosprite_next_mask_pixel(uint8_t* mask, struct rosprite_mask_state* mask_state); -static rosprite_error rosprite_load_high_color(uint8_t* image_in, uint8_t* mask, struct rosprite* sprite, struct rosprite_header* header); -static rosprite_error rosprite_load_low_color(uint8_t* image_in, uint8_t* mask, struct rosprite* sprite, struct rosprite_header* header); -rosprite_error rosprite_load_sprite(reader reader, void* ctx, struct rosprite** result); -static rosprite_error rosprite_init_mask_state(struct rosprite* sprite, struct rosprite_header* header, uint8_t* mask, struct rosprite_mask_state** result); -static uint32_t rosprite_upscale_color(uint32_t pixel, struct rosprite_mode* mode, bool* has_alpha_pixel_data); -static inline void rosprite_fix_alpha(uint32_t* image, unsigned long pixels); - -rosprite_error rosprite_load(reader reader, void* ctx, struct rosprite_area** result) -{ - struct rosprite_area* sprite_area = malloc(sizeof(struct rosprite_area)); - - ERRCHK(rosprite_read_word(reader, ctx, &(sprite_area->sprite_count))); - - uint32_t firstSpriteOffset, firstFreeWordOffset; - ERRCHK(rosprite_read_word(reader, ctx, &firstSpriteOffset)); - ERRCHK(rosprite_read_word(reader, ctx, &firstFreeWordOffset)); /* TODO: use this for some sanity checking? */ - sprite_area->extension_size = 16 - firstSpriteOffset; - - sprite_area->extension_words = NULL; - if (sprite_area->extension_size > 0) { - sprite_area->extension_words = malloc(sprite_area->extension_size); - int bytes_read = reader(sprite_area->extension_words, (size_t) (sprite_area->extension_size), ctx); - if (bytes_read < (signed long) sprite_area->extension_size) { - return ROSPRITE_EOF; - } - } - - sprite_area->sprites = malloc(sizeof(struct rosprite*) * sprite_area->sprite_count); /* allocate array of pointers */ - for (uint32_t i = 0; i < sprite_area->sprite_count; i++) { - struct rosprite* sprite; - ERRCHK(rosprite_load_sprite(reader, ctx, &sprite)); - sprite_area->sprites[i] = sprite; - } - - *result = sprite_area; - - return ROSPRITE_OK; -} - -void rosprite_destroy_sprite_area(struct rosprite_area* sprite_area) -{ - for (uint32_t i = 0; i < sprite_area->sprite_count; i++) { - struct rosprite* sprite = sprite_area->sprites[i]; - if (sprite->has_palette) free(sprite->palette); - free(sprite->image); - free(sprite); - } - - free(sprite_area->sprites); - if (sprite_area->extension_size > 0) free(sprite_area->extension_words); - free(sprite_area); -} - -rosprite_error rosprite_load_palette(reader reader, void* ctx, struct rosprite_palette** result) -{ - /* TODO: currently assume palette has linear entries (2nd byte in is 00, 01, 02 etc) */ - struct rosprite_palette* palette = malloc(sizeof(struct rosprite_palette)); - - palette->palette = malloc(sizeof(uint32_t) * 256); /* allocate 256 whether we need them all or not */ - - uint32_t c = 0; - uint8_t b[6]; - - unsigned int bytesRead = reader(b, 6, ctx); - assert(bytesRead % 6 == 0); - while (bytesRead == 6) { - assert(b[0] == 19); /* VDU 19 */ - - /* only process logical colours */ - if (b[2] == 16) { - /*assert(c == b[1]);*/ - - uint32_t entry = (b[3] << 24) | (b[4] << 16) | (b[5] << 8) | 0xff; /* last byte is alpha */ - palette->palette[c] = entry; - - c++; - assert(c <= 256); - } - - bytesRead = reader(b, 6, ctx); - assert(bytesRead % 6 == 0); - } - - palette->size = c; - - *result = palette; - - return ROSPRITE_OK; -} - -void rosprite_destroy_palette(struct rosprite_palette* palette) -{ - free(palette->palette); - free(palette); -} - -rosprite_error rosprite_create_file_context(FILE* f, struct rosprite_file_context** result) -{ - struct rosprite_file_context* ctx = malloc(sizeof(struct rosprite_file_context)); - if (!ctx) return ROSPRITE_NOMEM; - ctx->f = f; - *result = ctx; - - return ROSPRITE_OK; -} - -void rosprite_destroy_file_context(struct rosprite_file_context* ctx) -{ - free(ctx); -} - -int rosprite_file_reader(uint8_t* buf, size_t count, void* ctx) -{ - return fread(buf, 1 /*size*/, count, ((struct rosprite_file_context*) ctx)->f); -} - -rosprite_error rosprite_create_mem_context(uint8_t* p, unsigned long total_size, struct rosprite_mem_context** result) -{ - struct rosprite_mem_context* ctx = malloc(sizeof(struct rosprite_mem_context)); - if (!ctx) return ROSPRITE_NOMEM; - - ctx->base = p; - ctx->offset = 0; - ctx->size = total_size; - *result = ctx; - - return ROSPRITE_OK; -} - -void rosprite_destroy_mem_context(struct rosprite_mem_context* ctx) -{ - free(ctx); -} - -int rosprite_mem_reader(uint8_t* buf, size_t count, void* ctx) -{ - struct rosprite_mem_context* memctx = (struct rosprite_mem_context*) ctx; - if (memctx->offset + count > memctx->size) { - return -1; - } - - // if we're asked for more memory than the block contains, only copy as much as we can - size_t copy_size; - if ((memctx->offset + count) > memctx->size) { - copy_size = memctx->size - memctx->offset; - } else { - copy_size = count; - } - memcpy(buf, memctx->base + memctx->offset, count); - memctx->offset += count; - return copy_size; -} - -/** - * Load a single sprite. - * - * \param[out] result - */ -rosprite_error rosprite_load_sprite(reader reader, void* ctx, struct rosprite** result) -{ - uint32_t nextSpriteOffset; - ERRCHK(rosprite_read_word(reader, ctx, &nextSpriteOffset)); - - struct rosprite* sprite = malloc(sizeof(struct rosprite)); - struct rosprite_header* header = malloc(sizeof(struct rosprite_header)); - - reader(sprite->name, 12, ctx); - sprite->name[12] = '\0'; - - ERRCHK(rosprite_read_word(reader, ctx, &header->width_words)); /* file has width - 1 and height - 1 */ - header->width_words += 1; - ERRCHK(rosprite_read_word(reader, ctx, &(sprite->height))); - sprite->height += 1; - ERRCHK(rosprite_read_word(reader, ctx, &(header->first_used_bit))); /* old format only (spriteType = 0) */ - ERRCHK(rosprite_read_word(reader, ctx, &(header->last_used_bit))); - - uint32_t imageOffset; - ERRCHK(rosprite_read_word(reader, ctx, &imageOffset)); - assert(imageOffset >= 44); /* should never be smaller than the size of the header) */ - - uint32_t maskOffset, spriteModeWord; - ERRCHK(rosprite_read_word(reader, ctx, &maskOffset)); - ERRCHK(rosprite_read_word(reader, ctx, &spriteModeWord)); - - ERRCHK(rosprite_get_mode(spriteModeWord, &(sprite->mode))); - - /* TODO left-hand wastage */ - - assert((header->last_used_bit + 1) % sprite->mode.colorbpp == 0); - /*assert(header->width_words % sprite->mode->colorbpp == 0);*/ - sprite->width = (header->width_words * 32 - header->first_used_bit - (31 - header->last_used_bit)) / sprite->mode.colorbpp; - - sprite->palettesize = imageOffset - 44; - sprite->has_palette = (sprite->palettesize > 0); - - /* sprite has no mask if imageOffset == maskOffset */ - if (imageOffset == maskOffset) { - sprite->has_mask = false; - header->image_size = nextSpriteOffset - 44 - sprite->palettesize; - header->mask_size = 0; - } else { - sprite->has_mask = true; - header->image_size = maskOffset - imageOffset; - header->mask_size = nextSpriteOffset - 44 - sprite->palettesize - header->image_size; - } - - if (sprite->has_palette) { - assert(sprite->palettesize % 8 == 0); - sprite->palette = malloc(sizeof(uint32_t) * sprite->palettesize); - uint32_t paletteEntries = sprite->palettesize / 8; - - /* Each palette entry is two words big - * The second word is a duplicate of the first - * I think this is in case you ever wanted flashing colours - * PRM1-730 - */ - for (uint32_t j = 0; j < paletteEntries; j++) { - uint32_t word1, word2; - ERRCHK(rosprite_read_word(reader, ctx, &word1)); - ERRCHK(rosprite_read_word(reader, ctx, &word2)); - assert(word1 == word2); /* if they aren't equal, flashing colours are desired, which we don't support */ - - /* swap rr and bb parts -- PRM1-731 */ - uint32_t entry = ((word1 & 0xff000000) >> 16) | (word1 & 0x00ff0000) | ((word1 & 0x0000ff00) << 16) | 0xff; - sprite->palette[j] = entry; - } - } - - uint8_t* image = malloc(header->image_size); - reader(image, header->image_size, ctx); - - uint8_t* mask = NULL; - if (sprite->has_mask) { - mask = malloc(header->mask_size); - reader(mask, header->mask_size, ctx); - } - - /* sanity check image_size */ - assert((header->width_words) * 4 * (sprite->height) == header->image_size); - /* TODO: sanity check mask_size */ - if (sprite->mode.colorbpp > 8) { - ERRCHK(rosprite_load_high_color(image, mask, sprite, header)); - } else { - ERRCHK(rosprite_load_low_color(image, mask, sprite, header)); - } - - free(image); - free(mask); - free(header); - - *result = sprite; - - return ROSPRITE_OK; -} - -/** - * Determine the sprite_mode for the specified sprite_mode_word. - * - * \param[out] result - */ -static rosprite_error rosprite_get_mode(uint32_t sprite_mode_word, struct rosprite_mode* result) -{ - struct rosprite_mode mode; - - uint32_t spriteType = (sprite_mode_word & (15 << 27)) >> 27; /* preserve bits 27-30 only */ - - if (spriteType != 0) { - bool hasEightBitAlpha = sprite_mode_word >> 31; /* bit 31 */ - /* new modes have 1bpp masks (PRM5a-111) - * unless bit 31 is set (http://select.riscos.com/prm/graphics/sprites/alphachannel.html) - */ - mode.maskbpp = (hasEightBitAlpha ? 8 : 1); - mode.mask_width = mode.maskbpp; - mode.xdpi = (sprite_mode_word & (8191 << 14)) >> 14; /* preserve bits 14-26 only */ - mode.ydpi = (sprite_mode_word & (8191 << 1)) >> 1; /* preserve bits 1-13 only */ - - mode.color_model = ROSPRITE_RGB; - switch (spriteType) { - case 1: - mode.colorbpp = 1; break; - case 2: - mode.colorbpp = 2; break; - case 3: - mode.colorbpp = 4; break; - case 4: - mode.colorbpp = 8; break; - case 5: - mode.colorbpp = 16; break; - case 6: - mode.colorbpp = 32; break; - case 7: - mode.colorbpp = 32; - mode.color_model = ROSPRITE_CMYK; - break; - case 8: - mode.colorbpp = 24; break; - default: - return ROSPRITE_BADMODE; - } - } else { - assert(sprite_mode_word < 256); /* don't think you can have modes over 255? */ - - mode = oldmodes[sprite_mode_word]; - } - - /* illegal mode check */ - if ((mode.colorbpp == 0) || (mode.xdpi == 0) || (mode.ydpi == 0)) { - return ROSPRITE_BADMODE; - } - - memcpy(result, &mode, sizeof(struct rosprite_mode)); - - return ROSPRITE_OK; -} - -/** - * Load a sprite image with 16 or more bpp. - * - * \param[out] sprite On exit, sprite.image will be populated - */ -static rosprite_error rosprite_load_high_color(uint8_t* image_in, uint8_t* mask, struct rosprite* sprite, struct rosprite_header* header) -{ - struct rosprite_mask_state* mask_state = NULL; - if (sprite->has_mask) { - ERRCHK(rosprite_init_mask_state(sprite, header, mask, &mask_state)); - } - - sprite->image = malloc(sprite->width * sprite->height * 4); /* all image data is 32bpp going out */ - - uint32_t currentByteIndex = 0; - const uint32_t bpp = sprite->mode.colorbpp; - const uint32_t bytesPerPixel = bpp / 8; - const uint32_t row_max_bit = header->width_words * 32 - (31 - header->last_used_bit); /* Last used bit in row */ - - bool has_alpha_pixel_data = false; - - /* Spec says that there must be no left-hand wastage */ - assert(header->first_used_bit == 0); - - for (uint32_t y = 0; y < sprite->height; y++) { - uint32_t x_pixels = 0; - for (uint32_t x = 0; x < row_max_bit; x += bpp) { - uint32_t pixel = 0; - for (uint32_t j = 0; j < bytesPerPixel; j++) { - uint8_t b = image_in[currentByteIndex++]; - pixel = pixel | (b << (j * 8)); - } - - bool old_has_alpha = has_alpha_pixel_data; - pixel = rosprite_upscale_color(pixel, &(sprite->mode), &has_alpha_pixel_data); - if (old_has_alpha != has_alpha_pixel_data && (y > 0 || x_pixels > 0)) { - rosprite_fix_alpha(sprite->image, (y * sprite->width) + x_pixels - 1); - } - if (sprite->has_mask) { - uint8_t mask_pixel = rosprite_next_mask_pixel(mask, mask_state); - pixel = (pixel & 0xffffff00) | mask_pixel; - } - sprite->image[y*sprite->width + x_pixels] = pixel; - x_pixels++; - } - - /* Ensure byte index is pointing at start of next row */ - if (y + 1 < sprite->height) { - currentByteIndex = (currentByteIndex + 3) & ~3; /* Round up to next multiple of 4 */ - } - } - - if (sprite->has_mask) free(mask_state); - return ROSPRITE_OK; -} - -/** - * Iterate over the specified number of pixels, starting at the image pointer, - * and set the alpha channel to 0x00. - */ -static inline void rosprite_fix_alpha(uint32_t* image, unsigned long pixels) -{ - for (uint32_t i = 0; i <= pixels; i++) { - image[i] = image[i] & 0xffffff00; - } -} - -/** - * Load a sprite image with 8 or fewer bpp. - * - * \param[out] sprite On exit, sprite.image will be populated - */ -static rosprite_error rosprite_load_low_color(uint8_t* image_in, uint8_t* mask, struct rosprite* sprite, struct rosprite_header* header) -{ - struct rosprite_mask_state* mask_state = NULL; - if (sprite->has_mask) { - ERRCHK(rosprite_init_mask_state(sprite, header, mask, &mask_state)); - } - - sprite->image = malloc(sprite->width * sprite->height * 4); /* all image data is 32bpp going out */ - - const uint32_t bpp = sprite->mode.colorbpp; - const uint32_t row_max_bit = header->width_words * 32 - (31 - header->last_used_bit); /* Last used bit in row */ - const uint32_t bitmask = (1 << bpp) - 1; /* creates a mask of 1s that is bpp bits wide */ - - uint32_t current_byte_index = 0; - uint32_t currentword = BTUINT((image_in + current_byte_index)); - current_byte_index += 4; - - for (uint32_t y = 0; y < sprite->height; y++) { - uint32_t x_pixels = 0; - for (uint32_t x = header->first_used_bit; x < row_max_bit ; x += bpp) { - const uint32_t offset_into_word = x % 32; - - uint32_t pixel = (currentword & (bitmask << offset_into_word)) >> offset_into_word; - pixel = rosprite_palette_lookup(sprite, pixel); /* lookup returns 32bpp */ - if (sprite->has_mask) { - uint8_t mask_pixel = rosprite_next_mask_pixel(mask, mask_state); - pixel = (pixel & 0xffffff00) | mask_pixel; - } - sprite->image[y*sprite->width + x_pixels] = pixel; - x_pixels++; - - /* If we're not at the end of the row and we've processed all of this word, fetch the next one */ - if (x + bpp < row_max_bit && offset_into_word + bpp == 32) { - currentword = BTUINT((image_in + current_byte_index)); - current_byte_index += 4; - } - } - - /* Advance to first word of next row */ - if (y + 1 < sprite->height) { - currentword = BTUINT((image_in + current_byte_index)); - current_byte_index += 4; - } - } - - if (sprite->has_mask) free(mask_state); - - return ROSPRITE_OK; -} - -static uint32_t rosprite_palette_lookup(struct rosprite* sprite, uint32_t pixel) -{ - uint32_t translated_pixel; - /* because we're dealing with 8bpp or less */ - if (sprite->has_palette) { - assert(pixel <= sprite->palettesize); /* TODO: what to do if your color depth is bigger than palette? */ - translated_pixel = sprite->palette[pixel]; - } else { - switch (sprite->mode.colorbpp) { - case 8: - assert(pixel < 256); - translated_pixel = sprite_8bpp_palette[pixel]; - break; - case 4: - assert(pixel < 16); - translated_pixel = sprite_4bpp_palette[pixel]; - break; - case 2: - assert(pixel < 4); - translated_pixel = sprite_2bpp_palette[pixel]; - break; - case 1: - assert(pixel < 2); - translated_pixel = sprite_1bpp_palette[pixel]; - break; - default: - assert(false); - } - } - return translated_pixel; -} - -static rosprite_error rosprite_init_mask_state(struct rosprite* sprite, struct rosprite_header* header, uint8_t* mask, struct rosprite_mask_state** result) -{ - struct rosprite_mask_state* mask_state = malloc(sizeof(struct rosprite_mask_state)); - if (!mask_state) return ROSPRITE_NOMEM; - - mask_state->x = header->first_used_bit; - mask_state->y = 0; - mask_state->first_used_bit = header->first_used_bit; - mask_state->row_max_bit = sprite->width * sprite->mode.mask_width; - mask_state->height = sprite->height; - mask_state->bpp = sprite->mode.mask_width; - mask_state->current_word = BTUINT(mask); - mask_state->current_byte_index = 4; - - *result = mask_state; - - return ROSPRITE_OK; -} - -/** - * Get the next mask byte. - * A mask of 0xff denotes 100% opaque, 0x00 denotes 100% transparent. - * - * \param[in,out] mask_state - */ -static uint32_t rosprite_next_mask_pixel(uint8_t* mask, struct rosprite_mask_state* mask_state) -{ - /* a 1bpp mask (for new mode sprites), each row is word aligned (therefore potential righthand wastage */ - const uint32_t bitmask = (1 << mask_state->bpp) - 1; - const uint32_t offset_into_word = mask_state->x % 32; - uint32_t pixel = (mask_state->current_word & (bitmask << offset_into_word)) >> offset_into_word; - - if (mask_state->x + mask_state->bpp < mask_state->row_max_bit && offset_into_word + mask_state->bpp == 32) { - mask_state->current_word = BTUINT((mask + mask_state->current_byte_index)); - mask_state->current_byte_index += 4; - } - - mask_state->x += mask_state->bpp; - if (mask_state->x >= mask_state->row_max_bit) { - mask_state->x = mask_state->first_used_bit; - - if (mask_state->y + 1 < mask_state->height) { - mask_state->current_word = BTUINT((mask + mask_state->current_byte_index)); - mask_state->current_byte_index += 4; - } - - mask_state->y++; - } - - /* - * if the mask is 1bpp, make sure the whole byte is 0x00 or 0xff - */ - if (mask_state->bpp < 8) { - pixel = (pixel & 1) ? 0xff : 0x00; - } - - return pixel; -} - -/** - * Upscale a 16, 24 or 32bpp sprite to the 0xRRGGBBAA representation. - * Do not call this function with a sprite with less than 16bpp, - * but use a palette lookup instead. - */ -static uint32_t rosprite_upscale_color(uint32_t pixel, struct rosprite_mode* mode, bool* has_alpha_pixel_data) -{ - switch (mode->colorbpp) { - case 32: - if (mode->color_model == ROSPRITE_RGB) { - /* swap from 0xAABBGGRR to 0xRRGGBBAA */ - pixel = BSWAP(pixel); - } else { - pixel = rosprite_cmyk_to_rgb(pixel); - } - break; - case 24: - /* reverse byte order */ - pixel = BSWAP(pixel); - break; - case 16: - /* incoming format is b_00000000000000000bbbbbgggggrrrrr */ - { - uint8_t red = pixel & 31; - uint8_t green = (pixel & (31 << 5)) >> 5; - uint8_t blue = (pixel & (31 << 10)) >> 10; - - /* sanity check */ - assert(red < 32); - assert(green < 32); - assert(blue < 32); - - pixel = (sprite_16bpp_translate[red] << 24) - | (sprite_16bpp_translate[green] << 16) - | (sprite_16bpp_translate[blue] << 8); - } - break; - case 8: - case 4: - case 2: - case 1: - assert(false); /* shouldn't need to call for <= 8bpp, since a palette lookup will return 32bpp */ - default: - assert(false); /* unknown bpp */ - } - - uint8_t alpha = pixel & 0xff; - if (alpha == 0x00) { - if (!(*has_alpha_pixel_data)) { - pixel = pixel | 0xff; - } - } else { - *has_alpha_pixel_data = true; - } - return pixel; -} - -static inline uint32_t rosprite_cmyk_to_rgb(uint32_t cmyk) -{ - uint8_t c = cmyk & 0xff; - uint8_t m = (cmyk & 0xff00) >> 8; - uint8_t y = (cmyk & 0xff0000) >> 16; - uint8_t k = cmyk >> 24; - - /* Convert to CMY colourspace */ - uint8_t C = c + k; - uint8_t M = m + k; - uint8_t Y = y + k; - - /* And to RGB */ - uint8_t r = 255 - C; - uint8_t g = 255 - M; - uint8_t b = 255 - Y; - - return r << 24 | g << 16 | b << 8; -} - -static inline rosprite_error rosprite_read_word(reader reader, void* ctx, uint32_t* result) -{ - unsigned char b[4]; - if (reader(b, 4, ctx) < 4) { - return ROSPRITE_EOF; - } - *result = BTUINT(b); - return ROSPRITE_OK; -} diff --git a/trunk/librosprite.h b/trunk/librosprite.h deleted file mode 100644 index f54eaf2..0000000 --- a/trunk/librosprite.h +++ /dev/null @@ -1,185 +0,0 @@ -/* - * This file is part of librosprite. - * Licensed under the MIT License, - * http://www.opensource.org/licenses/mit-license.php - * Copyright 2008 James Shaw - */ - -/** - * \mainpage - * - * librosprite is a library for reading RISC OS sprite and palette files. The following subformats are supported: - *
    - *
  • 1-bit and 8-bit transparency masks
  • - *
  • Sprites with custom palettes
  • - *
  • Standard RISC OS 1-bit, 2-bit palettes, and 4-bit and 8-bit colour palettes
  • - *
  • Old-style sprites with most screen modes from 0-49 supported
  • - *
  • 32bpp CMYK
  • - *
  • Inline alpha channel, as used by Photodesk and Tinct
  • - *
- * - */ - -/** - * \file librosprite.h - * - * Sprite file reading is performed by rosprite_load(), and palette file reading by rosprite_load_palette(). - * - * Retrieving sprite or palette data is performed by a reader. - * librosprite implements file and memory readers. - * To use a reader, create a context by calling the - * rosprite_create_file_context() or rosprite_create_mem_context(). - * Pass the reader function, and the context you have created, to the load function, - * typically rosprite_load(). - */ - -#ifndef ROSPRITE_H -#define ROSPRITE_H - -#include -#include -#include - -typedef enum { ROSPRITE_OK, ROSPRITE_NOMEM, ROSPRITE_EOF, ROSPRITE_BADMODE } rosprite_error; - -typedef enum { ROSPRITE_RGB, ROSPRITE_CMYK } rosprite_color_model; - -/** - * A reader interface used to load sprite files. - */ -typedef int (*reader)(uint8_t* buf, size_t count, void* ctx); - -struct rosprite_file_context; - -/** - * A sprite area comprises zero or more rosprites. Optionally, it may also have an extension_words block. - */ -struct rosprite_area { - uint32_t extension_size; /* size of extension_words in bytes */ - uint8_t* extension_words; - uint32_t sprite_count; - struct rosprite** sprites; /* array of length sprite_count */ -}; - -/** - * A sprite mode defines the colour depth, colour model and bitmap resolution of a sprite. - */ -struct rosprite_mode { - /** - * The bits per colour channel. Legal values are 1, 2, 4, 8, 16, 24 and 32. - */ - uint32_t colorbpp; - /* maskbpp denotes the amount of alpha bpp used - * while mask_width is the bits used to store the mask. - * Old modes have the same mask_width as their colorbpp, but the value - * is always all-zeroes or all-ones. - * New modes can have 1bpp or 8bpp masks - */ - uint32_t maskbpp; - uint32_t mask_width; /* in pixels */ - - /** - * Horizontal dots per inch. Typical values are 22, 45, 90 and 180. - */ - uint32_t xdpi; - - /** - * Vertical dots per inch. Typical values are 22, 45, 90 and 180. - */ - uint32_t ydpi; - rosprite_color_model color_model; -}; - -struct rosprite_palette { - uint32_t size; /* in number of entries (each entry is a word) */ - uint32_t* palette; -}; - -/** - * A sprite is a bitmap image which has a mode, width and height. - */ -struct rosprite { - - /** - * The sprite name. This may be up to 12 characters long, and must be zero terminated. - */ - unsigned char name[13]; - struct rosprite_mode mode; - bool has_mask; - bool has_palette; - uint32_t palettesize; /* in number of entries (each entry is a word) */ - uint32_t* palette; - - /** - * Width in pixels - */ - uint32_t width; - - /** - * Height in pixels - */ - uint32_t height; - - /** - * Image data is a series of words, appearing on screen left-to-right, top-to-bottom. - * Each word takes the form 0xRRGGBBAA. A is the alpha channel, where 0 is transparent, and 255 is opaque. - */ - uint32_t* image; /* image data in 0xRRGGBBAA words */ -}; - -struct rosprite_file_context; - -/** - * Create a file reader context using the specified file handle. - * Clients must call rosprite_destroy_file_context() to dispose of the context. - * - * \param[out] result - */ -rosprite_error rosprite_create_file_context(FILE* f, struct rosprite_file_context** result); -void rosprite_destroy_file_context(struct rosprite_file_context* ctx); -int rosprite_file_reader(uint8_t* buf, size_t count, void* ctx); - -struct rosprite_mem_context; - -/** - * Create a memory reader context using the specified memory pointer. - * Clients must call rosprite_destroy_mem_context() to dispose of the context. - * - * \param[in] p pointer to the start of the memory block - * \param[in] total_size the size of the block pointed to by p, in bytes - * \param[out] result - */ -rosprite_error rosprite_create_mem_context(uint8_t* p, unsigned long total_size, struct rosprite_mem_context** result); -void rosprite_destroy_mem_context(struct rosprite_mem_context* ctx); -int rosprite_mem_reader(uint8_t* buf, size_t count, void* ctx); - -/** - * Load a rosprite_area using the reader provided. - * Clients must call rosprite_destroy_sprite_area() to dispose of the rosprite_area. - * - * \param[out] result The pointer to be populated by this function. - */ -rosprite_error rosprite_load(reader reader, void* ctx, struct rosprite_area** result); - -/** - * Dispose of a rosprite_area and its children. - */ -void rosprite_destroy_sprite_area(struct rosprite_area *); - -/** - * Load a RISC OS palette file. A palette file has RISC OS filetype 0xFED, - * and is a series of VDU 19 Set Palette commands, each command being 6 bytes long. - * - * Clients must call rosprite_destroy_palette() to dispose of the rosprite_palette. - * - * \param[out] result The pointer to be populated by this function. - * \see http://www.drobe.co.uk/show_manual.php?manual=/sh-cgi?manual=Vdu%26page=19 - */ -rosprite_error rosprite_load_palette(reader reader, void* ctx, struct rosprite_palette** result); - -/** - * Dispose of a rosprite_palette and its children. - */ -void rosprite_destroy_palette(struct rosprite_palette *); - -#endif diff --git a/trunk/librosprite.pc.in b/trunk/librosprite.pc.in deleted file mode 100644 index 322ca21..0000000 --- a/trunk/librosprite.pc.in +++ /dev/null @@ -1,10 +0,0 @@ -prefix=PREFIX -exec_prefix=${prefix} -libdir=${exec_prefix}/lib -includedir=${prefix}/include - -Name: librosprite -Description: Loads RISC OS sprite files -Version: 0.0.1 -Libs: -L${libdir} -lrosprite -Cflags: -I${includedir} diff --git a/trunk/palette2c.c b/trunk/palette2c.c deleted file mode 100644 index bbe272c..0000000 --- a/trunk/palette2c.c +++ /dev/null @@ -1,48 +0,0 @@ -/* - * This file is part of librosprite. - * Licensed under the MIT License, - * http://www.opensource.org/licenses/mit-license.php - * Copyright 2008 James Shaw - */ - -#include -#include - -#include "librosprite.h" - -int main(int argc, char *argv[]) -{ - if (argc < 2) { - printf("Usage: palette2c palettefile\n"); - exit(EXIT_FAILURE); - } - - char* filename = argv[1]; - - FILE* f = fopen(filename, "rb"); - if (f == NULL) { - printf("Can't load palettefile %s\n", filename); - exit(EXIT_FAILURE); - } - - struct rosprite_file_context* ctx; - if (rosprite_create_file_context(f, &ctx) != ROSPRITE_OK) { - exit(EXIT_FAILURE); - } - - struct rosprite_palette* palette; - if (rosprite_load_palette(rosprite_file_reader, ctx, &palette) != ROSPRITE_OK) { - exit(EXIT_FAILURE); - } - - for (uint32_t i = 0; i < palette->size; i++) { - printf("0x%x, ", palette->palette[i]); - } - - fclose(f); - - rosprite_destroy_file_context(ctx); - rosprite_destroy_palette(palette); - - return EXIT_SUCCESS; -} diff --git a/trunk/palettes/16colour b/trunk/palettes/16colour deleted file mode 100644 index 5ac39ea..0000000 Binary files a/trunk/palettes/16colour and /dev/null differ diff --git a/trunk/palettes/16mono b/trunk/palettes/16mono deleted file mode 100644 index f121b9a..0000000 Binary files a/trunk/palettes/16mono and /dev/null differ diff --git a/trunk/palettes/256colour b/trunk/palettes/256colour deleted file mode 100644 index e1f67bb..0000000 Binary files a/trunk/palettes/256colour and /dev/null differ diff --git a/trunk/palettes/256mono b/trunk/palettes/256mono deleted file mode 100644 index 0866679..0000000 Binary files a/trunk/palettes/256mono and /dev/null differ diff --git a/trunk/palettes/2mono b/trunk/palettes/2mono deleted file mode 100644 index a2afa45..0000000 Binary files a/trunk/palettes/2mono and /dev/null differ diff --git a/trunk/palettes/4mono b/trunk/palettes/4mono deleted file mode 100644 index 495ce8c..0000000 Binary files a/trunk/palettes/4mono and /dev/null differ diff --git a/trunk/test-data/32bpp-alpha-test b/trunk/test-data/32bpp-alpha-test deleted file mode 100644 index 92ebd63..0000000 Binary files a/trunk/test-data/32bpp-alpha-test and /dev/null differ diff --git a/trunk/test-data/primary-color-16bpp b/trunk/test-data/primary-color-16bpp deleted file mode 100644 index fba7a08..0000000 Binary files a/trunk/test-data/primary-color-16bpp and /dev/null differ diff --git a/trunk/test-data/small b/trunk/test-data/small deleted file mode 100644 index 5552782..0000000 Binary files a/trunk/test-data/small and /dev/null differ -- cgit v1.2.1