Forum Discussion
Altera_Forum
Honored Contributor
19 years agoSure... Here's a quick Perl script that reads your bitmap image and creates a C char array from it:
=====#!/bin/env perl
$file = $ARGV;
open(INPUT, "$file") || die "Failed to open input file!!! Cannot convert!!!";
open(OUTPUT, "> ext_flash.h" );
# # Output the variable declaration and set an attribute on it.#
print(OUTPUT "unsigned char __attribute__ ((aligned(4))) data_buf = {\n");
$i = 0;
while(read(INPUT, $data, 1))
{
if($i == 0)
{
print(OUTPUT "\t");
}
#
# Here's the magic... use unpack to grab the file's data into an unsigned
# char variable.
#
printf(OUTPUT "%#02x, ", unpack("C", $data));
$i++;
if($i == 10)
{
print(OUTPUT "\n");
$i = 0;
}
}
print(OUTPUT "};\n\n");
close(FILE); ===== You could do this is most any language.... modify at will. Cheers, - slacker