Localize bitsinfo
Closes ticket #7162. Signed-off-by: Niels Sascha Reedijk <[email protected]>
This commit is contained in:
committed by
Niels Sascha Reedijk
parent
eeb345aa17
commit
d05bb5a8e6
@@ -1,4 +1,15 @@
|
|||||||
SubDir HAIKU_TOP src tools translation bitsinfo ;
|
SubDir HAIKU_TOP src tools translation bitsinfo ;
|
||||||
|
|
||||||
BinCommand bitsinfo : bitsinfo.cpp : be $(TARGET_LIBSUPC++) ;
|
SetSubDirSupportedPlatformsBeOSCompatible ;
|
||||||
|
|
||||||
|
BinCommand bitsinfo :
|
||||||
|
bitsinfo.cpp
|
||||||
|
: be libbe.so $(HAIKU_LOCALE_LIBS) translation $(TARGET_LIBSTDC++) $(TARGET_LIBSUPC++) ;
|
||||||
|
|
||||||
|
AddResources bitsinfo : bitsinfo.rdef ;
|
||||||
|
|
||||||
|
DoCatalogs bitsinfo :
|
||||||
|
x-vnd.Haiku-bitsinfo
|
||||||
|
:
|
||||||
|
bitsinfo.cpp
|
||||||
|
;
|
||||||
|
|||||||
@@ -38,10 +38,14 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ByteOrder.h>
|
#include <ByteOrder.h>
|
||||||
|
#include <Catalog.h>
|
||||||
#include <File.h>
|
#include <File.h>
|
||||||
#include <TranslatorFormats.h>
|
#include <TranslatorFormats.h>
|
||||||
#include <StorageDefs.h>
|
#include <StorageDefs.h>
|
||||||
|
|
||||||
|
#undef B_TRANSLATE_CONTEXT
|
||||||
|
#define B_TRANSLATE_CONTEXT "bitsinfo"
|
||||||
|
|
||||||
struct ColorSpaceName {
|
struct ColorSpaceName {
|
||||||
color_space id;
|
color_space id;
|
||||||
const char *name;
|
const char *name;
|
||||||
@@ -62,7 +66,8 @@ PrintBitsInfo(const char *filepath, bool bdumppixels)
|
|||||||
// read in the rest of the header
|
// read in the rest of the header
|
||||||
ssize_t size = sizeof(TranslatorBitmap);
|
ssize_t size = sizeof(TranslatorBitmap);
|
||||||
if (file.Read(reinterpret_cast<uint8 *> (&header), size) != size) {
|
if (file.Read(reinterpret_cast<uint8 *> (&header), size) != size) {
|
||||||
printf("\nError: Unable to read the Be bitmap header.\n");
|
printf(B_TRANSLATE("\nError: Unable to read the Be bitmap "
|
||||||
|
"header.\n"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!bdumppixels)
|
if (!bdumppixels)
|
||||||
@@ -72,28 +77,29 @@ PrintBitsInfo(const char *filepath, bool bdumppixels)
|
|||||||
// convert to host byte order
|
// convert to host byte order
|
||||||
if (swap_data(B_UINT32_TYPE, &header, sizeof(TranslatorBitmap),
|
if (swap_data(B_UINT32_TYPE, &header, sizeof(TranslatorBitmap),
|
||||||
B_SWAP_BENDIAN_TO_HOST) != B_OK) {
|
B_SWAP_BENDIAN_TO_HOST) != B_OK) {
|
||||||
printf("\nError: Unable to swap byte order\n");
|
printf(B_TRANSLATE("\nError: Unable to swap byte order\n"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("\nBe bitmap (\"bits\") header for: %s\n\n", filepath);
|
printf(B_TRANSLATE("\nBe bitmap (\"bits\") header for: %s\n\n"),
|
||||||
|
filepath);
|
||||||
|
|
||||||
const uint32 kbitsmagic = 0x62697473UL;
|
const uint32 kbitsmagic = 0x62697473UL;
|
||||||
// in ASCII, this number looks like "bits"
|
// in ASCII, this number looks like "bits"
|
||||||
printf("magic number: 0x%.8lx ", header.magic);
|
|
||||||
if (header.magic == kbitsmagic)
|
if (header.magic == kbitsmagic)
|
||||||
printf("(valid)\n");
|
printf(B_TRANSLATE("magic number: 0x%.8lx (valid)\n"),
|
||||||
|
header.magic);
|
||||||
else
|
else
|
||||||
printf("(INVALID, should be: 0x%.8lx)\n",
|
printf(B_TRANSLATE("magic number: 0x%.8lx (INVALID, should be: "
|
||||||
kbitsmagic);
|
"0x%.8lx)\n"), header.magic, kbitsmagic);
|
||||||
printf("bounds: (%f, %f, %f, %f)\n",
|
printf(B_TRANSLATE("bounds: (%f, %f, %f, %f)\n"),
|
||||||
header.bounds.left, header.bounds.top,
|
header.bounds.left, header.bounds.top,
|
||||||
header.bounds.right, header.bounds.bottom);
|
header.bounds.right, header.bounds.bottom);
|
||||||
printf("dimensions: %d x %d\n",
|
printf(B_TRANSLATE("dimensions: %d x %d\n"),
|
||||||
static_cast<int>(header.bounds.Width() + 1),
|
static_cast<int>(header.bounds.Width() + 1),
|
||||||
static_cast<int>(header.bounds.Height() + 1));
|
static_cast<int>(header.bounds.Height() + 1));
|
||||||
|
|
||||||
printf("bytes per row: %u\n",
|
printf(B_TRANSLATE("bytes per row: %u\n"),
|
||||||
static_cast<unsigned int>(header.rowBytes));
|
static_cast<unsigned int>(header.rowBytes));
|
||||||
|
|
||||||
// print out colorspace if it matches an item in the list
|
// print out colorspace if it matches an item in the list
|
||||||
@@ -149,15 +155,15 @@ PrintBitsInfo(const char *filepath, bool bdumppixels)
|
|||||||
int32 i;
|
int32 i;
|
||||||
for (i = 0; i < kncolorspaces; i++) {
|
for (i = 0; i < kncolorspaces; i++) {
|
||||||
if (header.colors == colorspaces[i].id) {
|
if (header.colors == colorspaces[i].id) {
|
||||||
printf("color space: %s\n", colorspaces[i].name);
|
printf(B_TRANSLATE("color space: %s\n"), colorspaces[i].name);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (i == kncolorspaces)
|
if (i == kncolorspaces)
|
||||||
printf("color space: Unknown (0x%.8lx)\n",
|
printf(B_TRANSLATE("color space: Unknown (0x%.8lx)\n"),
|
||||||
static_cast<unsigned long>(header.colors));
|
static_cast<unsigned long>(header.colors));
|
||||||
|
|
||||||
printf("data size: %u\n",
|
printf(B_TRANSLATE("data size: %u\n"),
|
||||||
static_cast<unsigned int>(header.dataSize));
|
static_cast<unsigned int>(header.dataSize));
|
||||||
|
|
||||||
if (bdumppixels) {
|
if (bdumppixels) {
|
||||||
@@ -178,18 +184,19 @@ PrintBitsInfo(const char *filepath, bool bdumppixels)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
printf("Sorry, %s isn't supported yet"
|
printf(B_TRANSLATE("Sorry, %s isn't supported yet"
|
||||||
" for this color space\n", kpixels);
|
" for this color space\n"), kpixels);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
uint8 *prow = new uint8[header.rowBytes];
|
uint8 *prow = new uint8[header.rowBytes];
|
||||||
if (!prow) {
|
if (!prow) {
|
||||||
printf("Error: Not enough memory for row buffer\n");
|
printf(B_TRANSLATE("Error: Not enough memory for row "
|
||||||
|
"buffer\n"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ssize_t ret, n;
|
ssize_t ret, n;
|
||||||
uint32 totalbytes = 0;
|
uint32 totalbytes = 0;
|
||||||
printf("pixel data (%s):\n", components);
|
printf(B_TRANSLATE("pixel data (%s):\n"), components);
|
||||||
while ((ret = file.Read(prow, header.rowBytes)) > 0) {
|
while ((ret = file.Read(prow, header.rowBytes)) > 0) {
|
||||||
n = 0;
|
n = 0;
|
||||||
while (n < ret) {
|
while (n < ret) {
|
||||||
@@ -205,18 +212,21 @@ PrintBitsInfo(const char *filepath, bool bdumppixels)
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else
|
} else
|
||||||
printf("Error opening %s\n", filepath);
|
printf(B_TRANSLATE_COMMENT("Error opening %s\n",
|
||||||
|
"file path is opening"), filepath);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
if (argc == 1) {
|
if (argc == 1) {
|
||||||
printf("\nbitsinfo - reports information about a Be bitmap (\"bits\") image\n");
|
printf(B_TRANSLATE("\nbitsinfo - reports information about a Be "
|
||||||
printf("\nUsage:\n");
|
"bitmap (\"bits\") image\n"));
|
||||||
printf("bitsinfo [options] filename.bits\n\n");
|
printf(B_TRANSLATE("\nUsage:\n"));
|
||||||
printf("Options:\n\n");
|
printf(B_TRANSLATE("bitsinfo [options] filename.bits\n\n"));
|
||||||
printf("\t%s \t print RGB color for each pixel\n", kpixels);
|
printf(B_TRANSLATE("Options:\n\n"));
|
||||||
|
printf(B_TRANSLATE("\t%s \t print RGB color for each pixel\n"),
|
||||||
|
kpixels);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int32 first = 1;
|
int32 first = 1;
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
/*
|
||||||
|
* bitsinfo.rdef
|
||||||
|
*/
|
||||||
|
|
||||||
|
resource app_signature "application/x-vnd.Haiku-bitsinfo";
|
||||||
|
|
||||||
|
resource app_version {
|
||||||
|
major = 1,
|
||||||
|
middle = 0,
|
||||||
|
minor = 0,
|
||||||
|
variety = 0,
|
||||||
|
internal = 0,
|
||||||
|
short_info = "bitsinfo displays text information about Be bitmap format ("bits") images.",
|
||||||
|
long_info = "Haiku bitsinfo is a command line tool for displaying text information about Be bitmap format ("bits") images. Written by Michael Wilber, OBOS Translation Kit Team, Copyright © 2003 OpenBeOS Project."
|
||||||
|
};
|
||||||
|
|
||||||
|
resource app_flags B_SINGLE_LAUNCH;
|
||||||
Reference in New Issue
Block a user