summaryrefslogtreecommitdiff
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
parent4a6bae6e0114f9856d6b31228faf9cc14144f1f2 (diff)
downloadpx4-nuttx-742308f3e3646dd27ef9679ba2ae8756a2a64f7c.tar.gz
px4-nuttx-742308f3e3646dd27ef9679ba2ae8756a2a64f7c.tar.bz2
px4-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
-rw-r--r--apps/examples/Makefile5
-rw-r--r--apps/examples/README.txt10
-rw-r--r--apps/examples/tiff/Makefile106
-rw-r--r--apps/examples/tiff/tiff_main.c145
-rw-r--r--apps/graphics/tiff/Makefile4
-rw-r--r--apps/graphics/tiff/README.txt15
-rw-r--r--apps/graphics/tiff/tiff_addstrip.c6
-rw-r--r--apps/graphics/tiff/tiff_internal.h8
-rw-r--r--apps/include/tiff.h9
-rwxr-xr-xnuttx/Documentation/README.html4
-rwxr-xr-xnuttx/README.txt2
11 files changed, 299 insertions, 15 deletions
diff --git a/apps/examples/Makefile b/apps/examples/Makefile
index 7810f1a69..759a896b2 100644
--- a/apps/examples/Makefile
+++ b/apps/examples/Makefile
@@ -40,7 +40,7 @@
SUBDIRS = buttons dhcpd ftpc hello helloxx hidkbd igmp mm mount \
nettest nsh null nx nxffs nxflat nxhello nximage nxlines \
nxtext ostest pashello pipe poll rgmp romfs sendmail serloop \
- thttpd udp uip usbserial usbstorage wget wlan
+ thttpd tiff udp uip usbserial usbstorage wget wlan
# Sub-directories that might need context setup
@@ -61,6 +61,9 @@ endif
ifeq ($(CONFIG_EXAMPLES_NXTEXT_BUILTIN),y)
CNTXTDIRS += nxtext
endif
+ifeq ($(CONFIG_EXAMPLES_TIFF_BUILTIN),y)
+CNTXTDIRS += tiff
+endif
ifeq ($(CONFIG_EXAMPLES_USBSTRG_BUILTIN),y)
CNTXTDIRS += usbstorage
endif
diff --git a/apps/examples/README.txt b/apps/examples/README.txt
index 8bd704ccf..027b0a669 100644
--- a/apps/examples/README.txt
+++ b/apps/examples/README.txt
@@ -730,6 +730,16 @@ examples/thttpd
CONFIGURED_APPS += uiplib
CONFIGURED_APPS += thttpd
+examples/tiff
+^^^^^^^^^^^^^
+
+ This is a simple unit test for the TIFF creation library at apps/graphic/tiff.
+ It is configured to work in the Linux user-mode simulation and has not been
+ tested in any other environment.
+
+ At a miniumum, you would probably have to change the hard-coded pathes to
+ the TIFF files defined in the example to run in an embedded platform.
+
examples/udp
^^^^^^^^^^^^
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;
+}
diff --git a/apps/graphics/tiff/Makefile b/apps/graphics/tiff/Makefile
index 9fc762c9c..617717c65 100644
--- a/apps/graphics/tiff/Makefile
+++ b/apps/graphics/tiff/Makefile
@@ -37,10 +37,10 @@
-include $(TOPDIR)/Make.defs
include $(APPDIR)/Make.defs
-# NuttX NX Graphics Example.
+# NuttX TIFF Creation Tool
ASRCS =
-CSRCS = tiff_addstrip.c tiff_finalize.c tiff_initialize.c tiff_utils.c
+CSRCS = tiff_addstrip.c tiff_finalize.c tiff_initialize.c tiff_utils.c
AOBJS = $(ASRCS:.S=$(OBJEXT))
COBJS = $(CSRCS:.c=$(OBJEXT))
diff --git a/apps/graphics/tiff/README.txt b/apps/graphics/tiff/README.txt
new file mode 100644
index 000000000..b414107ff
--- /dev/null
+++ b/apps/graphics/tiff/README.txt
@@ -0,0 +1,15 @@
+README for the TIFF Creation Library
+=====================================
+
+This directory contains a library that can be used to create TIFF image
+files. This file was created for the purpose of supporting screen dumps
+from an LCD. Howeve, the logic is general and could be used for most
+any purpose.
+
+The only usage documentation is in the (rather extensive) comments in
+the file apps/include/tiff.h
+
+Unit Test
+=========
+
+See apps/examples/tiff
diff --git a/apps/graphics/tiff/tiff_addstrip.c b/apps/graphics/tiff/tiff_addstrip.c
index 929a3a70e..165eec5ae 100644
--- a/apps/graphics/tiff/tiff_addstrip.c
+++ b/apps/graphics/tiff/tiff_addstrip.c
@@ -113,9 +113,9 @@ int tiff_convstrip(FAR struct tiff_info_s *info, FAR const uint8_t *strip)
/* Convert RGB565 to RGB888 */
rgb565 = *src++;
- *dest++ = (rgb565 >> 11);
- *dest++ = (rgb565 >> 5) & 0x3f;
- *dest++ = rgb565 & 0x1f;
+ *dest++ = (rgb565 >> (11-3)) & 0xf8; /* Move bits 11-15 to 3-7 */
+ *dest++ = (rgb565 >> ( 5-2)) & 0xfc; /* Move bits 5-10 to 2-7 */
+ *dest++ = (rgb565 << ( 3)) & 0xf8; /* Move bits 0- 4 to 3-7 */
/* Update the byte count */
diff --git a/apps/graphics/tiff/tiff_internal.h b/apps/graphics/tiff/tiff_internal.h
index ac14e0ad7..bfc2a0253 100644
--- a/apps/graphics/tiff/tiff_internal.h
+++ b/apps/graphics/tiff/tiff_internal.h
@@ -1,7 +1,7 @@
/****************************************************************************
* apps/graphics/tiff/tiff_internal.h
*
- * Copyright (C) 2010 Gregory Nutt. All rights reserved.
+ * 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
@@ -33,8 +33,8 @@
*
****************************************************************************/
-#ifndef __APPS_GRPHICS_TIFF_TIFF_INTERNAL_H
-#define __APPS_GRPHICS_TIFF_TIFF_INTERNAL_H
+#ifndef __APPS_GRAPHICS_TIFF_TIFF_INTERNAL_H
+#define __APPS_GRAPHICS_TIFF_TIFF_INTERNAL_H
/****************************************************************************
* Included Files
@@ -206,5 +206,5 @@ EXTERN ssize_t tiff_wordalign(int fd, size_t size);
}
#endif
-#endif /* __APPS_GRPHICS_TIFF_TIFF_INTERNAL_H */
+#endif /* __APPS_GRAPHICS_TIFF_TIFF_INTERNAL_H */
diff --git a/apps/include/tiff.h b/apps/include/tiff.h
index 2b3415d51..353005599 100644
--- a/apps/include/tiff.h
+++ b/apps/include/tiff.h
@@ -44,6 +44,7 @@
************************************************************************************/
#include <nuttx/config.h>
+#include <sys/types.h>
#include <nuttx/nx/nxglib.h>
/************************************************************************************
@@ -78,9 +79,9 @@
/* Values for the IFD tag type */
#define IFD_TAG_NEWSUBFILETYPE 254 /* NewSubfileType, LONG */
-# define TAG_SUBFILETYPE_REDUCED (1 << 0) /* Bit 0: Reduced resolution verson of image */
-# define TAG_SUBFILETYPE_SINGLE (1 << 1) /* Bit 1: Single page of a multi-page image */
-# define TAG_SUBFILETYPE_TRANSP (1 << 2) /* Bit 2: Defines a transparency mask for image */
+# define TAG_NEWSUBFILETYPE_REDUCED (1 << 0) /* Bit 0: Reduced resolution verson of image */
+# define TAG_NEWSUBFILETYPE_SINGLE (1 << 1) /* Bit 1: Single page of a multi-page image */
+# define TAG_NEWSUBFILETYPE_TRANSP (1 << 2) /* Bit 2: Defines a transparency mask for image */
#define IFD_TAG_SUBFILETYPE 255 /* SubfileType, SHORT */
# define TAG_SUBFILETYPE_FULL 1 /* Full-resolution image data */
# define TAG_SUBFILETYPE_REDUCED 2 /* Reduced-resolution image data */
@@ -97,7 +98,7 @@
# define TAG_COMP_T6 4 /* CCITT T.6 bi-level encoding */
# define TAG_COMP_LZW 5 /* LZW */
# define TAG_COMP_JPEG 6 /* LZW */
-# define TAG_COMP_NONE 32773 /* PackBits compression */
+# define TAG_COMP_PACKBITS 32773 /* PackBits compression */
#define IFD_TAG_PMI 262 /* PhotometricInterpretation, SHORT (Required) */
# define TAG_PMI_WHITE 0 /* WhiteIsZero */
# define TAG_PMI_BLACK 1 /* BlackIsZero */
diff --git a/nuttx/Documentation/README.html b/nuttx/Documentation/README.html
index 794eb18b6..2cd1908c4 100755
--- a/nuttx/Documentation/README.html
+++ b/nuttx/Documentation/README.html
@@ -8,7 +8,7 @@
<tr align="center" bgcolor="#e4e4e4">
<td>
<h1><big><font color="#3c34ec"><i>NuttX README Files</i></font></big></h1>
- <p>Last Updated: September 2, 2010</p>
+ <p>Last Updated: September 21, 2011</p>
</td>
</tr>
</table>
@@ -206,6 +206,8 @@
|- examples/
| |- <a href="http://nuttx.svn.sourceforge.net/viewvc/nuttx/trunk/apps/examples/pashello/README.txt?view=log">pashello/README.txt</a>
| `- <a href="http://nuttx.svn.sourceforge.net/viewvc/nuttx/trunk/apps/examples/README.txt?view=log"><b><i>README.txt</i></b></a>
+ |- graphics/
+ | `- <a href="http://nuttx.svn.sourceforge.net/viewvc/nuttx/trunk/apps/graphics/tiff/README.txt?view=log">"><b><i>tiff/README.txt</i></b></a>
|- interpreters/
| |- <a href="http://nuttx.svn.sourceforge.net/viewvc/nuttx/trunk/apps/interpreters/ficl/README.txt?view=log"><b><i>ficl/README.txt</i></b></a>
| `- <a href="http://nuttx.svn.sourceforge.net/viewvc/nuttx/trunk/apps/interpreters/README.txt?view=log"><b><i>README.txt</i></b></a>
diff --git a/nuttx/README.txt b/nuttx/README.txt
index 61f9ffe57..fe94337c4 100755
--- a/nuttx/README.txt
+++ b/nuttx/README.txt
@@ -493,6 +493,8 @@ apps
|- examples/
| |- pashello/README.txt
| `- README.txt
+ |- graphics/
+ | `- tiff/README.txt
|- interpreters/
| |- ficl
| | `- README.txt