Added vector and PNG icon support to rc (PNG icons are not yet supported by the rest

of the system, though).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19213 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2006-11-06 12:08:24 +00:00
parent c2c1e4c725
commit f23596149e
2 changed files with 80 additions and 2 deletions
+36 -2
View File
@@ -713,8 +713,28 @@ write_app_flags(const void *data, size_t length)
static void
write_app_icon(uint32 which, const void *data, size_t length)
{
fprintf(sOutputFile, "resource %s_icon ", which == B_MINI_ICON ? "mini" : "large");
write_raw(NULL, B_RAW_TYPE, data, length, which);
int32 lineWidth = 32;
const char* type = "";
switch (which) {
case B_MINI_ICON:
type = "mini";
lineWidth = 16;
break;
case B_LARGE_ICON:
type = "large";
break;
case 'VICN':
type = "vector";
break;
case 'PNG ':
type = "png";
break;
default:
fprintf(stderr, "write_app_icon() called with invalid type!\n");
break;
}
fprintf(sOutputFile, "resource %s_icon ", type);
write_raw(NULL, B_RAW_TYPE, data, length, lineWidth);
}
@@ -828,6 +848,20 @@ write_data(int32 id, const char *name, type_code type,
}
break;
case B_RAW_TYPE:
if (!strcmp(name, "BEOS:ICON")) {
write_app_icon('VICN', data, length);
return;
}
break;
case 'PNG ':
if (!strcmp(name, "BEOS:ICON")) {
write_app_icon('PNG ', data, length);
return;
}
break;
case 'MICN':
if (!strcmp(name, "BEOS:M:STD_ICON")) {
write_app_icon(B_MINI_ICON, data, length);
+44
View File
@@ -1575,6 +1575,48 @@ add_app_version()
}
static void
add_png_icon()
{
field_t* fields = (field_t*)alloc_mem(1 * sizeof(field_t));
fields[0].type = get_type("raw");
fields[0].name = "icon";
fields[0].resize = 0;
fields[0].data = make_data(fields[0].resize, fields[0].type);
type_t type;
type.code = 'PNG ';
type.name = "png_icon";
type.fields = fields;
type.count = 1;
type.def_id = 101;
type.def_name = "BEOS:ICON";
type_table.insert(make_pair(type.name, type));
}
static void
add_vector_icon()
{
field_t* fields = (field_t*)alloc_mem(1 * sizeof(field_t));
fields[0].type = get_type("raw");
fields[0].name = "icon";
fields[0].resize = 0;
fields[0].data = make_data(fields[0].resize, fields[0].type);
type_t type;
type.code = 'RAWT';
type.name = "vector_icon";
type.fields = fields;
type.count = 1;
type.def_id = 101;
type.def_name = "BEOS:ICON";
type_table.insert(make_pair(type.name, type));
}
static void
add_large_icon()
{
@@ -1680,6 +1722,8 @@ init_parser()
add_app_version();
add_large_icon();
add_mini_icon();
add_vector_icon();
add_png_icon();
add_file_types();
add_define("B_SINGLE_LAUNCH", 0x0);