imageconv.c File Reference

#include <stdio.h>

Go to the source code of this file.

Defines

#define ALIGN   ((-WIDTH * 3) & 3)
#define ASTRINGZ(s)   STRINGZ(s)
#define BLUE   0
#define BRIEF   "Definition of a small Atmel logo."
#define FILENAME_IN   "AVR32.bmp"
#define FILENAME_OUT   "avr32_logo.h"
#define GREEN   1
#define HEADER_SIZE   0x36
#define HEIGHT   240
#define NAME   SMALL_ATMEL_LOGO
#define RED   2
#define STRIDE   ((WIDTH * 2 + 3) & ~3)
#define STRINGZ(s)   #s
#define WIDTH   320

Functions

int main (void)
static unsigned int min (unsigned int a, unsigned int b)

Variables

unsigned char buf [WIDTH *HEIGHT][3]


Define Documentation

#define ALIGN   ((-WIDTH * 3) & 3)

Definition at line 16 of file imageconv.c.

Referenced by main().

#define ASTRINGZ (  )     STRINGZ(s)

Definition at line 20 of file imageconv.c.

Referenced by main().

#define BLUE   0

Definition at line 7 of file imageconv.c.

#define BRIEF   "Definition of a small Atmel logo."

Definition at line 14 of file imageconv.c.

Referenced by main().

#define FILENAME_IN   "AVR32.bmp"

Definition at line 11 of file imageconv.c.

Referenced by main().

#define FILENAME_OUT   "avr32_logo.h"

Definition at line 12 of file imageconv.c.

Referenced by main().

#define GREEN   1

Definition at line 6 of file imageconv.c.

#define HEADER_SIZE   0x36

Definition at line 3 of file imageconv.c.

Referenced by main().

#define HEIGHT   240

Definition at line 10 of file imageconv.c.

Referenced by main().

#define NAME   SMALL_ATMEL_LOGO

Definition at line 13 of file imageconv.c.

Referenced by main().

#define RED   2

Definition at line 5 of file imageconv.c.

#define STRIDE   ((WIDTH * 2 + 3) & ~3)

Definition at line 17 of file imageconv.c.

Referenced by main().

#define STRINGZ (  )     #s

Definition at line 19 of file imageconv.c.

#define WIDTH   320

Definition at line 9 of file imageconv.c.

Referenced by main().


Function Documentation

int main ( void   ) 

Definition at line 29 of file imageconv.c.

References ALIGN, ASTRINGZ, BLUE, BRIEF, buf, FILENAME_IN, FILENAME_OUT, GREEN, HEADER_SIZE, HEIGHT, min(), NAME, RED, STRIDE, and WIDTH.

00030 {
00031   unsigned int r, c;
00032 
00033   FILE *Fin = fopen(FILENAME_IN, "rb");
00034   FILE *Fout = fopen(FILENAME_OUT, "w");
00035 
00036   fseek(Fin, HEADER_SIZE, SEEK_SET);
00037   for (r = 0; r < HEIGHT; r++)
00038   {
00039     fread(&buf[r * WIDTH], sizeof(buf[0]), WIDTH, Fin);
00040     fseek(Fin, ALIGN, SEEK_CUR);
00041   }
00042 
00043   fprintf(Fout, "/*This file is prepared for Doxygen automatic documentation generation.*/\r\n"
00044                 "/*! \\file *********************************************************************\r\n"
00045                 " *\r\n"
00046                 " * \\brief "BRIEF"\r\n"
00047                 " *\r\n"
00048                 " * - Compiler:           IAR EWAVR32 and GNU GCC for AVR32\r\n"
00049                 " * - Supported devices:  All AVR32 devices can be used.\r\n"
00050                 " * - AppNote:\r\n"
00051                 " *\r\n"
00052                 " * \\author               Atmel Corporation: http://www.atmel.com \r\n"
00053                 " *                       Support and FAQ: http://support.atmel.no/\r\n"
00054                 " *\r\n"
00055                 " ******************************************************************************/\r\n"
00056                 "\r\n"
00057 /* Copyright (c) 2009 Atmel Corporation. All rights reserved.
00058  *
00059  * Redistribution and use in source and binary forms, with or without
00060  * modification, are permitted provided that the following conditions are met:
00061  *
00062  * 1. Redistributions of source code must retain the above copyright notice, this
00063  * list of conditions and the following disclaimer.
00064  *
00065  * 2. Redistributions in binary form must reproduce the above copyright notice,
00066  * this list of conditions and the following disclaimer in the documentation
00067  * and/or other materials provided with the distribution.
00068  *
00069  * 3. The name of Atmel may not be used to endorse or promote products derived
00070  * from this software without specific prior written permission.
00071  *
00072  * 4. This software may only be redistributed and used in connection with an Atmel
00073  * AVR product.
00074  *
00075  * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
00076  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
00077  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
00078  * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
00079  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00080  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00081  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00082  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00083  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00084  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
00085  *
00086  */
00087                 "\r\n"
00088                 "#ifndef _"ASTRINGZ(NAME)"_H_\r\n"
00089                 "#define _"ASTRINGZ(NAME)"_H_\r\n"
00090                 "\r\n"
00091                 "\r\n"
00092                 "static const unsigned short int avr32_logo[] =\r\n"
00093                 "{\r\n"
00094                 "  ");
00095 
00096   for (r = 0; r < HEIGHT; r++)
00097   {
00098     for (c = 0; c < STRIDE; )
00099     {
00100       if (c < WIDTH * 2)
00101       {
00102         unsigned short pixel = (min(buf[(HEIGHT - r - 1) * WIDTH + c / 2][RED  ] + 0x04, 0xFF) >> (8 - 5)) << (6 + 5) |
00103                                (min(buf[(HEIGHT - r - 1) * WIDTH + c / 2][GREEN] + 0x02, 0xFF) >> (8 - 6)) << 5 |
00104                                (min(buf[(HEIGHT - r - 1) * WIDTH + c / 2][BLUE ] + 0x04, 0xFF) >> (8 - 5));
00105         fprintf(Fout, "0x%.2hhX%.2hhX, ", (unsigned char)(pixel >> 8), (unsigned char)pixel);
00106         c += 2;
00107       }
00108       else
00109       {
00110         fputs("0x0000, ", Fout);
00111         c++;
00112       }
00113       if (!((r * STRIDE + c) % 16) && (r != HEIGHT - 1 || c != STRIDE)) fputs("\r\n  ", Fout);
00114     }
00115   }
00116 
00117   fputs("\r\n"
00118         "};\r\n"
00119         "\r\n", Fout);
00120 
00121   fprintf(Fout, "#endif");
00122   fprintf(Fout, "\r\n");
00123 
00124   fclose(Fout);
00125   fclose(Fin);
00126 }

static unsigned int min ( unsigned int  a,
unsigned int  b 
) [inline, static]

Definition at line 24 of file imageconv.c.

Referenced by main().

00025 {
00026   return (a < b) ? a : b;
00027 }


Variable Documentation

unsigned char buf[WIDTH *HEIGHT][3]

Definition at line 22 of file imageconv.c.

Referenced by main().


Generated on Fri Feb 19 02:23:34 2010 for AVR32 UC3 - ET024006DHU LCD Driver by  doxygen 1.5.5