* 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:
parent
7d85665d0f
commit
2ca4cee18f
@ -37,6 +37,9 @@ BuildPlatformMain <build>copyattr : copyattr.cpp
|
||||
BuildPlatformMain <build>data_to_source : data_to_source.cpp
|
||||
: $(HOST_LIBSUPC++) ;
|
||||
|
||||
BuildPlatformMain <build>generate_boot_screen : generate_boot_screen.cpp
|
||||
: $(HOST_LIBSUPC++) $(HOST_LIBSTDC++) png ;
|
||||
|
||||
BuildPlatformMain <build>listattr : listattr.cpp : $(HOST_LIBBE) ;
|
||||
|
||||
if $(HOST_PLATFORM_BEOS_COMPATIBLE) {
|
||||
|
@ -120,24 +120,21 @@ writeHeader(char *filename)
|
||||
printf("Exporting image %s\n", varName);
|
||||
|
||||
// dumping palette
|
||||
char *line = new char[80];
|
||||
sprintf(line, "static const uint8 %sPalette[] = {\n", varName);
|
||||
fwrite(line, strlen(line), 1, foutput);
|
||||
fprintf(foutput, "static const uint8 %sPalette[] = {\n", varName);
|
||||
for (int i = 0; i < paletteColors; i++) {
|
||||
if (i == paletteColors - 1)
|
||||
sprintf(line, "\t0x%x, 0x%x, 0x%x\n", palette[i].red, palette[i].green, palette[i].blue);
|
||||
else
|
||||
sprintf(line, "\t0x%x, 0x%x, 0x%x,\n", palette[i].red, palette[i].green, palette[i].blue);
|
||||
fwrite(line, strlen(line), 1, foutput);
|
||||
if (i == paletteColors - 1) {
|
||||
fprintf(foutput, "\t0x%x, 0x%x, 0x%x\n", palette[i].red,
|
||||
palette[i].green, palette[i].blue);
|
||||
} else {
|
||||
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);
|
||||
fwrite(line, strlen(line), 1, foutput);
|
||||
sprintf(line, "static const uint %sHeight=%d;\n", varName, height);
|
||||
fwrite(line, strlen(line), 1, foutput);
|
||||
sprintf(line, "static const uint8 %sImage[] = {\n\t", varName);
|
||||
fwrite(line, strlen(line), 1, foutput);
|
||||
fprintf(foutput, "static const uint %sWidth=%d;\n", varName, width);
|
||||
fprintf(foutput, "static const uint %sHeight=%d;\n", varName, height);
|
||||
fprintf(foutput, "static const uint8 %sImage[] = {\n\t", varName);
|
||||
int offset = 0;
|
||||
unsigned char *data = new unsigned char[width * height];
|
||||
for (y = 0; y < height; y++) {
|
||||
@ -153,19 +150,18 @@ writeHeader(char *filename)
|
||||
offset = 0;
|
||||
while (!end) {
|
||||
if (offset == (width * height)) {
|
||||
sprintf(line, "0x%x", data[offset]);
|
||||
fprintf(foutput, "0x%x", data[offset]);
|
||||
end = true;
|
||||
}
|
||||
else
|
||||
sprintf(line, "0x%x, ", data[offset]);
|
||||
fwrite(line, strlen(line), 1, foutput);
|
||||
fprintf(foutput, "0x%x, ", data[offset]);
|
||||
if ((offset % 8) == 0) {
|
||||
fwrite("\n\t", strlen("\n\t"), 1, foutput);
|
||||
fputs("\n\t", foutput);
|
||||
}
|
||||
offset++;
|
||||
}
|
||||
|
||||
fwrite("};\n\n", strlen("};\n\n"), 1, foutput);
|
||||
fputs("};\n\n", foutput);
|
||||
delete varName;
|
||||
}
|
||||
|
||||
@ -183,18 +179,20 @@ main(int argc, char *argv[])
|
||||
printf("Copyright 2008, Artur Wyszynski <harakash@gmail.com>\n");
|
||||
printf("Distributed under the terms of the Haiku License. All rights reserved.\n");
|
||||
|
||||
if (argc < 4) {
|
||||
if (argc < 5) {
|
||||
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;
|
||||
}
|
||||
|
||||
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",
|
||||
strlen("// This file was generated by Haiku Boot Splash Generator\n\n"), 1, foutput);
|
||||
const char* headerFileName = argv[4];
|
||||
|
||||
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[2]);
|
Loading…
Reference in New Issue
Block a user