* Renamed hbsg to generate_boot_screen and moved it to src/tools.

* Build generate_boot_screen as a build platform tool. It requires
  libpng to be installed.
* Added output file name as fourth argument.
* Replaced unnecessarily complicated
  fwrite(<string>, strlen(<string>),...) and sprintf()+fwrite()
  constructs by fputs() and fprintf() respectively.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24440 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold
2008-03-18 14:06:57 +00:00
parent 7d85665d0f
commit 2ca4cee18f
2 changed files with 29 additions and 28 deletions
+3
View File
@@ -37,6 +37,9 @@ BuildPlatformMain <build>copyattr : copyattr.cpp
BuildPlatformMain <build>data_to_source : data_to_source.cpp BuildPlatformMain <build>data_to_source : data_to_source.cpp
: $(HOST_LIBSUPC++) ; : $(HOST_LIBSUPC++) ;
BuildPlatformMain <build>generate_boot_screen : generate_boot_screen.cpp
: $(HOST_LIBSUPC++) $(HOST_LIBSTDC++) png ;
BuildPlatformMain <build>listattr : listattr.cpp : $(HOST_LIBBE) ; BuildPlatformMain <build>listattr : listattr.cpp : $(HOST_LIBBE) ;
if $(HOST_PLATFORM_BEOS_COMPATIBLE) { if $(HOST_PLATFORM_BEOS_COMPATIBLE) {
@@ -120,24 +120,21 @@ writeHeader(char *filename)
printf("Exporting image %s\n", varName); printf("Exporting image %s\n", varName);
// dumping palette // dumping palette
char *line = new char[80]; fprintf(foutput, "static const uint8 %sPalette[] = {\n", varName);
sprintf(line, "static const uint8 %sPalette[] = {\n", varName);
fwrite(line, strlen(line), 1, foutput);
for (int i = 0; i < paletteColors; i++) { for (int i = 0; i < paletteColors; i++) {
if (i == paletteColors - 1) if (i == paletteColors - 1) {
sprintf(line, "\t0x%x, 0x%x, 0x%x\n", palette[i].red, palette[i].green, palette[i].blue); fprintf(foutput, "\t0x%x, 0x%x, 0x%x\n", palette[i].red,
else palette[i].green, palette[i].blue);
sprintf(line, "\t0x%x, 0x%x, 0x%x,\n", palette[i].red, palette[i].green, palette[i].blue); } else {
fwrite(line, strlen(line), 1, foutput); fprintf(foutput, "\t0x%x, 0x%x, 0x%x,\n", palette[i].red,
palette[i].green, palette[i].blue);
}
} }
fwrite("};\n\n", strlen("};\n\n"), 1, foutput); fputs("};\n\n", foutput);
sprintf(line, "static const uint %sWidth=%d;\n", varName, width); fprintf(foutput, "static const uint %sWidth=%d;\n", varName, width);
fwrite(line, strlen(line), 1, foutput); fprintf(foutput, "static const uint %sHeight=%d;\n", varName, height);
sprintf(line, "static const uint %sHeight=%d;\n", varName, height); fprintf(foutput, "static const uint8 %sImage[] = {\n\t", varName);
fwrite(line, strlen(line), 1, foutput);
sprintf(line, "static const uint8 %sImage[] = {\n\t", varName);
fwrite(line, strlen(line), 1, foutput);
int offset = 0; int offset = 0;
unsigned char *data = new unsigned char[width * height]; unsigned char *data = new unsigned char[width * height];
for (y = 0; y < height; y++) { for (y = 0; y < height; y++) {
@@ -153,19 +150,18 @@ writeHeader(char *filename)
offset = 0; offset = 0;
while (!end) { while (!end) {
if (offset == (width * height)) { if (offset == (width * height)) {
sprintf(line, "0x%x", data[offset]); fprintf(foutput, "0x%x", data[offset]);
end = true; end = true;
} }
else else
sprintf(line, "0x%x, ", data[offset]); fprintf(foutput, "0x%x, ", data[offset]);
fwrite(line, strlen(line), 1, foutput);
if ((offset % 8) == 0) { if ((offset % 8) == 0) {
fwrite("\n\t", strlen("\n\t"), 1, foutput); fputs("\n\t", foutput);
} }
offset++; offset++;
} }
fwrite("};\n\n", strlen("};\n\n"), 1, foutput); fputs("};\n\n", foutput);
delete varName; delete varName;
} }
@@ -183,18 +179,20 @@ main(int argc, char *argv[])
printf("Copyright 2008, Artur Wyszynski <[email protected]>\n"); printf("Copyright 2008, Artur Wyszynski <[email protected]>\n");
printf("Distributed under the terms of the Haiku License. All rights reserved.\n"); printf("Distributed under the terms of the Haiku License. All rights reserved.\n");
if (argc < 4) { if (argc < 5) {
printf("Usage:\n"); printf("Usage:\n");
printf("\thbsg splash.png icons.png copyright.png\n"); printf("\thbsg <splash.png> <icons.png> <copyright.png> <images.h>\n");
return 0; return 0;
} }
foutput = fopen("images.h", "wb");
if (!foutput)
error("Could not open file images.h for writing");
fwrite("// This file was generated by Haiku Boot Splash Generator\n\n", const char* headerFileName = argv[4];
strlen("// This file was generated by Haiku Boot Splash Generator\n\n"), 1, foutput);
foutput = fopen(headerFileName, "wb");
if (!foutput)
error("Could not open file \"%s\" for writing", headerFileName);
fputs("// This file was generated by Haiku Boot Splash Generator\n\n",
foutput);
parseImage(argv[1]); parseImage(argv[1]);
parseImage(argv[2]); parseImage(argv[2]);