summaryrefslogtreecommitdiff
path: root/apps/examples/tiff
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-09-22 14:53:15 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-09-22 14:53:15 +0000
commit742308f3e3646dd27ef9679ba2ae8756a2a64f7c (patch)
tree6e8f4d279b8c647b3e5f8f9974352cbe177d7b6a /apps/examples/tiff
parent4a6bae6e0114f9856d6b31228faf9cc14144f1f2 (diff)
downloadnuttx-742308f3e3646dd27ef9679ba2ae8756a2a64f7c.tar.gz
nuttx-742308f3e3646dd27ef9679ba2ae8756a2a64f7c.tar.bz2
nuttx-742308f3e3646dd27ef9679ba2ae8756a2a64f7c.zip
Add TIFF unit test
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3969 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'apps/examples/tiff')
-rw-r--r--apps/examples/tiff/Makefile106
-rw-r--r--apps/examples/tiff/tiff_main.c145
2 files changed, 251 insertions, 0 deletions
diff --git a/apps/examples/tiff/Makefile b/apps/examples/tiff/Makefile
new file mode 100644
index 000000000..bbe168683
--- /dev/null
+++ b/apps/examples/tiff/Makefile
@@ -0,0 +1,106 @@
+############################################################################
+# apps/examples/tiff/Makefile
+#
+# Copyright (C) 2011 Gregory Nutt. All rights reserved.
+# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in
+# the documentation and/or other materials provided with the
+# distribution.
+# 3. Neither the name NuttX nor the names of its contributors may be
+# used to endorse or promote products derived from this software
+# without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+############################################################################
+
+-include $(TOPDIR)/.config
+-include $(TOPDIR)/Make.defs
+include $(APPDIR)/Make.defs
+
+# TIFF Unit Test
+
+ASRCS =
+CSRCS = tiff_main.c
+
+AOBJS = $(ASRCS:.S=$(OBJEXT))
+COBJS = $(CSRCS:.c=$(OBJEXT))
+
+SRCS = $(ASRCS) $(CSRCS)
+OBJS = $(AOBJS) $(COBJS)
+
+ifeq ($(WINTOOL),y)
+ BIN = "${shell cygpath -w $(APPDIR)/libapps$(LIBEXT)}"
+else
+ BIN = "$(APPDIR)/libapps$(LIBEXT)"
+endif
+
+ROOTDEPPATH = --dep-path .
+
+# TIFF built-in application info
+
+APPNAME = tiff
+PRIORITY = SCHED_PRIORITY_DEFAULT
+STACKSIZE = 2048
+
+# Common build
+
+VPATH =
+
+all: .built
+.PHONY: clean depend distclean
+
+$(AOBJS): %$(OBJEXT): %.S
+ $(call ASSEMBLE, $<, $@)
+
+$(COBJS): %$(OBJEXT): %.c
+ $(call COMPILE, $<, $@)
+
+.built: $(OBJS)
+ @( for obj in $(OBJS) ; do \
+ $(call ARCHIVE, $(BIN), $${obj}); \
+ done ; )
+ @touch .built
+
+.context:
+ifeq ($(CONFIG_EXAMPLES_USBSTRG_BUILTIN),y)
+ $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main)
+ @touch $@
+endif
+
+context: .context
+
+.depend: Makefile $(SRCS)
+ @$(MKDEP) $(ROOTDEPPATH) $(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep
+ @touch $@
+
+depend: .depend
+
+clean:
+ @rm -f *.o *~ .*.swp .built
+ @rm -f result.tif tmpfile1.dat tmpfile2.dat
+ $(call CLEAN)
+
+distclean: clean
+ @rm -f Make.dep .depend
+
+-include Make.dep
diff --git a/apps/examples/tiff/tiff_main.c b/apps/examples/tiff/tiff_main.c
new file mode 100644
index 000000000..279c9324d
--- /dev/null
+++ b/apps/examples/tiff/tiff_main.c
@@ -0,0 +1,145 @@
+/****************************************************************************
+ * apps/graphics/tiff/tiff_main.c
+ *
+ * Copyright (C) 2011 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <errno.h>
+
+#include <apps/tiff.h>
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: tiff_test
+ *
+ * Description:
+ * TIFF unit test.
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_EXAMPLES_TIFF_BUILTIN
+# define MAIN_NAME tiff_main
+#else
+# define MAIN_NAME user_start
+#endif
+
+int MAIN_NAME(int argc, char *argv[])
+{
+ struct tiff_info_s info;
+ uint8_t strip[3*256];
+ uint8_t *ptr;
+ int green;
+ int blue;
+ int ret;
+
+ /* Configure the interface structure */
+
+ memset(&info, 0, sizeof(struct tiff_info_s));
+ info.outfile = "result.tif";
+ info.tmpfile1 = "tmpfile1.dat";
+ info.tmpfile2 = "tmpfile2.dat";
+ info.colorfmt = FB_FMT_RGB24;
+ info.rps = 1;
+ info.imgwidth = 256;
+ info.imgheight = 256;
+ info.iobuffer = (uint8_t *)malloc(300);
+ info.iosize = 300;
+
+ /* Initialize the TIFF library */
+
+ ret = tiff_initialize(&info);
+ if (ret < 0)
+ {
+ printf("tiff_initialize() failed: %d\n", ret);
+ exit(1);
+ }
+
+ /* Add each strip to the TIFF file */
+
+ for (green = 0, ptr = strip; green < 256; green++)
+ {
+ for (blue = 0; blue < 256; blue++)
+ {
+ *ptr++ = (green + blue) >> 1;
+ *ptr++ = green;
+ *ptr++ = blue;
+ }
+
+ ret = tiff_addstrip(&info, strip);
+ if (ret < 0)
+ {
+ printf("tiff_addstrip() #%d failed: %d\n", green, ret);
+ exit(1);
+ }
+ }
+
+ /* Then finalize the TIFF file */
+
+ ret = tiff_finalize(&info);
+ if (ret < 0)
+ {
+ printf("tiff_initialize() failed: %d\n", ret);
+ exit(1);
+ }
+ return 0;
+}