diff --git a/src/tools/translation/bmpinfo/Jamfile b/src/tools/translation/bmpinfo/Jamfile index 584b9a15cf..fae0e01048 100644 --- a/src/tools/translation/bmpinfo/Jamfile +++ b/src/tools/translation/bmpinfo/Jamfile @@ -1,4 +1,11 @@ SubDir HAIKU_TOP src tools translation bmpinfo ; -BinCommand bmpinfo : bmpinfo.cpp : be ; +BinCommand bmpinfo : bmpinfo.cpp : be libbe.so $(HAIKU_LOCALE_LIBS) translation $(TARGET_LIBSTDC++) $(TARGET_LIBSUPC++) ; +AddResources bmpinfo : bmpinfo.rdef ; + +DoCatalogs bmpinfo : + x-vnd.Haiku-bmpsinfo + : + bmpinfo.cpp +; diff --git a/src/tools/translation/bmpinfo/bmpinfo.cpp b/src/tools/translation/bmpinfo/bmpinfo.cpp index b5eb0d7038..c5e7a516c0 100644 --- a/src/tools/translation/bmpinfo/bmpinfo.cpp +++ b/src/tools/translation/bmpinfo/bmpinfo.cpp @@ -36,10 +36,14 @@ #include #include #include +#include #include #include #include +#undef B_TRANSLATE_CONTEXT +#define B_TRANSLATE_CONTEXT "bmpinfo" + #define BMP_NO_COMPRESS 0 #define BMP_RLE8_COMPRESS 1 #define BMP_RLE4_COMPRESS 2 @@ -82,7 +86,7 @@ print_bmp_info(BFile &file) ssize_t size = 14; if (file.Read(buf, size) != size) { - printf("Error: unable to read BMP file header\n"); + printf(B_TRANSLATE("Error: unable to read BMP file header\n")); return; } @@ -96,16 +100,18 @@ print_bmp_info(BFile &file) swap_data(B_UINT32_TYPE, (reinterpret_cast (&fh)) + 2, 12, B_SWAP_LENDIAN_TO_HOST); - printf("\nFile Header:\n"); - printf(" magic: 0x%.4x (should be: 0x424d)\n", fh.magic); - printf(" file size: 0x%.8lx (%lu)\n", fh.fileSize, fh.fileSize); - printf(" reserved: 0x%.8lx (should be: 0x%.8x)\n", fh.reserved, 0); - printf("data offset: 0x%.8lx (%lu) (should be: >= 54 for MS format " - "and >= 26 for OS/2 format)\n", fh.dataOffset, fh.dataOffset); + printf(B_TRANSLATE("\nFile Header:\n")); + printf(B_TRANSLATE(" magic: 0x%.4x (should be: 0x424d)\n"), fh.magic); + printf(B_TRANSLATE(" file size: 0x%.8lx (%lu)\n"), fh.fileSize, + fh.fileSize); + printf(B_TRANSLATE(" reserved: 0x%.8lx (should be: 0x%.8x)\n"), + fh.reserved, 0); + printf(B_TRANSLATE("data offset: 0x%.8lx (%lu) (should be: >= 54 for MS " + "format and >= 26 for OS/2 format)\n"), fh.dataOffset, fh.dataOffset); uint32 headersize = 0; if (file.Read(&headersize, 4) != 4) { - printf("Error: unable to read info header size\n"); + printf(B_TRANSLATE("Error: unable to read info header size\n")); return; } swap_data(B_UINT32_TYPE, &headersize, 4, B_SWAP_LENDIAN_TO_HOST); @@ -115,7 +121,7 @@ print_bmp_info(BFile &file) MSInfoHeader msh; msh.size = headersize; if (file.Read(reinterpret_cast (&msh) + 4, 36) != 36) { - printf("Error: unable to read entire MS info header\n"); + printf(B_TRANSLATE("Error: unable to read entire MS info header\n")); return; } @@ -123,22 +129,33 @@ print_bmp_info(BFile &file) swap_data(B_UINT32_TYPE, reinterpret_cast (&msh) + 4, 36, B_SWAP_LENDIAN_TO_HOST); - printf("\nMS Info Header:\n"); - printf(" header size: 0x%.8lx (%lu) (should be: 40)\n", msh.size, msh.size); - printf(" width: %lu\n", msh.width); - printf(" height: %lu\n", msh.height); - printf(" planes: %u (should be: 1)\n", msh.planes); - printf(" bits per pixel: %u (should be: 1,4,8,16,24 or 32)\n", msh.bitsperpixel); - printf(" compression: %s (%lu)\n", - ((msh.compression == BMP_NO_COMPRESS) ? ("none") : - ((msh.compression == BMP_RLE8_COMPRESS) ? ("RLE 8") : - ((msh.compression == BMP_RLE4_COMPRESS) ? ("RLE 4") : - ("unknown")))), msh.compression); - printf(" image size: 0x%.8lx (%lu)\n", msh.imagesize, msh.imagesize); - printf(" x pixels/meter: %lu\n", msh.xpixperm); - printf(" y pixels/meter: %lu\n", msh.ypixperm); - printf(" colors used: %lu\n", msh.colorsused); - printf("colors important: %lu\n", msh.colorsimportant); + printf(B_TRANSLATE("\nMS Info Header:\n")); + printf(B_TRANSLATE(" header size: 0x%.8lx (%lu) (should be: " + "40)\n"), msh.size, msh.size); + printf(B_TRANSLATE(" width: %lu\n"), msh.width); + printf(B_TRANSLATE(" height: %lu\n"), msh.height); + printf(B_TRANSLATE(" planes: %u (should be: 1)\n"), + msh.planes); + printf(B_TRANSLATE(" bits per pixel: %u (should be: 1,4,8,16,24 or " + "32)\n"), msh.bitsperpixel); + if (msh.compression == BMP_NO_COMPRESS) + printf(B_TRANSLATE(" compression: none (%lu)\n"), + msh.compression); + else if (msh.compression == BMP_RLE8_COMPRESS) + printf(B_TRANSLATE(" compression: RLE8 (%lu)\n"), + msh.compression); + else if (msh.compression == BMP_RLE4_COMPRESS) + printf(B_TRANSLATE(" compression: RLE4 (%lu)\n"), + msh.compression); + else + printf(B_TRANSLATE(" compression: unknown (%lu)\n"), + msh.compression); + printf(B_TRANSLATE(" image size: 0x%.8lx (%lu)\n"), msh.imagesize, + msh.imagesize); + printf(B_TRANSLATE(" x pixels/meter: %lu\n"), msh.xpixperm); + printf(B_TRANSLATE(" y pixels/meter: %lu\n"), msh.ypixperm); + printf(B_TRANSLATE(" colors used: %lu\n"), msh.colorsused); + printf(B_TRANSLATE("colors important: %lu\n"), msh.colorsimportant); } else if (headersize == sizeof(OS2InfoHeader)) { // OS/2 format @@ -146,7 +163,8 @@ print_bmp_info(BFile &file) OS2InfoHeader os2; os2.size = headersize; if (file.Read(reinterpret_cast (&os2) + 4, 8) != 8) { - printf("Error: unable to read entire OS/2 info header\n"); + printf(B_TRANSLATE("Error: unable to read entire OS/2 info " + "header\n")); return; } @@ -154,17 +172,18 @@ print_bmp_info(BFile &file) swap_data(B_UINT32_TYPE, reinterpret_cast (&os2) + 4, 8, B_SWAP_LENDIAN_TO_HOST); - printf("\nOS/2 Info Header:\n"); - printf(" header size: 0x%.8lx (%lu) (should be: 12)\n", os2.size, os2.size); - printf(" width: %u\n", os2.width); - printf(" height: %u\n", os2.height); - printf(" planes: %u (should be: 1)\n", os2.planes); - printf("bits per pixel: %u (should be: 1,4,8 or 24)\n", + printf(B_TRANSLATE("\nOS/2 Info Header:\n")); + printf(B_TRANSLATE(" header size: 0x%.8lx (%lu) (should be: 12)\n"), + os2.size, os2.size); + printf(B_TRANSLATE(" width: %u\n"), os2.width); + printf(B_TRANSLATE(" height: %u\n"), os2.height); + printf(B_TRANSLATE(" planes: %u (should be: 1)\n"), os2.planes); + printf(B_TRANSLATE("bits per pixel: %u (should be: 1,4,8 or 24)\n"), os2.bitsperpixel); } else - printf("Error: info header size (%lu) does not match MS or OS/2 " - "info header size\n", headersize); + printf(B_TRANSLATE("Error: info header size (%lu) does not match MS " + "or OS/2 info header size\n"), headersize); } int @@ -173,18 +192,20 @@ main(int argc, char **argv) printf("\n"); if (argc == 1) { - printf("bmpinfo - reports information about a BMP image file\n"); - printf("\nUsage:\n"); - printf("bmpinfo filename.bmp\n"); + printf(B_TRANSLATE("bmpinfo - reports information about a BMP image " + "file\n")); + printf(B_TRANSLATE("\nUsage:\n")); + printf(B_TRANSLATE("bmpinfo filename.bmp\n")); } else { BFile file; for (int32 i = 1; i < argc; i++) { if (file.SetTo(argv[i], B_READ_ONLY) != B_OK) - printf("\nError opening %s\n", argv[i]); + printf(B_TRANSLATE("\nError opening %s\n"), argv[i]); else { - printf("\nBMP image information for: %s\n", argv[i]); + printf(B_TRANSLATE("\nBMP image information for: %s\n"), + argv[i]); print_bmp_info(file); } } diff --git a/src/tools/translation/bmpinfo/bmpinfo.rdef b/src/tools/translation/bmpinfo/bmpinfo.rdef new file mode 100644 index 0000000000..90e61483c4 --- /dev/null +++ b/src/tools/translation/bmpinfo/bmpinfo.rdef @@ -0,0 +1,17 @@ +/* + * bmpinfo.rdef + */ + +resource app_signature "application/x-vnd.Haiku-bmpinfo"; + +resource app_version { + major = 1, + middle = 0, + minor = 0, + variety = 0, + internal = 0, + short_info = "bmpinfo displays text information about BMP images.", + long_info = "Haiku bmpinfo is a command line tool for displaying text information about BMP images. Written by Michael Wilber, OBOS Translation Kit Team, Copyright © 2003 OpenBeOS Project." +}; + +resource app_flags B_SINGLE_LAUNCH;